@@ -544,9 +544,8 @@ extension RegexTests {
544544 #"a\Q \Q \\.\Eb"# ,
545545 concat ( " a " , quote ( #" \Q \\."# ) , " b " ) )
546546
547- // These follow the PCRE behavior.
547+ // This follows the PCRE behavior.
548548 parseTest ( #"\Q\\E"# , quote ( " \\ " ) )
549- parseTest ( #"\E"# , " E " )
550549
551550 parseTest ( #"a" ."b"# , concat ( " a " , quote ( " . " ) , " b " ) ,
552551 syntax: . experimental)
@@ -566,6 +565,16 @@ extension RegexTests {
566565
567566 parseTest ( #"["-"]"# , charClass ( range_m ( " \" " , " \" " ) ) )
568567
568+ // MARK: Escapes
569+
570+ // Not metachars, but we allow their escape as ASCII.
571+ parseTest ( #"\<"# , " < " )
572+ parseTest ( #"\ "# , " " )
573+ parseTest ( #"\\"# , " \\ " )
574+
575+ // Escaped U+3000 IDEOGRAPHIC SPACE.
576+ parseTest ( #"\\#u{3000}"# , " \u{3000} " )
577+
569578 // MARK: Comments
570579
571580 parseTest (
@@ -989,13 +998,6 @@ extension RegexTests {
989998 // Backreferences are not valid in custom character classes.
990999 parseTest ( #"[\8]"# , charClass ( " 8 " ) )
9911000 parseTest ( #"[\9]"# , charClass ( " 9 " ) )
992- parseTest ( #"[\g]"# , charClass ( " g " ) )
993- parseTest ( #"[\g+30]"# , charClass ( " g " , " + " , " 3 " , " 0 " ) )
994- parseTest ( #"[\g{1}]"# , charClass ( " g " , " { " , " 1 " , " } " ) )
995- parseTest ( #"[\k'a']"# , charClass ( " k " , " ' " , " a " , " ' " ) )
996-
997- parseTest ( #"\g"# , atom ( . char( " g " ) ) )
998- parseTest ( #"\k"# , atom ( . char( " k " ) ) )
9991001
10001002 // MARK: Character names.
10011003
@@ -1526,7 +1528,7 @@ extension RegexTests {
15261528 parseWithDelimitersTest ( " re'x*' " , zeroOrMore ( of: " x " ) )
15271529
15281530 parseWithDelimitersTest ( #"re'🔥🇩🇰'"# , concat ( " 🔥 " , " 🇩🇰 " ) )
1529- parseWithDelimitersTest ( #"re'\ 🔥✅'"# , concat ( " 🔥 " , " ✅ " ) )
1531+ parseWithDelimitersTest ( #"re'🔥✅'"# , concat ( " 🔥 " , " ✅ " ) )
15301532
15311533 // Printable ASCII characters.
15321534 delimiterLexingTest ( ##"re' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~'"## )
@@ -1875,6 +1877,26 @@ extension RegexTests {
18751877
18761878 diagnosticTest ( " \\ " , . expectedEscape)
18771879
1880+ // TODO: Custom diagnostic for expected backref
1881+ diagnosticTest ( #"\g"# , . invalidEscape( " g " ) )
1882+ diagnosticTest ( #"\k"# , . invalidEscape( " k " ) )
1883+
1884+ // TODO: Custom diagnostic for backref in custom char class
1885+ diagnosticTest ( #"[\g]"# , . invalidEscape( " g " ) )
1886+ diagnosticTest ( #"[\g+30]"# , . invalidEscape( " g " ) )
1887+ diagnosticTest ( #"[\g{1}]"# , . invalidEscape( " g " ) )
1888+ diagnosticTest ( #"[\k'a']"# , . invalidEscape( " k " ) )
1889+
1890+ // TODO: Custom diagnostic for missing '\Q'
1891+ diagnosticTest ( #"\E"# , . invalidEscape( " E " ) )
1892+
1893+ // Non-ASCII non-whitespace cases.
1894+ diagnosticTest ( #"\🔥"# , . invalidEscape( " 🔥 " ) )
1895+ diagnosticTest ( #"\🇩🇰"# , . invalidEscape( " 🇩🇰 " ) )
1896+ diagnosticTest ( #"\e\#u{301}"# , . invalidEscape( " e \u{301} " ) )
1897+ diagnosticTest ( #"\\#u{E9}"# , . invalidEscape( " é " ) )
1898+ diagnosticTest ( #"\˂"# , . invalidEscape( " ˂ " ) )
1899+
18781900 // MARK: Text Segment options
18791901
18801902 diagnosticTest ( " (?-y{g}) " , . cannotRemoveTextSegmentOptions)
0 commit comments