summaryrefslogtreecommitdiff
path: root/test/lisp/emacs-lisp
diff options
context:
space:
mode:
authorMattias EngdegÄrd <mattiase@acm.org>2019-06-29 11:10:36 +0200
committerMattias EngdegÄrd <mattiase@acm.org>2019-06-29 11:12:27 +0200
commitf1d414b98f2df3d31abfa710ecbbc0223f73aed1 (patch)
tree5a7ce1d19a0d32a6af2825501766e88d63bc9914 /test/lisp/emacs-lisp
parent1dfb2f361595076d1a3e61a46b80470caf259b41 (diff)
downloademacs-f1d414b98f2df3d31abfa710ecbbc0223f73aed1.tar.gz
emacs-f1d414b98f2df3d31abfa710ecbbc0223f73aed1.tar.bz2
emacs-f1d414b98f2df3d31abfa710ecbbc0223f73aed1.zip
Allow empty argument to `regexp-opt-charset'
* test/lisp/emacs-lisp/regexp-opt-tests.el (regexp-opt-charset): Handle nil argument, and use regexp-quote for singletons. * lisp/emacs-lisp/regexp-opt.el (regexp-opt-charset): Expand tests.
Diffstat (limited to 'test/lisp/emacs-lisp')
-rw-r--r--test/lisp/emacs-lisp/regexp-opt-tests.el29
1 files changed, 24 insertions, 5 deletions
diff --git a/test/lisp/emacs-lisp/regexp-opt-tests.el b/test/lisp/emacs-lisp/regexp-opt-tests.el
index 1fc49909d3e..927de8c6a5f 100644
--- a/test/lisp/emacs-lisp/regexp-opt-tests.el
+++ b/test/lisp/emacs-lisp/regexp-opt-tests.el
@@ -1,4 +1,4 @@
-;;; regexp-tests.el --- Test suite for regular expression handling.
+;;; regexp-opt-tests.el --- Tests for regexp-opt.el
;; Copyright (C) 2013-2019 Free Software Foundation, Inc.
@@ -25,9 +25,28 @@
(require 'regexp-opt)
-(ert-deftest regexp-test-regexp-opt ()
- "Test the `compilation-error-regexp-alist' regexps.
-The test data is in `compile-tests--test-regexps-data'."
- (should (string-match (regexp-opt-charset '(?^)) "a^b")))
+(ert-deftest regexp-opt-charset ()
+ (should (equal (regexp-opt-charset '(?a ?b ?a)) "[ab]"))
+ (should (equal (regexp-opt-charset '(?D ?d ?B ?a ?b ?C ?7 ?a ?c ?A))
+ "[7A-Da-d]"))
+ (should (equal (regexp-opt-charset '(?a)) "a"))
+
+ (should (equal (regexp-opt-charset '(?^)) "\\^"))
+ (should (equal (regexp-opt-charset '(?-)) "-"))
+ (should (equal (regexp-opt-charset '(?\])) "]"))
+ (should (equal (regexp-opt-charset '(?^ ?\])) "[]^]"))
+ (should (equal (regexp-opt-charset '(?^ ?-)) "[-^]"))
+ (should (equal (regexp-opt-charset '(?- ?\])) "[]-]"))
+ (should (equal (regexp-opt-charset '(?- ?\] ?^)) "[]^-]"))
+
+ (should (equal (regexp-opt-charset '(?^ ?a)) "[a^]"))
+ (should (equal (regexp-opt-charset '(?- ?a)) "[a-]"))
+ (should (equal (regexp-opt-charset '(?\] ?a)) "[]a]"))
+ (should (equal (regexp-opt-charset '(?^ ?\] ?a)) "[]a^]"))
+ (should (equal (regexp-opt-charset '(?^ ?- ?a)) "[a^-]"))
+ (should (equal (regexp-opt-charset '(?- ?\] ?a)) "[]a-]"))
+ (should (equal (regexp-opt-charset '(?- ?\] ?^ ?a)) "[]a^-]"))
+
+ (should (equal (regexp-opt-charset '()) regexp-unmatchable)))
;;; regexp-tests.el ends here.