diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2019-12-12 23:04:00 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2019-12-12 23:47:25 +0100 |
commit | f16766a0eb2a78b58a4856d31306fc37f913d70e (patch) | |
tree | d3be560c8aaf4f4d3a59b285e27aab224922bb33 /test/lisp/emacs-lisp/rx-tests.el | |
parent | d7efe98951730842db4fc136e3b631c5ee0d8a53 (diff) | |
download | emacs-f16766a0eb2a78b58a4856d31306fc37f913d70e.tar.gz emacs-f16766a0eb2a78b58a4856d31306fc37f913d70e.tar.bz2 emacs-f16766a0eb2a78b58a4856d31306fc37f913d70e.zip |
Use `or' instead of `union' for charset union in rx
Design change suggested by Stefan Monnier.
* doc/lispref/searching.texi (Rx Constructs):
* etc/NEWS: Document.
* lisp/emacs-lisp/rx.el (rx--translate-or): Detect charset arguments.
(rx--charset-p): New.
(rx--translate-not, rx--charset-intervals, rx--translate-union):
Change from `union' to `or'.
(rx--translate-form, rx--builtin-forms, rx): Remove `union'.
* test/lisp/emacs-lisp/rx-tests.el (rx-union, rx-def-in-union)
(rx-intersection): Rename tests and change `union' to `or' and `|'.
Diffstat (limited to 'test/lisp/emacs-lisp/rx-tests.el')
-rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 0cd2c9590b7..344f46764c8 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el @@ -274,33 +274,36 @@ (should (equal (rx (not (not ascii)) (not (not (not (any "a-z"))))) "[[:ascii:]][^a-z]"))) -(ert-deftest rx-union () - (should (equal (rx (union)) +(ert-deftest rx-charset-or () + (should (equal (rx (or)) "\\`a\\`")) - (should (equal (rx (union (any "ba"))) + (should (equal (rx (or (any "ba"))) "[ab]")) - (should (equal (rx (union (any "a-f") (any "c-k" ?y) (any ?r "x-z"))) + (should (equal (rx (| (any "a-f") (any "c-k" ?y) (any ?r "x-z"))) "[a-krx-z]")) - (should (equal (rx (union (not (any "a-m")) (not (any "f-p")))) + (should (equal (rx (or (not (any "a-m")) (not (any "f-p")))) "[^f-m]")) - (should (equal (rx (union (any "e-m") (not (any "a-z")))) + (should (equal (rx (| (any "e-m") (not (any "a-z")))) "[^a-dn-z]")) - (should (equal (rx (union (not (any "g-r")) (not (any "t")))) + (should (equal (rx (or (not (any "g-r")) (not (any "t")))) "[^z-a]")) - (should (equal (rx (not (union (not (any "g-r")) (not (any "t"))))) + (should (equal (rx (not (or (not (any "g-r")) (not (any "t"))))) "\\`a\\`")) - (should (equal (rx (union (union (any "a-f") (any "u-z")) - (any "g-r"))) + (should (equal (rx (or (| (any "a-f") (any "u-z")) + (any "g-r"))) "[a-ru-z]")) - (should (equal (rx (union (intersection (any "c-z") (any "a-g")) - (not (any "a-k")))) + (should (equal (rx (or (intersection (any "c-z") (any "a-g")) + (not (any "a-k")))) "[^abh-k]"))) -(ert-deftest rx-def-in-union () +(ert-deftest rx-def-in-charset-or () (rx-let ((a (any "badc")) - (b (union a (any "def")))) - (should (equal(rx (union b (any "q"))) - "[a-fq]")))) + (b (| a (any "def")))) + (should (equal (rx (or b (any "q"))) + "[a-fq]"))) + (rx-let ((diff-| (a b) (not (or (not a) b)))) + (should (equal (rx (diff-| (any "a-z") (any "gr"))) + "[a-fh-qs-z]")))) (ert-deftest rx-intersection () (should (equal (rx (intersection)) @@ -321,15 +324,18 @@ (should (equal (rx (intersection (any "d-u") (intersection (any "e-z") (any "a-m")))) "[e-m]")) - (should (equal (rx (intersection (union (any "a-f") (any "f-t")) + (should (equal (rx (intersection (or (any "a-f") (any "f-t")) (any "e-w"))) "[e-t]"))) (ert-deftest rx-def-in-intersection () (rx-let ((a (any "a-g")) (b (intersection a (any "d-j")))) - (should (equal(rx (intersection b (any "e-k"))) - "[e-g]")))) + (should (equal (rx (intersection b (any "e-k"))) + "[e-g]"))) + (rx-let ((diff-& (a b) (intersection a (not b)))) + (should (equal (rx (diff-& (any "a-z") (any "m-p"))) + "[a-lq-z]")))) (ert-deftest rx-group () (should (equal (rx (group nonl) (submatch "x") |