Skip to content

Commit 3eb9985

Browse files
authored
Merge pull request #510 from Azoy/remove-x-u-57
[5.7] Remove (?X) and (?u) for now
2 parents 6b2cb9d + cef8ea9 commit 3eb9985

File tree

5 files changed

+51
-17
lines changed

5 files changed

+51
-17
lines changed

Sources/_RegexParser/Regex/Parse/Sema.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,13 @@ extension RegexValidator {
106106
case .byteSemantics:
107107
throw error(.unsupported("byte semantic mode"), at: loc)
108108

109+
case .unicodeScalarSemantics:
110+
throw error(.unsupported("unicode scalar semantic mode"), at: loc)
111+
112+
case .graphemeClusterSemantics:
113+
throw error(.unsupported("grapheme semantic mode"), at: loc)
114+
109115
case .caseInsensitive, .possessiveByDefault, .reluctantByDefault,
110-
.unicodeScalarSemantics, .graphemeClusterSemantics,
111116
.singleLine, .multiline, .namedCapturesOnly, .extended, .extraExtended,
112117
.asciiOnlyDigit, .asciiOnlyWord, .asciiOnlySpace, .asciiOnlyPOSIXProps:
113118
break

Tests/RegexTests/CompileTests.swift

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,13 @@ extension RegexTests {
124124
"(?im)(?s).",
125125
matchingOptions(adding: [.caseInsensitive, .multiline, .singleLine]))
126126
try expectInitialOptions(".", matchingOptions())
127-
try expectInitialOptions(
128-
"(?im)(?s).(?u)",
129-
matchingOptions(adding: [.caseInsensitive, .multiline, .singleLine]))
127+
128+
// FIXME: Figure out (?X) and (?u) semantics
129+
try XCTExpectFailure("Figure out (?X) and (?u) semantics") {
130+
try expectInitialOptions(
131+
"(?im)(?s).(?u)",
132+
matchingOptions(adding: [.caseInsensitive, .multiline, .singleLine]))
133+
}
130134

131135
try expectInitialOptions(
132136
"(?i:.)",

Tests/RegexTests/MatchTests.swift

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,10 +1022,12 @@ extension RegexTests {
10221022
#"\u{65}\y"#, // Grapheme boundary assertion
10231023
("Cafe\u{301}", nil),
10241024
("Sol Cafe", "e"))
1025+
1026+
// FIXME: Figure out (?X) and (?u) semantics
10251027
firstMatchTests(
10261028
#"(?u)\u{65}\Y"#, // Grapheme non-boundary assertion
10271029
("Cafe\u{301}", "e"),
1028-
("Sol Cafe", nil))
1030+
("Sol Cafe", nil), xfail: true)
10291031
}
10301032

