diff options
| author | Mattias EngdegÄrd | 2023-07-30 15:30:38 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2023-07-30 17:53:14 +0200 |
| commit | 5f5d668ac7917d61e9366fe0c3efd7b542671c3d (patch) | |
| tree | de9bc3583caa56b2dd622350fd6d54ac9bd5cff6 /test | |
| parent | 060766cf2c67314539e3002078add7f3fe3c6f86 (diff) | |
| download | emacs-5f5d668ac7917d61e9366fe0c3efd7b542671c3d.tar.gz emacs-5f5d668ac7917d61e9366fe0c3efd7b542671c3d.zip | |
Fix rx wrong-code bug: ranges starting with ^
(rx (in (?^ . ?a))) was incorrectly translated to "[^-a]".
Change it so that we get "[_-a^]" instead.
* lisp/emacs-lisp/rx.el (rx--generate-alt): Split ranges starting with
`^` occurring first in a non-negated character alternative.
* test/lisp/emacs-lisp/rx-tests.el (rx-any): Add and adapt tests.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 995d297ff08..4928d5adf9d 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el | |||
| @@ -122,23 +122,33 @@ | |||
| 122 | (should (equal (rx (any "]" "^") (any "]" "-") (any "-" "^") | 122 | (should (equal (rx (any "]" "^") (any "]" "-") (any "-" "^") |
| 123 | (not (any "]" "^")) (not (any "]" "-")) | 123 | (not (any "]" "^")) (not (any "]" "-")) |
| 124 | (not (any "-" "^"))) | 124 | (not (any "-" "^"))) |
| 125 | "[]^][]-][-^][^]^][^]-][^-^]")) | 125 | "[]^][]-][-^][^]^][^]-][^^-]")) |
| 126 | (should (equal (rx (any "]" "^" "-") (not (any "]" "^" "-"))) | 126 | (should (equal (rx (any "]" "^" "-") (not (any "]" "^" "-"))) |
| 127 | "[]^-][^]^-]")) | 127 | "[]^-][^]^-]")) |
| 128 | (should (equal (rx (any "^-f") (any "^-f" "-") | ||
| 129 | (any "^-f" "z") (any "^-f" "z" "-")) | ||
| 130 | "[_-f^][_-f^-][_-f^z][_-f^z-]")) | ||
| 131 | (should (equal (rx (not (any "^-f")) (not (any "^-f" "-")) | ||
| 132 | (not (any "^-f" "z")) (not (any "^-f" "z" "-"))) | ||
| 133 | "[^^-f][^^-f-][^^-fz][^^-fz-]")) | ||
| 134 | (should (equal (rx (any "^-f" word) (any "^-f" "-" word)) | ||
| 135 | "[_-f^[:word:]][_-f^[:word:]-]")) | ||
| 136 | (should (equal (rx (not (any "^-f" word)) (not (any "^-f" "-" word))) | ||
| 137 | "[^^-f[:word:]][^^-f[:word:]-]")) | ||
| 128 | (should (equal (rx (any "-" ascii) (any "^" ascii) (any "]" ascii)) | 138 | (should (equal (rx (any "-" ascii) (any "^" ascii) (any "]" ascii)) |
| 129 | "[[:ascii:]-][[:ascii:]^][][:ascii:]]")) | 139 | "[[:ascii:]-][[:ascii:]^][][:ascii:]]")) |
| 130 | (should (equal (rx (not (any "-" ascii)) (not (any "^" ascii)) | 140 | (should (equal (rx (not (any "-" ascii)) (not (any "^" ascii)) |
| 131 | (not (any "]" ascii))) | 141 | (not (any "]" ascii))) |
| 132 | "[^[:ascii:]-][^[:ascii:]^][^][:ascii:]]")) | 142 | "[^[:ascii:]-][^^[:ascii:]][^][:ascii:]]")) |
| 133 | (should (equal (rx (any "-]" ascii) (any "^]" ascii) (any "-^" ascii)) | 143 | (should (equal (rx (any "-]" ascii) (any "^]" ascii) (any "-^" ascii)) |
| 134 | "[][:ascii:]-][]^[:ascii:]][[:ascii:]^-]")) | 144 | "[][:ascii:]-][]^[:ascii:]][[:ascii:]^-]")) |
| 135 | (should (equal (rx (not (any "-]" ascii)) (not (any "^]" ascii)) | 145 | (should (equal (rx (not (any "-]" ascii)) (not (any "^]" ascii)) |
| 136 | (not (any "-^" ascii))) | 146 | (not (any "-^" ascii))) |
| 137 | "[^][:ascii:]-][^]^[:ascii:]][^[:ascii:]^-]")) | 147 | "[^][:ascii:]-][^]^[:ascii:]][^^[:ascii:]-]")) |
| 138 | (should (equal (rx (any "-]^" ascii) (not (any "-]^" ascii))) | 148 | (should (equal (rx (any "-]^" ascii) (not (any "-]^" ascii))) |
| 139 | "[]^[:ascii:]-][^]^[:ascii:]-]")) | 149 | "[]^[:ascii:]-][^]^[:ascii:]-]")) |
| 140 | (should (equal (rx (any "^" lower upper) (not (any "^" lower upper))) | 150 | (should (equal (rx (any "^" lower upper) (not (any "^" lower upper))) |
| 141 | "[[:lower:]^[:upper:]][^[:lower:]^[:upper:]]")) | 151 | "[[:lower:]^[:upper:]][^^[:lower:][:upper:]]")) |
| 142 | (should (equal (rx (any "-" lower upper) (not (any "-" lower upper))) | 152 | (should (equal (rx (any "-" lower upper) (not (any "-" lower upper))) |
| 143 | "[[:lower:][:upper:]-][^[:lower:][:upper:]-]")) | 153 | "[[:lower:][:upper:]-][^[:lower:][:upper:]-]")) |
| 144 | (should (equal (rx (any "]" lower upper) (not (any "]" lower upper))) | 154 | (should (equal (rx (any "]" lower upper) (not (any "]" lower upper))) |
| @@ -153,7 +163,7 @@ | |||
| 153 | "[]-a-][^]-a-]")) | 163 | "[]-a-][^]-a-]")) |
| 154 | (should (equal (rx (any "--]") (not (any "--]")) | 164 | (should (equal (rx (any "--]") (not (any "--]")) |
| 155 | (any "-" "^-a") (not (any "-" "^-a"))) | 165 | (any "-" "^-a") (not (any "-" "^-a"))) |
| 156 | "[].-\\-][^].-\\-][-^-a][^-^-a]")) | 166 | "[].-\\-][^].-\\-][_-a^-][^^-a-]")) |
| 157 | (should (equal (rx (not (any "!a" "0-8" digit nonascii))) | 167 | (should (equal (rx (not (any "!a" "0-8" digit nonascii))) |
| 158 | "[^!0-8a[:digit:][:nonascii:]]")) | 168 | "[^!0-8a[:digit:][:nonascii:]]")) |
| 159 | (should (equal (rx (any) (not (any))) | 169 | (should (equal (rx (any) (not (any))) |