diff options
| author | Andrea Corallo | 2020-02-21 15:25:01 +0000 |
|---|---|---|
| committer | Andrea Corallo | 2020-02-21 15:25:01 +0000 |
| commit | de17b43370fa8549531d34c27d3cbcfb24725c6d (patch) | |
| tree | 07d28ce99e4f2e1b10654001c5205e36f65c3e80 /test | |
| parent | 81c34a35aab53978bc2f3608dff3751030d0e914 (diff) | |
| parent | 3b4bd4be1dfa8717cb6911bd57c4c7d9d13614b4 (diff) | |
| download | emacs-de17b43370fa8549531d34c27d3cbcfb24725c6d.tar.gz emacs-de17b43370fa8549531d34c27d3cbcfb24725c6d.zip | |
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 11 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/regexp-opt-tests.el | 75 | ||||
| -rw-r--r-- | test/lisp/progmodes/compile-tests.el | 7 | ||||
| -rw-r--r-- | test/lisp/tempo-tests.el | 39 | ||||
| -rw-r--r-- | test/src/regex-emacs-tests.el | 2 |
5 files changed, 61 insertions, 73 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index a16adfedfb8..de11ae22d50 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -615,17 +615,6 @@ literals (Bug#20852)." | |||
| 615 | (let ((byte-compile-dest-file-function (lambda (_) destination))) | 615 | (let ((byte-compile-dest-file-function (lambda (_) destination))) |
| 616 | (should (byte-compile-file source))))))) | 616 | (should (byte-compile-file source))))))) |
| 617 | 617 | ||
| 618 | (ert-deftest bytecomp-tests--old-style-backquotes () | ||
| 619 | "Check that byte compiling warns about old-style backquotes." | ||
| 620 | (bytecomp-tests--with-temp-file source | ||
| 621 | (write-region "(` (a b))" nil source) | ||
| 622 | (bytecomp-tests--with-temp-file destination | ||
| 623 | (let* ((byte-compile-dest-file-function (lambda (_) destination)) | ||
| 624 | (byte-compile-debug t) | ||
| 625 | (err (should-error (byte-compile-file source)))) | ||
| 626 | (should (equal (cdr err) '("Old-style backquotes detected!"))))))) | ||
| 627 | |||
| 628 | |||
| 629 | (ert-deftest bytecomp-tests-function-put () | 618 | (ert-deftest bytecomp-tests-function-put () |
| 630 | "Check `function-put' operates during compilation." | 619 | "Check `function-put' operates during compilation." |
| 631 | (bytecomp-tests--with-temp-file source | 620 | (bytecomp-tests--with-temp-file source |
diff --git a/test/lisp/emacs-lisp/regexp-opt-tests.el b/test/lisp/emacs-lisp/regexp-opt-tests.el index 9b4567c72cc..2d316b5829f 100644 --- a/test/lisp/emacs-lisp/regexp-opt-tests.el +++ b/test/lisp/emacs-lisp/regexp-opt-tests.el | |||
| @@ -25,65 +25,22 @@ | |||
| 25 | 25 | ||
| 26 | (require 'regexp-opt) | 26 | (require 'regexp-opt) |
| 27 | 27 | ||
| 28 | (defun regexp-opt-test--permutation (n list) | 28 | (defun regexp-opt-test--permutations (l) |
| 29 | "The Nth permutation of LIST, 0 ≤ N < (length LIST)!." | 29 | "All permutations of L, assuming no duplicates." |
| 30 | (let ((len (length list)) | 30 | (if (cdr l) |
| 31 | (perm-list nil)) | 31 | (mapcan (lambda (x) |
| 32 | (dotimes (i len) | 32 | (mapcar (lambda (p) (cons x p)) |
| 33 | (let* ((d (- len i)) | 33 | (perm (remove x l)))) |
| 34 | (k (mod n d))) | 34 | l) |
| 35 | (push (nth k list) perm-list) | 35 | (list l))) |
| 36 | (setq list (append (butlast list (- (length list) k)) | 36 | |
| 37 | (nthcdr (1+ k) list))) | 37 | (ert-deftest regexp-opt-longest-match () |
| 38 | (setq n (/ n d)))) | 38 | "Check that the regexp always matches as much as possible." |
| 39 | (nreverse perm-list))) | 39 | (let ((s "abcd")) |
| 40 | 40 | (dolist (perm (regexp-opt-test--permutations '("a" "ab" "ac" "abc"))) | |
| 41 | (defun regexp-opt-test--factorial (n) | 41 | (should (equal (and (string-match (regexp-opt perm) s) |
| 42 | "N!" | 42 | (match-string 0 s)) |
| 43 | (apply #'* (number-sequence 1 n))) | 43 | "abc"))))) |
| 44 | |||
| 45 | (defun regexp-opt-test--permutations (list) | ||
| 46 | "All permutations of LIST." | ||
| 47 | (mapcar (lambda (i) (regexp-opt-test--permutation i list)) | ||
| 48 | (number-sequence 0 (1- (regexp-opt-test--factorial (length list)))))) | ||
| 49 | |||
| 50 | (defun regexp-opt-test--match-all (words re) | ||
| 51 | (mapcar (lambda (w) (and (string-match re w) | ||
| 52 | (match-string 0 w))) | ||
| 53 | words)) | ||
| 54 | |||
| 55 | (defun regexp-opt-test--check-perm (perm) | ||
| 56 | (let* ((ref-re (mapconcat #'regexp-quote perm "\\|")) | ||
| 57 | (opt-re (regexp-opt perm nil t)) | ||
| 58 | (ref (regexp-opt-test--match-all perm ref-re)) | ||
| 59 | (opt (regexp-opt-test--match-all perm opt-re))) | ||
| 60 | (equal opt ref))) | ||
| 61 | |||
| 62 | (defun regexp-opt-test--explain-perm (perm) | ||
| 63 | (let* ((ref-re (mapconcat #'regexp-quote perm "\\|")) | ||
| 64 | (opt-re (regexp-opt perm nil t)) | ||
| 65 | (ref (regexp-opt-test--match-all perm ref-re)) | ||
| 66 | (opt (regexp-opt-test--match-all perm opt-re))) | ||
| 67 | (concat "\n" | ||
| 68 | (format "Naïve regexp: %s\n" ref-re) | ||
| 69 | (format "Optimized regexp: %s\n" opt-re) | ||
| 70 | (format "Got: %s\n" opt) | ||
| 71 | (format "Expected: %s\n" ref)))) | ||
| 72 | |||
| 73 | (put 'regexp-opt-test--check-perm 'ert-explainer 'regexp-opt-test--explain-perm) | ||
| 74 | |||
| 75 | (ert-deftest regexp-opt-keep-order () | ||
| 76 | "Check that KEEP-ORDER works." | ||
| 77 | (dolist (perm (regexp-opt-test--permutations '("abc" "bca" "cab"))) | ||
| 78 | (should (regexp-opt-test--check-perm perm))) | ||
| 79 | (dolist (perm (regexp-opt-test--permutations '("abc" "ab" "bca" "bc"))) | ||
| 80 | (should (regexp-opt-test--check-perm perm))) | ||
| 81 | (dolist (perm (regexp-opt-test--permutations '("abxy" "cdxy"))) | ||
| 82 | (should (regexp-opt-test--check-perm perm))) | ||
| 83 | (dolist (perm (regexp-opt-test--permutations '("afgx" "bfgx" "afgy" "bfgy"))) | ||
| 84 | (should (regexp-opt-test--check-perm perm))) | ||
| 85 | (dolist (perm (regexp-opt-test--permutations '("a" "ab" "ac" "abc"))) | ||
| 86 | (should (regexp-opt-test--check-perm perm)))) | ||
| 87 | 44 | ||
| 88 | (ert-deftest regexp-opt-charset () | 45 | (ert-deftest regexp-opt-charset () |
| 89 | (should (equal (regexp-opt-charset '(?a ?b ?a)) "[ab]")) | 46 | (should (equal (regexp-opt-charset '(?a ?b ?a)) "[ab]")) |
diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el index 350b4eb400f..75962566f14 100644 --- a/test/lisp/progmodes/compile-tests.el +++ b/test/lisp/progmodes/compile-tests.el | |||
| @@ -242,7 +242,7 @@ | |||
| 242 | ;; maven | 242 | ;; maven |
| 243 | ("FooBar.java:[111,53] no interface expected here" | 243 | ("FooBar.java:[111,53] no interface expected here" |
| 244 | 1 53 111 "FooBar.java" 2) | 244 | 1 53 111 "FooBar.java" 2) |
| 245 | (" [ERROR] /Users/cinsk/hello.java:[651,96] ';' expected" | 245 | ("[ERROR] /Users/cinsk/hello.java:[651,96] ';' expected" |
| 246 | 15 96 651 "/Users/cinsk/hello.java" 2) ;Bug#11517. | 246 | 15 96 651 "/Users/cinsk/hello.java" 2) ;Bug#11517. |
| 247 | ("[WARNING] /foo/bar/Test.java:[27,43] unchecked conversion" | 247 | ("[WARNING] /foo/bar/Test.java:[27,43] unchecked conversion" |
| 248 | 11 43 27 "/foo/bar/Test.java" 1) ;Bug#20556 | 248 | 11 43 27 "/foo/bar/Test.java" 1) ;Bug#20556 |
| @@ -269,6 +269,9 @@ | |||
| 269 | 1 nil 109 "..\\src\\ctrl\\lister.c") | 269 | 1 nil 109 "..\\src\\ctrl\\lister.c") |
| 270 | ("..\\src\\ctrl\\lister.c(120): Warning! W201: Unreachable code" | 270 | ("..\\src\\ctrl\\lister.c(120): Warning! W201: Unreachable code" |
| 271 | 1 nil 120 "..\\src\\ctrl\\lister.c") | 271 | 1 nil 120 "..\\src\\ctrl\\lister.c") |
| 272 | ;; omake | ||
| 273 | (" alpha.c:5:15: error: expected ';' after expression" | ||
| 274 | 1 15 5 "alpha.c") | ||
| 272 | ;; oracle | 275 | ;; oracle |
| 273 | ("Semantic error at line 528, column 5, file erosacqdb.pc:" | 276 | ("Semantic error at line 528, column 5, file erosacqdb.pc:" |
| 274 | 1 5 528 "erosacqdb.pc") | 277 | 1 5 528 "erosacqdb.pc") |
| @@ -428,7 +431,7 @@ The test data is in `compile-tests--test-regexps-data'." | |||
| 428 | (compilation-num-warnings-found 0) | 431 | (compilation-num-warnings-found 0) |
| 429 | (compilation-num-infos-found 0)) | 432 | (compilation-num-infos-found 0)) |
| 430 | (mapc #'compile--test-error-line compile-tests--test-regexps-data) | 433 | (mapc #'compile--test-error-line compile-tests--test-regexps-data) |
| 431 | (should (eq compilation-num-errors-found 92)) | 434 | (should (eq compilation-num-errors-found 93)) |
| 432 | (should (eq compilation-num-warnings-found 36)) | 435 | (should (eq compilation-num-warnings-found 36)) |
| 433 | (should (eq compilation-num-infos-found 26))))) | 436 | (should (eq compilation-num-infos-found 26))))) |
| 434 | 437 | ||
diff --git a/test/lisp/tempo-tests.el b/test/lisp/tempo-tests.el index 0dd310b8531..bfe475910da 100644 --- a/test/lisp/tempo-tests.el +++ b/test/lisp/tempo-tests.el | |||
| @@ -216,6 +216,45 @@ | |||
| 216 | (tempo-complete-tag) | 216 | (tempo-complete-tag) |
| 217 | (should (equal (buffer-string) "Hello, World!")))) | 217 | (should (equal (buffer-string) "Hello, World!")))) |
| 218 | 218 | ||
| 219 | (ert-deftest tempo-define-tag-globally-test () | ||
| 220 | "Testing usage of a template tag defined from another buffer." | ||
| 221 | (tempo-define-template "test" '("Hello, World!") "hello") | ||
| 222 | |||
| 223 | (with-temp-buffer | ||
| 224 | ;; Use a tag in buffer 1 | ||
| 225 | (insert "hello") | ||
| 226 | (tempo-complete-tag) | ||
| 227 | (should (equal (buffer-string) "Hello, World!")) | ||
| 228 | (erase-buffer) | ||
| 229 | |||
| 230 | ;; Collection should not be dirty | ||
| 231 | (should-not tempo-dirty-collection) | ||
| 232 | |||
| 233 | ;; Define a tag on buffer 2 | ||
| 234 | (with-temp-buffer | ||
| 235 | (tempo-define-template "test2" '("Now expanded.") "mytag")) | ||
| 236 | |||
| 237 | ;; I should be able to use this template back in buffer 1 | ||
| 238 | (insert "mytag") | ||
| 239 | (tempo-complete-tag) | ||
| 240 | (should (equal (buffer-string) "Now expanded.")))) | ||
| 241 | |||
| 242 | (ert-deftest tempo-overwrite-tag-test () | ||
| 243 | "Testing ability to reassign templates to tags." | ||
| 244 | (with-temp-buffer | ||
| 245 | ;; Define a tag and use it | ||
| 246 | (tempo-define-template "test-tag-1" '("abc") "footag") | ||
| 247 | (insert "footag") | ||
| 248 | (tempo-complete-tag) | ||
| 249 | (should (equal (buffer-string) "abc")) | ||
| 250 | (erase-buffer) | ||
| 251 | |||
| 252 | ;; Define a new template with the same tag | ||
| 253 | (tempo-define-template "test-tag-2" '("xyz") "footag") | ||
| 254 | (insert "footag") | ||
| 255 | (tempo-complete-tag) | ||
| 256 | (should (equal (buffer-string) "xyz")))) | ||
| 257 | |||
| 219 | (ert-deftest tempo-expand-partial-tag-test () | 258 | (ert-deftest tempo-expand-partial-tag-test () |
| 220 | "Testing expansion of a template with a tag, with a partial match." | 259 | "Testing expansion of a template with a tag, with a partial match." |
| 221 | (with-temp-buffer | 260 | (with-temp-buffer |
diff --git a/test/src/regex-emacs-tests.el b/test/src/regex-emacs-tests.el index ad0271049c3..f9372e37b11 100644 --- a/test/src/regex-emacs-tests.el +++ b/test/src/regex-emacs-tests.el | |||
| @@ -505,7 +505,7 @@ differences in behavior.") | |||
| 505 | (cond | 505 | (cond |
| 506 | 506 | ||
| 507 | ;; pattern | 507 | ;; pattern |
| 508 | ((save-excursion (re-search-forward "^/\\(.*\\)/\\(.*i?\\)$" nil t)) | 508 | ((save-excursion (re-search-forward "^/\\(.*\\)/\\(.*\\)$" nil t)) |
| 509 | (setq icase (string= "i" (match-string 2)) | 509 | (setq icase (string= "i" (match-string 2)) |
| 510 | pattern (regex-tests-unextend (match-string 1)))) | 510 | pattern (regex-tests-unextend (match-string 1)))) |
| 511 | 511 | ||