10311033
func testMatchGroups() {
@@ -1588,7 +1590,8 @@ extension RegexTests {
15881590
// a single Unicode scalar value, leaving any other grapheme scalar
15891591
// components to be matched.
15901592

1591-
firstMatchTest(#"(?u:.)"#, input: eDecomposed, match: "e")
1593+
// FIXME: Figure out (?X) and (?u) semantics
1594+
firstMatchTest(#"(?u:.)"#, input: eDecomposed, match: "e", xfail: true)
15921595

15931596
matchTest(
15941597
#".\u{301}"#,
@@ -1599,18 +1602,30 @@ extension RegexTests {
15991602
(eComposed, false),
16001603
(eDecomposed, false))
16011604

1605+
// FIXME: Figure out (?X) and (?u) semantics
16021606
// FIXME: \O is unsupported
1603-
firstMatchTest(#"(?u)\O\u{301}"#, input: eDecomposed, match: eDecomposed)
1604-
firstMatchTest(#"(?u)e\O"#, input: eDecomposed, match: eDecomposed)
1607+
firstMatchTest(
1608+
#"(?u)\O\u{301}"#,
1609+
input: eDecomposed,
1610+
match: eDecomposed,
1611+
xfail: true
1612+
)
1613+
firstMatchTest(
1614+
#"(?u)e\O"#,
1615+
input: eDecomposed,
1616+
match: eDecomposed,
1617+
xfail: true
1618+
)
16051619
firstMatchTest(#"\O"#, input: eComposed, match: eComposed)
16061620
firstMatchTest(#"\O"#, input: eDecomposed, match: nil,
16071621
xfail: true)
16081622

1623+
// FIXME: Figure out (?X) and (?u) semantics
16091624
matchTest(
16101625
#"(?u).\u{301}"#,
16111626
(eComposed, false),
1612-
(eDecomposed, true))
1613-
firstMatchTest(#"(?u).$"#, input: eComposed, match: eComposed)
1627+
(eDecomposed, true), xfail: true)
1628+
firstMatchTest(#"(?u).$"#, input: eComposed, match: eComposed, xfail: true)
16141629

16151630
// Option permutations for 'u' and 's'
16161631
matchTest(
@@ -1623,14 +1638,16 @@ extension RegexTests {
16231638
("e\u{301}ab", false),
16241639
("e\u{301}abc", true),
16251640
("e\u{301}\nab", true))
1641+
1642+
// FIXME: Figure out (?X) and (?u) semantics
16261643
matchTest(
16271644
#"(?u)...."#,
16281645
("e\u{301}ab", true),
1629-
("e\u{301}\na", false))
1646+
("e\u{301}\na", false), xfail: true)
16301647
matchTest(
16311648
#"(?us)...."#,
16321649
("e\u{301}ab", true),
1633-
("e\u{301}\na", true))
1650+
("e\u{301}\na", true), xfail: true)
16341651
}
16351652

16361653
// TODO: Add test for implied grapheme cluster requirement at group boundaries

Tests/RegexTests/ParseTests.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,9 +1102,11 @@ extension RegexTests {
11021102
.singleLine, .reluctantByDefault, .extraExtended, .extended,
11031103
.unicodeWordBoundaries, .asciiOnlyDigit, .asciiOnlyPOSIXProps,
11041104
.asciiOnlySpace, .asciiOnlyWord, .textSegmentGraphemeMode,
1105-
.textSegmentWordMode, .graphemeClusterSemantics, .unicodeScalarSemantics,
1105+
.textSegmentWordMode,
1106+
.graphemeClusterSemantics, .unicodeScalarSemantics,
11061107
.byteSemantics
11071108
]
1109+
11081110
parseTest("(?iJmnsUxxxwDPSWy{g}y{w}Xub-iJmnsUxxxwDPSW)", changeMatchingOptions(
11091111
matchingOptions(adding: allOptions, removing: allOptions.dropLast(5))
11101112
), throwsError: .unsupported)
@@ -2841,8 +2843,9 @@ extension RegexTests {
28412843
diagnosticTest("(?-y{g})", .cannotRemoveTextSegmentOptions)
28422844
diagnosticTest("(?-y{w})", .cannotRemoveTextSegmentOptions)
28432845

2844-
diagnosticTest("(?-X)", .cannotRemoveSemanticsOptions)
2845-
diagnosticTest("(?-u)", .cannotRemoveSemanticsOptions)
2846+
// FIXME: Reenable once we figure out (?X) and (?u) semantics
2847+
//diagnosticTest("(?-X)", .cannotRemoveSemanticsOptions)
2848+
//diagnosticTest("(?-u)", .cannotRemoveSemanticsOptions)
28462849
diagnosticTest("(?-b)", .cannotRemoveSemanticsOptions)
28472850

28482851
diagnosticTest("(?a)", .unknownGroupKind("?a"))

Tests/RegexTests/UTS18Tests.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ fileprivate func expectFirstMatch<Output: Equatable>(
6262
}
6363

6464
#if os(Linux)
65-
func XCTExpectFailure(_ message: String? = nil, body: () -> Void) {}
65+
func XCTExpectFailure(_ message: String? = nil, body: () throws -> Void) rethrows {}
6666
#endif
6767

6868
// MARK: - Basic Unicode Support: Level 1
@@ -466,7 +466,12 @@ extension UTS18Tests {
466466

467467
// Matching semantic level
468468
XCTAssertFalse("👩‍👩‍👧‍👦".contains(regex(#".\N{ZERO WIDTH JOINER}"#)))
469-
XCTAssertTrue("👩‍👩‍👧‍👦".contains(regex(#"(?u).\N{ZERO WIDTH JOINER}"#)))
469+
470+
// FIXME: Figure out (?X) and (?u) semantics
471+
XCTExpectFailure("Figure out (?X) and (?u) semantics") {
472+
XCTFail(#"(?u).\N{ZERO WIDTH JOINER}"#)
473+
//XCTAssertTrue("👩‍👩‍👧‍👦".contains(regex(#"(?u).\N{ZERO WIDTH JOINER}"#)))
474+
}
470475
}
471476

472477
func testIndividuallyNamedCharacters_XFail() {

0 commit comments

Comments
 (0)