aboutsummaryrefslogtreecommitdiffstats
path: root/test/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'test/lisp')
-rw-r--r--test/lisp/cedet/srecode-utest-template.el5
-rw-r--r--test/lisp/emacs-lisp/bytecomp-tests.el43
-rw-r--r--test/lisp/emacs-lisp/cl-lib-tests.el16
-rw-r--r--test/lisp/ffap-tests.el40
-rw-r--r--test/lisp/mail/flow-fill-tests.el3
-rw-r--r--test/lisp/progmodes/compile-tests.el4
-rw-r--r--test/lisp/progmodes/cperl-mode-tests.el51
-rw-r--r--test/lisp/simple-tests.el7
-rw-r--r--test/lisp/textmodes/bibtex-tests.el57
-rw-r--r--test/lisp/textmodes/paragraphs-tests.el4
-rw-r--r--test/lisp/url/url-expand-tests.el7
11 files changed, 210 insertions, 27 deletions
diff --git a/test/lisp/cedet/srecode-utest-template.el b/test/lisp/cedet/srecode-utest-template.el
index 63c33a3c440..7c5bbc599a3 100644
--- a/test/lisp/cedet/srecode-utest-template.el
+++ b/test/lisp/cedet/srecode-utest-template.el
@@ -323,7 +323,6 @@ INSIDE SECTION: ARG HANDLER ONE")
323 323
324(ert-deftest srecode-utest-project () 324(ert-deftest srecode-utest-project ()
325 "Test that project filtering works." 325 "Test that project filtering works."
326 :expected-result (if (getenv "EMACS_HYDRA_CI") :failed :passed) ; fixme
327 (save-excursion 326 (save-excursion
328 (let ((testbuff (find-file-noselect srecode-utest-testfile)) 327 (let ((testbuff (find-file-noselect srecode-utest-testfile))
329 (temp nil)) 328 (temp nil))
@@ -347,6 +346,10 @@ INSIDE SECTION: ARG HANDLER ONE")
347 ;; Load the application templates, and make sure we can find them. 346 ;; Load the application templates, and make sure we can find them.
348 (srecode-load-tables-for-mode major-mode 'tests) 347 (srecode-load-tables-for-mode major-mode 'tests)
349 348
349 (dolist (table (oref (srecode-table) tables))
350 (when (gethash "test" (oref table contexthash))
351 (oset table project default-directory)))
352
350 (setq temp (srecode-template-get-table (srecode-table) 353 (setq temp (srecode-template-get-table (srecode-table)
351 "test-project" 354 "test-project"
352 "test" 355 "test"
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el
index 894914300ae..834e3b6d914 100644
--- a/test/lisp/emacs-lisp/bytecomp-tests.el
+++ b/test/lisp/emacs-lisp/bytecomp-tests.el
@@ -365,24 +365,24 @@ bytecompiled code, and their results compared.")
365(defun bytecomp-check-1 (pat) 365(defun bytecomp-check-1 (pat)
366 "Return non-nil if PAT is the same whether directly evalled or compiled." 366 "Return non-nil if PAT is the same whether directly evalled or compiled."
367 (let ((warning-minimum-log-level :emergency) 367 (let ((warning-minimum-log-level :emergency)
368 (byte-compile-warnings nil) 368 (byte-compile-warnings nil)
369 (v0 (condition-case nil 369 (v0 (condition-case err
370 (eval pat) 370 (eval pat)
371 (error 'bytecomp-check-error))) 371 (error (list 'bytecomp-check-error (car err)))))
372 (v1 (condition-case nil 372 (v1 (condition-case err
373 (funcall (byte-compile (list 'lambda nil pat))) 373 (funcall (byte-compile (list 'lambda nil pat)))
374 (error 'bytecomp-check-error)))) 374 (error (list 'bytecomp-check-error (car err))))))
375 (equal v0 v1))) 375 (equal v0 v1)))
376 376
377(put 'bytecomp-check-1 'ert-explainer 'bytecomp-explain-1) 377(put 'bytecomp-check-1 'ert-explainer 'bytecomp-explain-1)
378 378
379(defun bytecomp-explain-1 (pat) 379(defun bytecomp-explain-1 (pat)
380 (let ((v0 (condition-case nil 380 (let ((v0 (condition-case err
381 (eval pat) 381 (eval pat)
382 (error 'bytecomp-check-error))) 382 (error (list 'bytecomp-check-error (car err)))))
383 (v1 (condition-case nil 383 (v1 (condition-case err
384 (funcall (byte-compile (list 'lambda nil pat))) 384 (funcall (byte-compile (list 'lambda nil pat)))
385 (error 'bytecomp-check-error)))) 385 (error (list 'bytecomp-check-error (car err))))))
386 (format "Expression `%s' gives `%s' if directly evalled, `%s' if compiled." 386 (format "Expression `%s' gives `%s' if directly evalled, `%s' if compiled."
387 pat v0 v1))) 387 pat v0 v1)))
388 388
@@ -405,12 +405,12 @@ Subtests signal errors if something goes wrong."
405 (print-quoted t) 405 (print-quoted t)
406 v0 v1) 406 v0 v1)
407 (dolist (pat byte-opt-testsuite-arith-data) 407 (dolist (pat byte-opt-testsuite-arith-data)
408 (condition-case nil 408 (condition-case err
409 (setq v0 (eval pat)) 409 (setq v0 (eval pat))
410 (error (setq v0 'bytecomp-check-error))) 410 (error (setq v0 (list 'bytecomp-check-error (car err)))))
411 (condition-case nil 411 (condition-case err
412 (setq v1 (funcall (byte-compile (list 'lambda nil pat)))) 412 (setq v1 (funcall (byte-compile (list 'lambda nil pat))))
413 (error (setq v1 'bytecomp-check-error))) 413 (error (setq v1 (list 'bytecomp-check-error (car err)))))
414 (insert (format "%s" pat)) 414 (insert (format "%s" pat))
415 (indent-to-column 65) 415 (indent-to-column 65)
416 (if (equal v0 v1) 416 (if (equal v0 v1)
@@ -479,6 +479,7 @@ Subtests signal errors if something goes wrong."
479(ert-deftest bytecomp-tests--warnings () 479(ert-deftest bytecomp-tests--warnings ()
480 (with-current-buffer (get-buffer-create "*Compile-Log*") 480 (with-current-buffer (get-buffer-create "*Compile-Log*")
481 (let ((inhibit-read-only t)) (erase-buffer))) 481 (let ((inhibit-read-only t)) (erase-buffer)))
482 (mapc #'fmakunbound '(my-test0 my--test11 my--test12 my--test2))
482 (test-byte-comp-compile-and-load t 483 (test-byte-comp-compile-and-load t
483 '(progn 484 '(progn
484 (defun my-test0 () 485 (defun my-test0 ()
@@ -564,25 +565,25 @@ bytecompiled code, and their results compared.")
564 "Return non-nil if PAT is the same whether directly evalled or compiled." 565 "Return non-nil if PAT is the same whether directly evalled or compiled."
565 (let ((warning-minimum-log-level :emergency) 566 (let ((warning-minimum-log-level :emergency)
566 (byte-compile-warnings nil) 567 (byte-compile-warnings nil)
567 (v0 (condition-case nil 568 (v0 (condition-case err
568 (eval pat t) 569 (eval pat t)
569 (error 'bytecomp-check-error))) 570 (error (list 'bytecomp-check-error (car err)))))
570 (v1 (condition-case nil 571 (v1 (condition-case err
571 (funcall (let ((lexical-binding t)) 572 (funcall (let ((lexical-binding t))
572 (byte-compile `(lambda nil ,pat)))) 573 (byte-compile `(lambda nil ,pat))))
573 (error 'bytecomp-check-error)))) 574 (error (list 'bytecomp-check-error (car err))))))
574 (equal v0 v1))) 575 (equal v0 v1)))
575 576
576(put 'bytecomp-lexbind-check-1 'ert-explainer 'bytecomp-lexbind-explain-1) 577(put 'bytecomp-lexbind-check-1 'ert-explainer 'bytecomp-lexbind-explain-1)
577 578
578(defun bytecomp-lexbind-explain-1 (pat) 579(defun bytecomp-lexbind-explain-1 (pat)
579 (let ((v0 (condition-case nil 580 (let ((v0 (condition-case err
580 (eval pat t) 581 (eval pat t)
581 (error 'bytecomp-check-error))) 582 (error (list 'bytecomp-check-error (car err)))))
582 (v1 (condition-case nil 583 (v1 (condition-case err
583 (funcall (let ((lexical-binding t)) 584 (funcall (let ((lexical-binding t))
584 (byte-compile (list 'lambda nil pat)))) 585 (byte-compile (list 'lambda nil pat))))
585 (error 'bytecomp-check-error)))) 586 (error (list 'bytecomp-check-error (car err))))))
586 (format "Expression `%s' gives `%s' if directly evalled, `%s' if compiled." 587 (format "Expression `%s' gives `%s' if directly evalled, `%s' if compiled."
587 pat v0 v1))) 588 pat v0 v1)))
588 589
diff --git a/test/lisp/emacs-lisp/cl-lib-tests.el b/test/lisp/emacs-lisp/cl-lib-tests.el
index 57b9d23efb0..40dd7e4eeb0 100644
--- a/test/lisp/emacs-lisp/cl-lib-tests.el
+++ b/test/lisp/emacs-lisp/cl-lib-tests.el
@@ -242,6 +242,22 @@
242 (should (= (cl-the integer (cl-incf side-effect)) 1)) 242 (should (= (cl-the integer (cl-incf side-effect)) 1))
243 (should (= side-effect 1)))) 243 (should (= side-effect 1))))
244 244
245(ert-deftest cl-lib-test-incf ()
246 (let ((var 0))
247 (should (= (cl-incf var) 1))
248 (should (= var 1)))
249 (let ((alist))
250 (should (= (cl-incf (alist-get 'a alist 0)) 1))
251 (should (= (alist-get 'a alist 0) 1))))
252
253(ert-deftest cl-lib-test-decf ()
254 (let ((var 1))
255 (should (= (cl-decf var) 0))
256 (should (= var 0)))
257 (let ((alist))
258 (should (= (cl-decf (alist-get 'a alist 0)) -1))
259 (should (= (alist-get 'a alist 0) -1))))
260
245(ert-deftest cl-lib-test-plusp () 261(ert-deftest cl-lib-test-plusp ()
246 (should-not (cl-plusp -1.0e+INF)) 262 (should-not (cl-plusp -1.0e+INF))
247 (should-not (cl-plusp -1.5e2)) 263 (should-not (cl-plusp -1.5e2))
diff --git a/test/lisp/ffap-tests.el b/test/lisp/ffap-tests.el
index 30c8f794577..e8c12669c1a 100644
--- a/test/lisp/ffap-tests.el
+++ b/test/lisp/ffap-tests.el
@@ -77,6 +77,46 @@ left alone when opening a URL in an external browser."
77 (should (compare-window-configurations (current-window-configuration) old)) 77 (should (compare-window-configurations (current-window-configuration) old))
78 (should (equal urls '("https://www.gnu.org"))))) 78 (should (equal urls '("https://www.gnu.org")))))
79 79
80(defun ffap-test-string (space string)
81 (let ((ffap-file-name-with-spaces space))
82 (with-temp-buffer
83 (insert string)
84 (goto-char (point-min))
85 (forward-char 10)
86 (ffap-string-at-point))))
87
88(ert-deftest ffap-test-with-spaces ()
89 (should
90 (equal
91 (ffap-test-string
92 t "c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt")
93 "/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt"))
94 (should
95 (equal
96 (ffap-test-string
97 nil "c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program here.txt")
98 "c:/Program"))
99 (should
100 (equal
101 (ffap-test-string
102 t "c:/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program Files/Hummingbird/")
103 "/Program Files/Open Text Evaluation Media/Open Text Exceed 14 x86/Program Files/Hummingbird/"))
104 (should
105 (equal
106 (ffap-test-string
107 t "c:\\Program Files\\Open Text Evaluation Media\\Open Text Exceed 14 x86\\Program Files\\Hummingbird\\")
108 "\\Program Files\\Open Text Evaluation Media\\Open Text Exceed 14 x86\\Program Files\\Hummingbird\\"))
109 (should
110 (equal
111 (ffap-test-string
112 t "c:\\Program Files\\Freescale\\CW for MPC55xx and MPC56xx 2.10\\PowerPC_EABI_Tools\\Command_Line_Tools\\CLT_Usage_Notes.txt")
113 "\\Program Files\\Freescale\\CW for MPC55xx and MPC56xx 2.10\\PowerPC_EABI_Tools\\Command_Line_Tools\\CLT_Usage_Notes.txt"))
114 (should
115 (equal
116 (ffap-test-string
117 t "C:\\temp\\program.log on Windows or /var/log/program.log on Unix.")
118 "\\temp\\program.log")))
119
80(provide 'ffap-tests) 120(provide 'ffap-tests)
81 121
82;;; ffap-tests.el ends here 122;;; ffap-tests.el ends here
diff --git a/test/lisp/mail/flow-fill-tests.el b/test/lisp/mail/flow-fill-tests.el
index 4d435aeda71..c2e4178b7d4 100644
--- a/test/lisp/mail/flow-fill-tests.el
+++ b/test/lisp/mail/flow-fill-tests.el
@@ -35,7 +35,8 @@
35 ">>> unmuzzled ratsbane!\n" 35 ">>> unmuzzled ratsbane!\n"
36 ">>>> Henceforth, the coding style is to be strictly \n" 36 ">>>> Henceforth, the coding style is to be strictly \n"
37 ">>>> enforced, including the use of only upper case.\n" 37 ">>>> enforced, including the use of only upper case.\n"
38 ">>>>> I've noticed a lack of adherence to the coding \n" 38 ">>>>> I've noticed a lack of adherence to \n"
39 ">>>>> the coding \n"
39 ">>>>> styles, of late.\n" 40 ">>>>> styles, of late.\n"
40 ">>>>>> Any complaints?\n")) 41 ">>>>>> Any complaints?\n"))
41 (output 42 (output
diff --git a/test/lisp/progmodes/compile-tests.el b/test/lisp/progmodes/compile-tests.el
index cd736497e66..d566e7dd862 100644
--- a/test/lisp/progmodes/compile-tests.el
+++ b/test/lisp/progmodes/compile-tests.el
@@ -435,8 +435,8 @@ The test data is in `compile-tests--test-regexps-data'."
435 (compilation-num-infos-found 0)) 435 (compilation-num-infos-found 0))
436 (mapc #'compile--test-error-line compile-tests--test-regexps-data) 436 (mapc #'compile--test-error-line compile-tests--test-regexps-data)
437 (should (eq compilation-num-errors-found 94)) 437 (should (eq compilation-num-errors-found 94))
438 (should (eq compilation-num-warnings-found 37)) 438 (should (eq compilation-num-warnings-found 35))
439 (should (eq compilation-num-infos-found 26))))) 439 (should (eq compilation-num-infos-found 28)))))
440 440
441(ert-deftest compile-test-grep-regexps () 441(ert-deftest compile-test-grep-regexps ()
442 "Test the `grep-regexp-alist' regexps. 442 "Test the `grep-regexp-alist' regexps.
diff --git a/test/lisp/progmodes/cperl-mode-tests.el b/test/lisp/progmodes/cperl-mode-tests.el
new file mode 100644
index 00000000000..be8b42d99a8
--- /dev/null
+++ b/test/lisp/progmodes/cperl-mode-tests.el
@@ -0,0 +1,51 @@
1;;; cperl-mode-tests --- Test for cperl-mode -*- lexical-binding: t -*-
2
3;; Copyright (C) 2020 Free Software Foundation, Inc.
4
5;; Author: Harald Jörg <haj@posteo.de>
6;; Maintainer: Harald Jörg
7;; Keywords: internal
8;; Homepage: https://github.com/HaraldJoerg/cperl-mode
9
10;;; Commentary:
11
12;; This is a collection of tests for the fontification of CPerl-mode.
13
14;; Run these tests interactively:
15;; (ert-run-tests-interactively '(tag :fontification))
16
17;;; Code:
18
19(defvar cperl-test-mode #'cperl-mode)
20
21(defun cperl-test-ppss (text regexp)
22 "Return the `syntax-ppss' of the first character matched by REGEXP in TEXT."
23 (interactive)
24 (with-temp-buffer
25 (insert text)
26 (funcall cperl-test-mode)
27 (goto-char (point-min))
28 (re-search-forward regexp)
29 (syntax-ppss)))
30
31(ert-deftest cperl-mode-test-bug-42168 ()
32 "Verify that '/' is a division after ++ or --, not a regexp.
33Reported in https://github.com/jrockway/cperl-mode/issues/45.
34If seen as regular expression, then the slash is displayed using
35font-lock-constant-face. If seen as a division, then it doesn't
36have a face property."
37 :tags '(:fontification)
38 ;; The next two Perl expressions have divisions. Perl "punctuation"
39 ;; operators don't get a face.
40 (let ((code "{ $a++ / $b }"))
41 (should (equal (nth 8 (cperl-test-ppss code "/")) nil)))
42 (let ((code "{ $a-- / $b }"))
43 (should (equal (nth 8 (cperl-test-ppss code "/")) nil)))
44 ;; The next two Perl expressions have regular expressions. The
45 ;; delimiter of a RE is fontified with font-lock-constant-face.
46 (let ((code "{ $a+ / $b } # /"))
47 (should (equal (nth 8 (cperl-test-ppss code "/")) 7)))
48 (let ((code "{ $a- / $b } # /"))
49 (should (equal (nth 8 (cperl-test-ppss code "/")) 7))))
50
51;;; cperl-mode-tests.el ends here
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index 4adcacb279b..63e504bbe17 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -39,6 +39,13 @@
39 (with-no-warnings (simple-test--buffer-substrings)))) 39 (with-no-warnings (simple-test--buffer-substrings))))
40 40
41 41
42;;; `count-words'
43(ert-deftest simple-test-count-words-bug-41761 ()
44 (with-temp-buffer
45 (dotimes (i 10) (insert (propertize "test " 'field (cons nil nil))))
46 (should (= (count-words (point-min) (point-max)) 10))))
47
48
42;;; `transpose-sexps' 49;;; `transpose-sexps'
43(defmacro simple-test--transpositions (&rest body) 50(defmacro simple-test--transpositions (&rest body)
44 (declare (indent 0) 51 (declare (indent 0)
diff --git a/test/lisp/textmodes/bibtex-tests.el b/test/lisp/textmodes/bibtex-tests.el
new file mode 100644
index 00000000000..b3858de9e61
--- /dev/null
+++ b/test/lisp/textmodes/bibtex-tests.el
@@ -0,0 +1,57 @@
1;;; bibtex-tests.el --- Test suite for bibtex.
2
3;; Copyright (C) 2013-2020 Free Software Foundation, Inc.
4
5;; Keywords: bibtex
6
7;; This file is part of GNU Emacs.
8
9;; GNU Emacs is free software: you can redistribute it and/or modify
10;; it under the terms of the GNU General Public License as published by
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
18
19;; You should have received a copy of the GNU General Public License
20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
21
22;;; Commentary:
23
24;;; Code:
25
26(require 'ert)
27(require 'bibtex)
28
29(ert-deftest bibtex-test-set-dialect ()
30 "Tests if `bibtex-set-dialect' is executed."
31 (with-temp-buffer
32 (insert "@article{someID,
33 author = {some author},
34 title = {some title},
35}")
36 (bibtex-mode)
37 (should-not (null bibtex-dialect))
38 (should-not (null bibtex-entry-type))
39 (should-not (null bibtex-entry-head))
40 (should-not (null bibtex-reference-key))
41 (should-not (null bibtex-entry-head))
42 (should-not (null bibtex-entry-maybe-empty-head))
43 (should-not (null bibtex-any-valid-entry-type))))
44
45(ert-deftest bibtex-test-parse-buffers-stealthily ()
46 "Tests if `bibtex-parse-buffers-stealthily' can be executed."
47 (with-temp-buffer
48 (insert "@article{someID,
49 author = {some author},
50 title = {some title},
51}")
52 (bibtex-mode)
53 (should (progn (bibtex-parse-buffers-stealthily) t))))
54
55(provide 'bibtex-tests)
56
57;;; bibtex-tests.el ends here
diff --git a/test/lisp/textmodes/paragraphs-tests.el b/test/lisp/textmodes/paragraphs-tests.el
index fc839fe7d95..0b264e7e184 100644
--- a/test/lisp/textmodes/paragraphs-tests.el
+++ b/test/lisp/textmodes/paragraphs-tests.el
@@ -50,8 +50,8 @@
50 (goto-char (point-min)) 50 (goto-char (point-min))
51 (mark-paragraph) 51 (mark-paragraph)
52 (should mark-active) 52 (should mark-active)
53 (should (equal (mark) 7))) 53 (should (equal (mark) 7))))
54 (should-error (mark-paragraph 0))) 54;;; (should-error (mark-paragraph 0)))
55 55
56(ert-deftest paragraphs-tests-kill-paragraph () 56(ert-deftest paragraphs-tests-kill-paragraph ()
57 (with-temp-buffer 57 (with-temp-buffer
diff --git a/test/lisp/url/url-expand-tests.el b/test/lisp/url/url-expand-tests.el
index 6e0ce869502..3b0b6fbd41a 100644
--- a/test/lisp/url/url-expand-tests.el
+++ b/test/lisp/url/url-expand-tests.el
@@ -100,6 +100,13 @@
100 (should (equal (url-expand-file-name "foo#bar" "http://host/foobar") "http://host/foo#bar")) 100 (should (equal (url-expand-file-name "foo#bar" "http://host/foobar") "http://host/foo#bar"))
101 (should (equal (url-expand-file-name "foo#bar" "http://host/foobar/") "http://host/foobar/foo#bar"))) 101 (should (equal (url-expand-file-name "foo#bar" "http://host/foobar/") "http://host/foobar/foo#bar")))
102 102
103(ert-deftest url-expand-file-name/relative-resolution-file-url ()
104 "RFC 3986, Section 5.4 Reference Resolution Examples / Section 5.4.1. Normal Examples"
105 (should (equal (url-expand-file-name "bar.html" "file:///a/b/c/foo.html") "file:///a/b/c/bar.html"))
106 (should (equal (url-expand-file-name "bar.html" "file:///a/b/c/") "file:///a/b/c/bar.html"))
107 (should (equal (url-expand-file-name "../d/bar.html" "file:///a/b/c/") "file:///a/b/d/bar.html"))
108 (should (equal (url-expand-file-name "../d/bar.html" "file:///a/b/c/foo.html") "file:///a/b/d/bar.html")))
109
103(provide 'url-expand-tests) 110(provide 'url-expand-tests)
104 111
105;;; url-expand-tests.el ends here 112;;; url-expand-tests.el ends here