diff options
| author | Mattias EngdegÄrd | 2019-12-13 13:10:58 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-12-13 13:30:14 +0100 |
| commit | 82b4e48c590cf2c0448a751e641b0ee7a6a02438 (patch) | |
| tree | 55da830604ce9ebe4a5aa626bec285fb688578a3 /test | |
| parent | b04086adf649b18cf5309dd43aa638fc7b3cd4a0 (diff) | |
| download | emacs-82b4e48c590cf2c0448a751e641b0ee7a6a02438.tar.gz emacs-82b4e48c590cf2c0448a751e641b0ee7a6a02438.zip | |
Allow characters and single-char strings in rx charsets
The `not' and `intersection' forms, and `or' inside these forms,
now accept characters and single-character strings as arguments.
Previously, they had to be wrapped in `any' forms.
This does not add expressive power but is a convenience and is easily
understood.
* doc/lispref/searching.texi (Rx Constructs): Amend the documentation.
* etc/NEWS: Announce the change.
* lisp/emacs-lisp/rx.el (rx--charset-p, rx--translate-not)
(rx--charset-intervals, rx): Accept characters and 1-char strings in
more places.
* test/lisp/emacs-lisp/rx-tests.el (rx-not, rx-charset-or)
(rx-def-in-charset-or, rx-intersection): Test the change.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/rx-tests.el | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/test/lisp/emacs-lisp/rx-tests.el b/test/lisp/emacs-lisp/rx-tests.el index 344f46764c8..a82f1f83645 100644 --- a/test/lisp/emacs-lisp/rx-tests.el +++ b/test/lisp/emacs-lisp/rx-tests.el | |||
| @@ -272,7 +272,9 @@ | |||
| 272 | (should (equal (rx (not (category tone-mark)) (not (category lao))) | 272 | (should (equal (rx (not (category tone-mark)) (not (category lao))) |
| 273 | "\\C4\\Co")) | 273 | "\\C4\\Co")) |
| 274 | (should (equal (rx (not (not ascii)) (not (not (not (any "a-z"))))) | 274 | (should (equal (rx (not (not ascii)) (not (not (not (any "a-z"))))) |
| 275 | "[[:ascii:]][^a-z]"))) | 275 | "[[:ascii:]][^a-z]")) |
| 276 | (should (equal (rx (not ?a) (not "b") (not (not "c")) (not (not ?d))) | ||
| 277 | "[^a][^b]cd"))) | ||
| 276 | 278 | ||
| 277 | (ert-deftest rx-charset-or () | 279 | (ert-deftest rx-charset-or () |
| 278 | (should (equal (rx (or)) | 280 | (should (equal (rx (or)) |
| @@ -294,13 +296,17 @@ | |||
| 294 | "[a-ru-z]")) | 296 | "[a-ru-z]")) |
| 295 | (should (equal (rx (or (intersection (any "c-z") (any "a-g")) | 297 | (should (equal (rx (or (intersection (any "c-z") (any "a-g")) |
| 296 | (not (any "a-k")))) | 298 | (not (any "a-k")))) |
| 297 | "[^abh-k]"))) | 299 | "[^abh-k]")) |
| 300 | (should (equal (rx (or ?f (any "b-e") "a") (not (or ?x "y" (any "s-w")))) | ||
| 301 | "[a-f][^s-y]"))) | ||
| 298 | 302 | ||
| 299 | (ert-deftest rx-def-in-charset-or () | 303 | (ert-deftest rx-def-in-charset-or () |
| 300 | (rx-let ((a (any "badc")) | 304 | (rx-let ((a (any "badc")) |
| 301 | (b (| a (any "def")))) | 305 | (b (| a (any "def"))) |
| 302 | (should (equal (rx (or b (any "q"))) | 306 | (c ?a) |
| 303 | "[a-fq]"))) | 307 | (d "b")) |
| 308 | (should (equal (rx (or b (any "q")) (or c d)) | ||
| 309 | "[a-fq][ab]"))) | ||
| 304 | (rx-let ((diff-| (a b) (not (or (not a) b)))) | 310 | (rx-let ((diff-| (a b) (not (or (not a) b)))) |
| 305 | (should (equal (rx (diff-| (any "a-z") (any "gr"))) | 311 | (should (equal (rx (diff-| (any "a-z") (any "gr"))) |
| 306 | "[a-fh-qs-z]")))) | 312 | "[a-fh-qs-z]")))) |
| @@ -326,7 +332,9 @@ | |||
| 326 | "[e-m]")) | 332 | "[e-m]")) |
| 327 | (should (equal (rx (intersection (or (any "a-f") (any "f-t")) | 333 | (should (equal (rx (intersection (or (any "a-f") (any "f-t")) |
| 328 | (any "e-w"))) | 334 | (any "e-w"))) |
| 329 | "[e-t]"))) | 335 | "[e-t]")) |
| 336 | (should (equal (rx (intersection ?m (any "a-z") "m")) | ||
| 337 | "m"))) | ||
| 330 | 338 | ||
| 331 | (ert-deftest rx-def-in-intersection () | 339 | (ert-deftest rx-def-in-intersection () |
| 332 | (rx-let ((a (any "a-g")) | 340 | (rx-let ((a (any "a-g")) |