aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMattias EngdegÄrd2019-12-12 23:04:00 +0100
committerMattias EngdegÄrd2019-12-12 23:47:25 +0100
commitf16766a0eb2a78b58a4856d31306fc37f913d70e (patch)
treed3be560c8aaf4f4d3a59b285e27aab224922bb33 /test
parentd7efe98951730842db4fc136e3b631c5ee0d8a53 (diff)
downloademacs-f16766a0eb2a78b58a4856d31306fc37f913d70e.tar.gz
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')
-rw-r--r--test/lisp/emacs-lisp/rx-tests.el44
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 @@
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 276
277(ert-deftest rx-union () 277(ert-deftest rx-charset-or ()
278 (should (equal (rx (union)) 278 (should (equal (rx (or))
279 "\\`a\\`")) 279 "\\`a\\`"))
280 (should (equal (rx (union (any "ba"))) 280 (should (equal (rx (or (any "ba")))
281 "[ab]")) 281 "[ab]"))
282 (should (equal (rx (union (any "a-f") (any "c-k" ?y) (any ?r "x-z"))) 282 (should (equal (rx (| (any "a-f") (any "c-k" ?y) (any ?r "x-z")))
283 "[a-krx-z]")) 283 "[a-krx-z]"))
284 (should (equal (rx (union (not (any "a-m")) (not (any "f-p")))) 284 (should (equal (rx (or (not (any "a-m")) (not (any "f-p"))))
285 "[^f-m]")) 285 "[^f-m]"))
286 (should (equal (rx (union (any "e-m") (not (any "a-z")))) 286 (should (equal (rx (| (any "e-m") (not (any "a-z"))))
287 "[^a-dn-z]")) 287 "[^a-dn-z]"))
288 (should (equal (rx (union (not (any "g-r")) (not (any "t")))) 288 (should (equal (rx (or (not (any "g-r")) (not (any "t"))))
289 "[^z-a]")) 289 "[^z-a]"))
290 (should (equal (rx (not (union (not (any "g-r")) (not (any "t"))))) 290 (should (equal (rx (not (or (not (any "g-r")) (not (any "t")))))
291 "\\`a\\`")) 291 "\\`a\\`"))
292 (should (equal (rx (union (union (any "a-f") (any "u-z")) 292 (should (equal (rx (or (| (any "a-f") (any "u-z"))
293 (any "g-r"))) 293 (any "g-r")))
294 "[a-ru-z]")) 294 "[a-ru-z]"))
295 (should (equal (rx (union (intersection (any "c-z") (any "a-g")) 295 (should (equal (rx (or (intersection (any "c-z") (any "a-g"))
296 (not (any "a-k")))) 296 (not (any "a-k"))))
297 "[^abh-k]"))) 297 "[^abh-k]")))
298 298
299(ert-deftest rx-def-in-union () 299(ert-deftest rx-def-in-charset-or ()
300 (rx-let ((a (any "badc")) 300 (rx-let ((a (any "badc"))
301 (b (union a (any "def")))) 301 (b (| a (any "def"))))
302 (should (equal(rx (union b (any "q"))) 302 (should (equal (rx (or b (any "q")))
303 "[a-fq]")))) 303 "[a-fq]")))
304 (rx-let ((diff-| (a b) (not (or (not a) b))))
305 (should (equal (rx (diff-| (any "a-z") (any "gr")))
306 "[a-fh-qs-z]"))))
304 307
305(ert-deftest rx-intersection () 308(ert-deftest rx-intersection ()
306 (should (equal (rx (intersection)) 309 (should (equal (rx (intersection))
@@ -321,15 +324,18 @@
321 (should (equal (rx (intersection (any "d-u") 324 (should (equal (rx (intersection (any "d-u")
322 (intersection (any "e-z") (any "a-m")))) 325 (intersection (any "e-z") (any "a-m"))))
323 "[e-m]")) 326 "[e-m]"))
324 (should (equal (rx (intersection (union (any "a-f") (any "f-t")) 327 (should (equal (rx (intersection (or (any "a-f") (any "f-t"))
325 (any "e-w"))) 328 (any "e-w")))
326 "[e-t]"))) 329 "[e-t]")))
327 330
328(ert-deftest rx-def-in-intersection () 331(ert-deftest rx-def-in-intersection ()
329 (rx-let ((a (any "a-g")) 332 (rx-let ((a (any "a-g"))
330 (b (intersection a (any "d-j")))) 333 (b (intersection a (any "d-j"))))
331 (should (equal(rx (intersection b (any "e-k"))) 334 (should (equal (rx (intersection b (any "e-k")))
332 "[e-g]")))) 335 "[e-g]")))
336 (rx-let ((diff-& (a b) (intersection a (not b))))
337 (should (equal (rx (diff-& (any "a-z") (any "m-p")))
338 "[a-lq-z]"))))
333 339
334(ert-deftest rx-group () 340(ert-deftest rx-group ()
335 (should (equal (rx (group nonl) (submatch "x") 341 (should (equal (rx (group nonl) (submatch "x")