File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed
stdlib/private/StdlibUnittest Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,10 @@ fileprivate struct AtomicBool {
117
117
func orAndFetch( _ b: Bool ) -> Bool {
118
118
return _value. orAndFetch ( b ? 1 : 0 ) != 0
119
119
}
120
+
121
+ func fetchAndClear( ) -> Bool {
122
+ return _value. fetchAndAnd ( 0 ) != 0
123
+ }
120
124
}
121
125
122
126
func _printStackTrace( _ stackTrace: SourceLocStack ? ) {
@@ -139,11 +143,9 @@ public func expectFailure(
139
143
stackTrace: SourceLocStack = SourceLocStack ( ) ,
140
144
showFrame: Bool = true ,
141
145
file: String = #file, line: UInt = #line, invoking body: ( ) -> Void ) {
142
- let startAnyExpectFailed = _anyExpectFailed. load ( )
143
- _anyExpectFailed. store ( false )
146
+ let startAnyExpectFailed = _anyExpectFailed. fetchAndClear ( )
144
147
body ( )
145
- let endAnyExpectFailed = _anyExpectFailed. load ( )
146
- _anyExpectFailed. store ( false )
148
+ let endAnyExpectFailed = _anyExpectFailed. fetchAndClear ( )
147
149
expectTrue (
148
150
endAnyExpectFailed, " running `body` should produce an expected failure " ,
149
151
stackTrace: stackTrace. pushIf ( showFrame, file: file, line: line)
You can’t perform that action at this time.
0 commit comments