Skip to content

Commit 70ad70d

Browse files
committed
Add tests for individual scalar matching
1 parent a8aa433 commit 70ad70d

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

Tests/RegexTests/MatchTests.swift

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,23 @@ extension RegexTests {
837837
var eComposed: String { "é" }
838838
var eDecomposed: String { "e\u{301}" }
839839

840+
func testIndividualScalars() {
841+
matchTest(#"\u{65}\u{301}$"#, input: eDecomposed, match: eDecomposed)
842+
843+
matchTest(#"\u{65}"#, input: eDecomposed, match: "e")
844+
matchTest(#"\u{65}$"#, input: eDecomposed, match: nil)
845+
// FIXME: \y is unsupported
846+
matchTest(#"\u{65}\y"#, input: eDecomposed, match: nil,
847+
xfail: true)
848+
849+
// FIXME: Unicode scalars are only matched at the start of a grapheme cluster
850+
matchTest(#"\u{301}"#, input: eDecomposed, match: "\u{301}",
851+
xfail: true)
852+
// FIXME: \y is unsupported
853+
matchTest(#"\y\u{301}"#, input: eDecomposed, match: nil,
854+
xfail: true)
855+
}
856+
840857
func testCanonicalEquivalence() throws {
841858
// Expectation: Matching should use canonical equivalence whenever comparing
842859
// characters, so a user can write characters using any equivalent spelling
@@ -846,20 +863,22 @@ extension RegexTests {
846863
#"é$"#,
847864
(eComposed, eComposed),
848865
(eDecomposed, eDecomposed))
849-
866+
850867
// FIXME: Decomposed character in regex literal doesn't match an equivalent character
851868
matchTests(
852869
#"e\u{301}$"#,
853870
(eComposed, eComposed),
854871
(eDecomposed, eDecomposed),
855872
xfail: true)
856-
873+
matchTest(#"\u{65}\u{301}$"#, input: eComposed, match: eComposed,
874+
xfail: true)
875+
857876
matchTests(
858877
#"e$"#,
859878
(eComposed, nil),
860879
(eDecomposed, nil))
861880
}
862-
881+
863882
func testCanonicalEquivalenceCharacterClass() throws {
864883
// Expectation: Character classes should match equivalent characters to the
865884
// same degree, regardless of how they are spelled. Unicode "property
@@ -980,8 +999,7 @@ extension RegexTests {
980999
xfail: true)
9811000
matchTest(#"e\O"#, input: eDecomposed, match: eDecomposed,
9821001
xfail: true)
983-
// TODO: Should these two match or not?
984-
matchTest(#"\O\u{301}"#, input: eComposed, match: eComposed,
1002+
matchTest(#"\O\u{301}"#, input: eComposed, match: nil,
9851003
xfail: true)
9861004
matchTest(#"e\O"#, input: eComposed, match: nil,
9871005
xfail: true)

0 commit comments

Comments
 (0)