summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp/rx-tests.el
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2019-03-12 14:39:47 +0100
committerMattias EngdegÄrd <mattiase@acm.org>2019-03-19 20:30:15 +0100
commit3ed1621d843e057ad879fbed3605d32f55a065b9 (patch)
treee4bd97bb649e9b6c05a0601eba5ef754f0d3310c /test/lisp/emacs-lisp/rx-tests.el
parentc0936672876bccc15e7899e83d8ab99910f8feee (diff)
downloademacs-3ed1621d843e057ad879fbed3605d32f55a065b9.tar.gz
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/lisp/emacs-lisp/rx-tests.el')
-rw-r--r--test/lisp/emacs-lisp/rx-tests.el4
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 @@
(should (equal (rx (any "\a-\n"))
"[\a-\n]")))
+(ert-deftest rx-char-any-range-bad ()
+ (should-error (rx (any "0-9a-Z")))
+ (should-error (rx (any (?0 . ?9) (?a . ?Z)))))
+
(ert-deftest rx-char-any-raw-byte ()
"Test raw bytes in character alternatives."
;; Separate raw characters.