| 1 | # These tests are specifically written to test the regex-lite crate. While it |
| 2 | # largely has the same semantics as the regex crate, there are some differences |
| 3 | # around Unicode support and UTF-8. |
| 4 | # |
| 5 | # To be clear, regex-lite supports far fewer patterns because of its lack of |
| 6 | # Unicode support, nested character classes and character class set operations. |
| 7 | # What we're talking about here are the patterns that both crates support but |
| 8 | # where the semantics might differ. |
| 9 | |
| 10 | # regex-lite uses ASCII definitions for Perl character classes. |
| 11 | [[test]] |
| 12 | name = "perl-class-decimal" |
| 13 | regex = '\d' |
| 14 | haystack = '᠕' |
| 15 | matches = [] |
| 16 | unicode = true |
| 17 | |
| 18 | # regex-lite uses ASCII definitions for Perl character classes. |
| 19 | [[test]] |
| 20 | name = "perl-class-space" |
| 21 | regex = '\s' |
| 22 | haystack = "\u2000" |
| 23 | matches = [] |
| 24 | unicode = true |
| 25 | |
| 26 | # regex-lite uses ASCII definitions for Perl character classes. |
| 27 | [[test]] |
| 28 | name = "perl-class-word" |
| 29 | regex = '\w' |
| 30 | haystack = 'δ' |
| 31 | matches = [] |
| 32 | unicode = true |
| 33 | |
| 34 | # regex-lite uses the ASCII definition of word for word boundary assertions. |
| 35 | [[test]] |
| 36 | name = "word-boundary" |
| 37 | regex = '\b' |
| 38 | haystack = 'δ' |
| 39 | matches = [] |
| 40 | unicode = true |
| 41 | |
| 42 | # regex-lite uses the ASCII definition of word for negated word boundary |
| 43 | # assertions. But note that it should still not split codepoints! |
| 44 | [[test]] |
| 45 | name = "word-boundary-negated" |
| 46 | regex = '\B' |
| 47 | haystack = 'δ' |
| 48 | matches = [[0, 0], [2, 2]] |
| 49 | unicode = true |
| 50 | |
| 51 | # While we're here, the empty regex---which matches at every |
| 52 | # position---shouldn't split a codepoint either. |
| 53 | [[test]] |
| 54 | name = "empty-no-split-codepoint" |
| 55 | regex = '' |
| 56 | haystack = '💩' |
| 57 | matches = [[0, 0], [4, 4]] |
| 58 | unicode = true |
| 59 | |
| 60 | # A dot always matches a full codepoint. |
| 61 | [[test]] |
| 62 | name = "dot-always-matches-codepoint" |
| 63 | regex = '.' |
| 64 | haystack = '💩' |
| 65 | matches = [[0, 4]] |
| 66 | unicode = false |
| 67 | |
| 68 | # A negated character class also always matches a full codepoint. |
| 69 | [[test]] |
| 70 | name = "negated-class-always-matches-codepoint" |
| 71 | regex = '[^a]' |
| 72 | haystack = '💩' |
| 73 | matches = [[0, 4]] |
| 74 | unicode = false |
| 75 | |
| 76 | # regex-lite only supports ASCII-aware case insensitive matching. |
| 77 | [[test]] |
| 78 | name = "case-insensitive-is-ascii-only" |
| 79 | regex = 's' |
| 80 | haystack = 'ſ' |
| 81 | matches = [] |
| 82 | unicode = true |
| 83 | case-insensitive = true |
| 84 | |
| 85 | # Negated word boundaries shouldn't split a codepoint, but they will match |
| 86 | # between invalid UTF-8. |
| 87 | # |
| 88 | # This test is only valid for a 'bytes' API, but that doesn't (yet) exist in |
| 89 | # regex-lite. This can't happen in the main API because &str can't contain |
| 90 | # invalid UTF-8. |
| 91 | # [[test]] |
| 92 | # name = "word-boundary-invalid-utf8" |
| 93 | # regex = '\B' |
| 94 | # haystack = '\xFF\xFF\xFF\xFF' |
| 95 | # unescape = true |
| 96 | # matches = [[0, 0], [1, 1], [2, 2], [3, 3], [4, 4]] |
| 97 | # unicode = true |
| 98 | # utf8 = false |