diff options
| author | Mattias EngdegÄrd | 2019-03-12 14:39:47 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-03-19 20:30:15 +0100 |
| commit | 3ed1621d843e057ad879fbed3605d32f55a065b9 (patch) | |
| tree | e4bd97bb649e9b6c05a0601eba5ef754f0d3310c /test | |
| parent | c0936672876bccc15e7899e83d8ab99910f8feee (diff) | |
| download | emacs-3ed1621d843e057ad879fbed3605d32f55a065b9.tar.gz emacs-3ed1621d843e057ad879fbed3605d32f55a065b9.zip | |
Disallow reversed char ranges in `rx'
(any "a-Z0-9") generated "[0-9]", and (any (?9 . ?0)) generated "[9-0]".
Reversed ranges are either mistakes or abuse. Neither should be allowed.
etc/NEWS: Explain the change.
lisp/emacs-lisp/rx.el (rx): Document.
(rx-check-any-string, rx-check-any): Add error checks for reversed ranges.
test/lisp/emacs-lisp/rx-tests.el (rx-char-any-range-bad): New test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 7dd5e3b8de9..4a5919edf02 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el | |||
| @@ -40,6 +40,10 @@ | |||
| 40 | (should (equal (rx (any "\a-\n")) | 40 | (should (equal (rx (any "\a-\n")) |
| 41 | "[\a-\n]"))) | 41 | "[\a-\n]"))) |
| 42 | 42 | ||
| 43 | (ert-deftest rx-char-any-range-bad () | ||
| 44 | (should-error (rx (any "0-9a-Z"))) | ||
| 45 | (should-error (rx (any (?0 . ?9) (?a . ?Z))))) | ||
| 46 | |||
| 43 | (ert-deftest rx-char-any-raw-byte () | 47 | (ert-deftest rx-char-any-raw-byte () |
| 44 | "Test raw bytes in character alternatives." | 48 | "Test raw bytes in character alternatives." |
| 45 | ;; Separate raw characters. | 49 | ;; Separate raw characters. |