File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -67,7 +67,11 @@ public func XCTModify<Root, Case>(
67
67
return
68
68
}
69
69
70
- if let isEqual = _isEqual ( before, value) , isEqual {
70
+ if
71
+ XCTModifyLocals . isExhaustive,
72
+ let isEqual = _isEqual ( before, value) ,
73
+ isEqual
74
+ {
71
75
XCTFail (
72
76
"""
73
77
XCTModify failed: expected " \( Case . self) " value to be modified but it was unchanged.
@@ -77,4 +81,8 @@ public func XCTModify<Root, Case>(
77
81
root = casePath. embed ( value)
78
82
}
79
83
84
+ @_spi ( Internals) public enum XCTModifyLocals {
85
+ @TaskLocal public static var isExhaustive = true
86
+ }
87
+
80
88
private struct UnwrappingCase : Error { }
Original file line number Diff line number Diff line change 1
1
#if DEBUG && (os(iOS) || os(macOS) || os(tvOS) || os(watchOS))
2
- import CasePaths
2
+ @ _spi ( Internals ) import CasePaths
3
3
import XCTest
4
4
5
5
final class XCTModifyTests : XCTestCase {
117
117
}
118
118
XCTAssertEqual ( result, . success( 2 ) )
119
119
}
120
+
121
+ func testXCTModifyFailUnchangedEquatable_NonExhaustive( ) throws {
122
+ try XCTSkipIf ( ProcessInfo . processInfo. environment [ " CI " ] != nil )
123
+
124
+ var result = Result < Int , SomeError > . success ( 2 )
125
+ XCTModifyLocals . $isExhaustive. withValue ( false ) {
126
+ XCTModify ( & result, case: / Result. success) {
127
+ _ = $0
128
+ } }
129
+ XCTAssertEqual ( result, . success( 2 ) )
130
+ }
120
131
}
121
132
122
133
private struct SomeError : Error , Equatable { }
You can’t perform that action at this time.
0 commit comments