diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2019-05-15 22:44:00 +0200 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2019-05-20 17:56:40 +0200 |
commit | afdc20d73c8588e5a744ecf7bffaf4401a557d20 (patch) | |
tree | fa09854d24edb81160a2d709bd450ea7284d83f1 /test/lisp/emacs-lisp | |
parent | c2cda3ff4025e8c27bdfc2a5279f3b635c8df260 (diff) | |
download | emacs-afdc20d73c8588e5a744ecf7bffaf4401a557d20.tar.gz emacs-afdc20d73c8588e5a744ecf7bffaf4401a557d20.tar.bz2 emacs-afdc20d73c8588e5a744ecf7bffaf4401a557d20.zip |
Allow zero-argument rx `or' and `seq' forms
Make the rx `or' and `seq' forms accept zero arguments to produce a
never-matching regexp and an empty string, respectively.
* lisp/emacs-lisp/rx.el: Require cl-extra.
(rx-constituents, rx-or): Permit zero args.
(rx): Amend doc string for `or' and `seq'.
* test/lisp/emacs-lisp/rx-tests.el (rx-or, rx-seq): Test the change.
* etc/NEWS (Changes in Specialized Modes and Packages): Mention the change.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 4a5919edf02..6f392d616d1 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el @@ -107,7 +107,13 @@ "ab")) (should (equal (and (string-match (rx (or "a" "ab" "abc")) s) (match-string 0 s)) - "a")))) + "a"))) + ;; Test zero-argument `or'. + (should (equal (rx (or)) regexp-unmatchable))) + +(ert-deftest rx-seq () + ;; Test zero-argument `seq'. + (should (equal (rx (seq)) ""))) (provide 'rx-tests) ;; rx-tests.el ends here. |