File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 1
1
// RUN: %target-run-simple-swift
2
2
// REQUIRES: executable_test
3
+ // REQUIRES: optimized_stdlib
3
4
4
5
import StdlibUnittest
5
6
@@ -112,10 +113,18 @@ class RefCountedObj {
112
113
let RefcountTests = TestSuite ( " RefCount " )
113
114
RefcountTests . test ( " Basic " ) {
114
115
var Obj = RefCountedObj ( 47 ) ;
115
- expectEqual ( _getRetainCount ( Obj) , 2 ) ;
116
- expectEqual ( _getWeakRetainCount ( Obj) , 1 ) ;
117
- expectEqual ( _getUnownedRetainCount ( Obj) , 1 ) ;
118
- let _ = Obj . f ( ) // try to keep the object live here.
116
+
117
+ // Counters for live objects should be always positive.
118
+ // We try to be a little bit more lax here because optimizations
119
+ // or different stdlib versions might impact the exact value of
120
+ // refcounting, and we're just interested in testing whether the
121
+ // stub works properly.
122
+ expectGT ( _getRetainCount ( Obj) , 0 ) ;
123
+ expectGT ( _getWeakRetainCount ( Obj) , 0 ) ;
124
+ expectGT ( _getUnownedRetainCount ( Obj) , 0 ) ;
125
+
126
+ // Try to keep the object live here.
127
+ let _ = Obj . f ( )
119
128
}
120
129
121
130
runAllTests ( )
You can’t perform that action at this time.
0 commit comments