@@ -1211,41 +1211,61 @@ class TestNSString : XCTestCase {
1211
1211
}
1212
1212
1213
1213
struct ComparisonTest {
1214
+ enum TestBehavior {
1215
+ case run
1216
+ case expectedFailure( String )
1217
+ case skip( String )
1218
+ }
1214
1219
let lhs : String
1215
1220
let rhs : String
1216
1221
let loc : UInt
1217
- let reason : String
1222
+ let behavior : TestBehavior
1218
1223
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
+ }
1221
1230
}
1222
1231
1223
1232
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
+ }
1231
1250
}
1232
1251
}
1233
1252
1234
- let comparisonTests = [
1253
+ let comparisonTests : [ ComparisonTest ] = [
1235
1254
ComparisonTest ( " " , " " ) ,
1236
1255
ComparisonTest ( " " , " a " ) ,
1237
1256
1238
1257
// ASCII cases
1239
1258
ComparisonTest ( " t " , " tt " ) ,
1240
1259
ComparisonTest ( " t " , " Tt " ) ,
1241
- ComparisonTest ( " \u{0} " , " " ) ,
1260
+ ComparisonTest ( " \u{0} " , " " ,
1261
+ skip: " rdar://problem/37686816 " ) ,
1242
1262
ComparisonTest ( " \u{0} " , " \u{0} " ,
1243
- reason : " https://bugs.swift.org/browse/SR-332 " ) ,
1263
+ expectedFailure : " https://bugs.swift.org/browse/SR-332 " ) ,
1244
1264
ComparisonTest ( " \r \n " , " t " ) ,
1245
1265
ComparisonTest ( " \r \n " , " \n " ,
1246
- reason : " blocked on rdar://problem/19036555 " ) ,
1266
+ expectedFailure : " blocked on rdar://problem/19036555 " ) ,
1247
1267
ComparisonTest ( " \u{0} " , " \u{0} \u{0} " ,
1248
- reason : " rdar://problem/19034601 " ) ,
1268
+ expectedFailure : " rdar://problem/19034601 " ) ,
1249
1269
1250
1270
// Whitespace
1251
1271
// U+000A LINE FEED (LF)
@@ -1309,7 +1329,7 @@ let comparisonTests = [
1309
1329
// U+1F1E7 REGIONAL INDICATOR SYMBOL LETTER B
1310
1330
// \u{1F1E7}\u{1F1E7} Flag of Barbados
1311
1331
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 " ) ,
1313
1333
1314
1334
// Test that Unicode collation is performed in deterministic mode.
1315
1335
//
@@ -1325,7 +1345,7 @@ let comparisonTests = [
1325
1345
// U+0301 and U+0954 don't decompose in the canonical decomposition mapping.
1326
1346
// U+0341 has a canonical decomposition mapping of U+0301.
1327
1347
ComparisonTest ( " \u{0301} " , " \u{0341} " ,
1328
- reason : " https://bugs.swift.org/browse/SR-243 " ) ,
1348
+ expectedFailure : " https://bugs.swift.org/browse/SR-243 " ) ,
1329
1349
ComparisonTest ( " \u{0301} " , " \u{0954} " ) ,
1330
1350
ComparisonTest ( " \u{0341} " , " \u{0954} " ) ,
1331
1351
]
@@ -1385,6 +1405,10 @@ func checkHasPrefixHasSuffix(_ lhs: String, _ rhs: String, _ stack: [UInt]) -> I
1385
1405
extension TestNSString {
1386
1406
func test_PrefixSuffix( ) {
1387
1407
for test in comparisonTests {
1408
+ if case . skip = test. behavior {
1409
+ continue
1410
+ }
1411
+
1388
1412
var failures = 0
1389
1413
failures += checkHasPrefixHasSuffix ( test. lhs, test. rhs, [ test. loc, #line] )
1390
1414
failures += checkHasPrefixHasSuffix ( test. rhs, test. lhs, [ test. loc, #line] )
@@ -1400,9 +1424,9 @@ extension TestNSString {
1400
1424
let fail = ( failures > 0 )
1401
1425
if fail {
1402
1426
// print("Prefix/Suffix case \(test.loc): \(failures) failures")
1403
- // print("Failures were\(test.xfail ? "" : " not") expected")
1427
+ // print("Failures were\(test.expectedFailure ? "" : " not") expected")
1404
1428
}
1405
- XCTAssert ( test. xfail == fail, " Unexpected \( test. xfail ? " success " : " failure " ) : \( test. loc) " )
1429
+ XCTAssert ( test. expectedFailure == fail, " Unexpected \( test. expectedFailure ? " success " : " failure " ) : \( test. loc) " )
1406
1430
}
1407
1431
}
1408
1432
}
0 commit comments