12
12
import XCTest
13
13
@testable import _RegexParser
14
14
@testable import _StringProcessing
15
+ import TestSupport
15
16
16
17
struct MatchError : Error {
17
18
var message : String
@@ -1003,6 +1004,9 @@ extension RegexTests {
1003
1004
}
1004
1005
1005
1006
func testMatchAnchors( ) throws {
1007
+ // Must have new stdlib for character class ranges and word boundaries.
1008
+ guard ensureNewStdlib ( ) else { return }
1009
+
1006
1010
// MARK: Anchors
1007
1011
firstMatchTests (
1008
1012
#"^\d+"# ,
@@ -1051,8 +1055,6 @@ extension RegexTests {
1051
1055
( " 123 \n 456 \n " , nil ) ,
1052
1056
( " 123 456 " , " 456 " ) )
1053
1057
1054
- // FIXME: Keep this until _wordIndex and friends are
1055
- #if os(Linux)
1056
1058
firstMatchTests (
1057
1059
#"\d+\b"# ,
1058
1060
( " 123 " , " 123 " ) ,
@@ -1070,7 +1072,6 @@ extension RegexTests {
1070
1072
( " 123 " , " 23 " ) ,
1071
1073
( " 123 " , " 23 " ) ,
1072
1074
( " 123 456 " , " 23 " ) )
1073
- #endif
1074
1075
1075
1076
// TODO: \G and \K
1076
1077
do {
@@ -1101,9 +1102,10 @@ extension RegexTests {
1101
1102
( " Sol Cafe " , nil ) , xfail: true )
1102
1103
}
1103
1104
1104
- // FIXME: Keep this until _wordIndex and friends are
1105
- #if os(Linux)
1106
1105
func testLevel2WordBoundaries( ) {
1106
+ // Must have new stdlib for character class ranges and word boundaries.
1107
+ guard ensureNewStdlib ( ) else { return }
1108
+
1107
1109
// MARK: Level 2 Word Boundaries
1108
1110
firstMatchTest ( #"\b😊\b"# , input: " 🔥😊👍 " , match: " 😊 " )
1109
1111
firstMatchTest ( #"\b👨🏽\b"# , input: " 👩🏻👶🏿👨🏽🧑🏾👩🏼 " , match: " 👨🏽 " )
@@ -1119,8 +1121,7 @@ extension RegexTests {
1119
1121
firstMatchTest ( #"can\B\'\Bt"# , input: " I can't do that. " , match: " can't " )
1120
1122
firstMatchTest ( #"\b÷\b"# , input: " 3 ÷ 3 = 1 " , match: " ÷ " )
1121
1123
}
1122
- #endif
1123
-
1124
+
1124
1125
func testMatchGroups( ) {
1125
1126
// MARK: Groups
1126
1127
@@ -1345,6 +1346,9 @@ extension RegexTests {
1345
1346
}
1346
1347
1347
1348
func testMatchExamples( ) {
1349
+ // Must have new stdlib for character class ranges and word boundaries.
1350
+ guard ensureNewStdlib ( ) else { return }
1351
+
1348
1352
// Backreferences
1349
1353
matchTest (
1350
1354
#"(sens|respons)e and \1ibility"# ,
@@ -1394,8 +1398,6 @@ extension RegexTests {
1394
1398
xfail: true
1395
1399
)
1396
1400
1397
- // FIXME: Keep this until _wordIndex and friends are
1398
- #if os(Linux)
1399
1401
// HTML tags
1400
1402
matchTest (
1401
1403
#"<([a-zA-Z][a-zA-Z0-9]*)\b[^>]*>.*?</\1>"# ,
@@ -1413,7 +1415,6 @@ extension RegexTests {
1413
1415
( " pass me the the kettle " , [ " the " ] ) ,
1414
1416
( " this doesn't have any " , nil )
1415
1417
)
1416
- #endif
1417
1418
1418
1419
// Floats
1419
1420
flatCaptureTest (
@@ -1493,6 +1494,9 @@ extension RegexTests {
1493
1494
}
1494
1495
1495
1496
func testASCIIClasses( ) {
1497
+ // Must have new stdlib for character class ranges and word boundaries.
1498
+ guard ensureNewStdlib ( ) else { return }
1499
+
1496
1500
// 'D' ASCII-only digits
1497
1501
matchTest (
1498
1502
#"\d+"# ,
@@ -1521,8 +1525,6 @@ extension RegexTests {
1521
1525
( " aeiou " , true ) ,
1522
1526
( " åe \u{301} ïôú " , false ) )
1523
1527
1524
- // FIXME: Keep this until _wordIndex and friends are
1525
- #if os(Linux)
1526
1528
matchTest (
1527
1529
#"abcd\b.+"# ,
1528
1530
( " abcd ef " , true ) ,
@@ -1538,7 +1540,6 @@ extension RegexTests {
1538
1540
( " abcd ef " , true ) ,
1539
1541
( " abcdef " , false ) ,
1540
1542
( " abcdéf " , false ) )
1541
- #endif
1542
1543
1543
1544
// 'S' ASCII-only spaces
1544
1545
matchTest (
0 commit comments