-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Switch bytes::Regex to using Unicode mode by default.
- Loading branch information
1 parent
e2f0850
commit d44a9f9
Showing
13 changed files
with
77 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
mat!(uni_literal, u!(r"☃"), "☃", Some((0, 3))); | ||
mat!(uni_literal_plus, u!(r"☃+"), "☃", Some((0, 3))); | ||
mat!(uni_literal_casei_plus, u!(r"(?i)☃+"), "☃", Some((0, 3))); | ||
mat!(uni_class_plus, u!(r"[☃Ⅰ]+"), "☃", Some((0, 3))); | ||
mat!(uni_one, u!(r"\pN"), "Ⅰ", Some((0, 3))); | ||
mat!(uni_mixed, u!(r"\pN+"), "Ⅰ1Ⅱ2", Some((0, 8))); | ||
mat!(uni_not, u!(r"\PN+"), "abⅠ", Some((0, 2))); | ||
mat!(uni_not_class, u!(r"[\PN]+"), "abⅠ", Some((0, 2))); | ||
mat!(uni_not_class_neg, u!(r"[^\PN]+"), "abⅠ", Some((2, 5))); | ||
mat!(uni_case, u!(r"(?i)Δ"), "δ", Some((0, 2))); | ||
mat!(uni_case_upper, u!(r"\p{Lu}+"), "ΛΘΓΔα", Some((0, 8))); | ||
mat!(uni_case_upper_nocase_flag, u!(r"(?i)\p{Lu}+"), "ΛΘΓΔα", Some((0, 10))); | ||
mat!(uni_case_upper_nocase, u!(r"\p{L}+"), "ΛΘΓΔα", Some((0, 10))); | ||
mat!(uni_case_lower, u!(r"\p{Ll}+"), "ΛΘΓΔα", Some((8, 10))); | ||
mat!(uni_literal, r"☃", "☃", Some((0, 3))); | ||
mat!(uni_literal_plus, r"☃+", "☃", Some((0, 3))); | ||
mat!(uni_literal_casei_plus, r"(?i)☃+", "☃", Some((0, 3))); | ||
mat!(uni_class_plus, r"[☃Ⅰ]+", "☃", Some((0, 3))); | ||
mat!(uni_one, r"\pN", "Ⅰ", Some((0, 3))); | ||
mat!(uni_mixed, r"\pN+", "Ⅰ1Ⅱ2", Some((0, 8))); | ||
mat!(uni_not, r"\PN+", "abⅠ", Some((0, 2))); | ||
mat!(uni_not_class, r"[\PN]+", "abⅠ", Some((0, 2))); | ||
mat!(uni_not_class_neg, r"[^\PN]+", "abⅠ", Some((2, 5))); | ||
mat!(uni_case, r"(?i)Δ", "δ", Some((0, 2))); | ||
mat!(uni_case_upper, r"\p{Lu}+", "ΛΘΓΔα", Some((0, 8))); | ||
mat!(uni_case_upper_nocase_flag, r"(?i)\p{Lu}+", "ΛΘΓΔα", Some((0, 10))); | ||
mat!(uni_case_upper_nocase, r"\p{L}+", "ΛΘΓΔα", Some((0, 10))); | ||
mat!(uni_case_lower, r"\p{Ll}+", "ΛΘΓΔα", Some((8, 10))); | ||
|
||
// Test the Unicode friendliness of Perl character classes. | ||
mat!(uni_perl_w, u!(r"\w+"), "dδd", Some((0, 4))); | ||
mat!(uni_perl_w_not, u!(r"\w+"), "⥡", None); | ||
mat!(uni_perl_w_neg, u!(r"\W+"), "⥡", Some((0, 3))); | ||
mat!(uni_perl_d, u!(r"\d+"), "1२३9", Some((0, 8))); | ||
mat!(uni_perl_d_not, u!(r"\d+"), "Ⅱ", None); | ||
mat!(uni_perl_d_neg, u!(r"\D+"), "Ⅱ", Some((0, 3))); | ||
mat!(uni_perl_s, u!(r"\s+"), " ", Some((0, 3))); | ||
mat!(uni_perl_s_not, u!(r"\s+"), "☃", None); | ||
mat!(uni_perl_s_neg, u!(r"\S+"), "☃", Some((0, 3))); | ||
mat!(uni_perl_w, r"\w+", "dδd", Some((0, 4))); | ||
mat!(uni_perl_w_not, r"\w+", "⥡", None); | ||
mat!(uni_perl_w_neg, r"\W+", "⥡", Some((0, 3))); | ||
mat!(uni_perl_d, r"\d+", "1२३9", Some((0, 8))); | ||
mat!(uni_perl_d_not, r"\d+", "Ⅱ", None); | ||
mat!(uni_perl_d_neg, r"\D+", "Ⅱ", Some((0, 3))); | ||
mat!(uni_perl_s, r"\s+", " ", Some((0, 3))); | ||
mat!(uni_perl_s_not, r"\s+", "☃", None); | ||
mat!(uni_perl_s_neg, r"\S+", "☃", Some((0, 3))); | ||
|
||
// And do the same for word boundaries. | ||
mat!(uni_boundary_none, u!(r"\d\b"), "6δ", None); | ||
mat!(uni_boundary_ogham, u!(r"\d\b"), "6 ", Some((0, 1))); | ||
mat!(uni_not_boundary_none, u!(r"\d\B"), "6δ", Some((0, 1))); | ||
mat!(uni_not_boundary_ogham, u!(r"\d\B"), "6 ", None); | ||
mat!(uni_boundary_none, r"\d\b", "6δ", None); | ||
mat!(uni_boundary_ogham, r"\d\b", "6 ", Some((0, 1))); | ||
mat!(uni_not_boundary_none, r"\d\B", "6δ", Some((0, 1))); | ||
mat!(uni_not_boundary_ogham, r"\d\B", "6 ", None); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
// ASCII word boundaries are completely oblivious to Unicode characters. | ||
// For Unicode word boundaries, the tests are precisely inverted. | ||
matiter!(ascii1, r"\bx\b", "áxβ", (2, 3)); | ||
matiter!(ascii2, r"\Bx\B", "áxβ"); | ||
matiter!(ascii3, r"\B", "0\u{7EF5E}", (2, 2), (3, 3), (4, 4), (5, 5)); | ||
matiter!(ascii1, r"(?-u:\b)x(?-u:\b)", "áxβ", (2, 3)); | ||
matiter!(ascii2, r"(?-u:\B)x(?-u:\B)", "áxβ"); | ||
matiter!(ascii3, r"(?-u:\B)", "0\u{7EF5E}", (2, 2), (3, 3), (4, 4), (5, 5)); | ||
|
||
// We can still get Unicode mode in byte regexes. | ||
matiter!(unicode1, r"(?u:\b)x(?u:\b)", "áxβ"); | ||
matiter!(unicode2, r"(?u:\B)x(?u:\B)", "áxβ", (2, 3)); | ||
// We still get Unicode word boundaries by default in byte regexes. | ||
matiter!(unicode1, r"\bx\b", "áxβ"); | ||
matiter!(unicode2, r"\Bx\B", "áxβ", (2, 3)); |