@@ -1211,41 +1211,61 @@ class TestNSString : XCTestCase {
12111211}
12121212
12131213struct ComparisonTest {
1214+ enum TestBehavior {
1215+ case run
1216+ case expectedFailure( String )
1217+ case skip( String )
1218+ }
12141219 let lhs : String
12151220 let rhs : String
12161221 let loc : UInt
1217- let reason : String
1222+ let behavior : TestBehavior
12181223
1219- var xfail : Bool {
1220- return !reason. isEmpty
1224+ var expectedFailure : Bool {
1225+ if case . expectedFailure = behavior {
1226+ return true
1227+ } else {
1228+ return false
1229+ }
12211230 }
12221231
12231232 init (
1224- _ lhs: String , _ rhs: String ,
1225- reason: String = " " , line: UInt = #line
1226- ) {
1227- self . lhs = lhs
1228- self . rhs = rhs
1229- self . reason = reason
1230- self . loc = line
1233+ _ lhs: String , _ rhs: String ,
1234+ expectedFailure xfailReason: String = " " ,
1235+ skip skipReason: String = " " ,
1236+ line: UInt = #line
1237+ ) {
1238+ self . lhs = lhs
1239+ self . rhs = rhs
1240+ self . loc = line
1241+
1242+ switch ( xfailReason. isEmpty, skipReason. isEmpty) {
1243+ case ( false , true ) :
1244+ behavior = . expectedFailure( xfailReason)
1245+ case ( _, false ) :
1246+ behavior = . skip( skipReason)
1247+ default :
1248+ behavior = . run
1249+ }
12311250 }
12321251}
12331252
1234- let comparisonTests = [
1253+ let comparisonTests : [ ComparisonTest ] = [
12351254 ComparisonTest ( " " , " " ) ,
12361255 ComparisonTest ( " " , " a " ) ,
12371256
12381257 // ASCII cases
12391258 ComparisonTest ( " t " , " tt " ) ,
12401259 ComparisonTest ( " t " , " Tt " ) ,
1241- ComparisonTest ( " \u{0} " , " " ) ,
1260+ ComparisonTest ( " \u{0} " , " " ,
1261+ skip: " rdar://problem/37686816 " ) ,
12421262 ComparisonTest ( " \u{0} " , " \u{0} " ,
1243- reason : " https://bugs.swift.org/browse/SR-332 " ) ,
1263+ expectedFailure : " https://bugs.swift.org/browse/SR-332 " ) ,
12441264 ComparisonTest ( " \r \n " , " t " ) ,
12451265 ComparisonTest ( " \r \n " , " \n " ,
1246- reason : " blocked on rdar://problem/19036555 " ) ,
1266+ expectedFailure : " blocked on rdar://problem/19036555 " ) ,
12471267 ComparisonTest ( " \u{0} " , " \u{0} \u{0} " ,
1248- reason : " rdar://problem/19034601 " ) ,
1268+ expectedFailure : " rdar://problem/19034601 " ) ,
12491269
12501270 // Whitespace
12511271 // U+000A LINE FEED (LF)
@@ -1309,7 +1329,7 @@ let comparisonTests = [
13091329 // U+1F1E7 REGIONAL INDICATOR SYMBOL LETTER B
13101330 // \u{1F1E7}\u{1F1E7} Flag of Barbados
13111331 ComparisonTest ( " \u{1F1E7} " , " \u{1F1E7} \u{1F1E7} " ,
1312- reason : " https://bugs.swift.org/browse/SR-367 " ) ,
1332+ expectedFailure : " https://bugs.swift.org/browse/SR-367 " ) ,
13131333
13141334 // Test that Unicode collation is performed in deterministic mode.
13151335 //
@@ -1325,7 +1345,7 @@ let comparisonTests = [
13251345 // U+0301 and U+0954 don't decompose in the canonical decomposition mapping.
13261346 // U+0341 has a canonical decomposition mapping of U+0301.
13271347 ComparisonTest ( " \u{0301} " , " \u{0341} " ,
1328- reason : " https://bugs.swift.org/browse/SR-243 " ) ,
1348+ expectedFailure : " https://bugs.swift.org/browse/SR-243 " ) ,
13291349 ComparisonTest ( " \u{0301} " , " \u{0954} " ) ,
13301350 ComparisonTest ( " \u{0341} " , " \u{0954} " ) ,
13311351]
@@ -1385,6 +1405,10 @@ func checkHasPrefixHasSuffix(_ lhs: String, _ rhs: String, _ stack: [UInt]) -> I
13851405extension TestNSString {
13861406 func test_PrefixSuffix( ) {
13871407 for test in comparisonTests {
1408+ if case . skip = test. behavior {
1409+ continue
1410+ }
1411+
13881412 var failures = 0
13891413 failures += checkHasPrefixHasSuffix ( test. lhs, test. rhs, [ test. loc, #line] )
13901414 failures += checkHasPrefixHasSuffix ( test. rhs, test. lhs, [ test. loc, #line] )
@@ -1400,9 +1424,9 @@ extension TestNSString {
14001424 let fail = ( failures > 0 )
14011425 if fail {
14021426 // print("Prefix/Suffix case \(test.loc): \(failures) failures")
1403- // print("Failures were\(test.xfail ? "" : " not") expected")
1427+ // print("Failures were\(test.expectedFailure ? "" : " not") expected")
14041428 }
1405- XCTAssert ( test. xfail == fail, " Unexpected \( test. xfail ? " success " : " failure " ) : \( test. loc) " )
1429+ XCTAssert ( test. expectedFailure == fail, " Unexpected \( test. expectedFailure ? " success " : " failure " ) : \( test. loc) " )
14061430 }
14071431 }
14081432}
0 commit comments