diff options
| author | Andrea Corallo | 2020-05-17 22:49:02 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2020-05-17 22:49:02 +0100 |
| commit | cd4ef52c8673a76c6fcb0efd7d2c74778522038c (patch) | |
| tree | b3d4b99c92ddccc02a2f3ee846b11419dde1d892 /test | |
| parent | 9e9421c7eecd74c9f163253ab760044fca53f26b (diff) | |
| parent | abec255c024938a40fa3c9730f602c0351e5877d (diff) | |
| download | emacs-cd4ef52c8673a76c6fcb0efd7d2c74778522038c.tar.gz emacs-cd4ef52c8673a76c6fcb0efd7d2c74778522038c.zip | |
Merge remote-tracking branch 'savannah/master' into HEAD
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/arc-mode-tests.el | 2 | ||||
| -rw-r--r-- | test/lisp/calc/calc-tests.el | 52 | ||||
| -rw-r--r-- | test/lisp/emacs-lisp/cl-macs-tests.el | 4 | ||||
| -rw-r--r-- | test/lisp/erc/erc-track-tests.el | 4 | ||||
| -rw-r--r-- | test/lisp/files-tests.el | 36 | ||||
| -rw-r--r-- | test/lisp/net/tramp-tests.el | 30 | ||||
| -rw-r--r-- | test/lisp/password-cache-tests.el | 14 | ||||
| -rw-r--r-- | test/lisp/progmodes/autoconf-tests.el | 55 | ||||
| -rw-r--r-- | test/lisp/startup-tests.el | 47 | ||||
| -rw-r--r-- | test/lisp/tar-mode-tests.el | 3 | ||||
| -rw-r--r-- | test/src/fns-tests.el | 34 |
11 files changed, 242 insertions, 39 deletions
diff --git a/test/lisp/arc-mode-tests.el b/test/lisp/arc-mode-tests.el index df658b98139..22ca7e2ec55 100644 --- a/test/lisp/arc-mode-tests.el +++ b/test/lisp/arc-mode-tests.el | |||
| @@ -28,7 +28,7 @@ | |||
| 28 | (let ((alist (list (cons 448 "-rwx------") | 28 | (let ((alist (list (cons 448 "-rwx------") |
| 29 | (cons 420 "-rw-r--r--") | 29 | (cons 420 "-rw-r--r--") |
| 30 | (cons 292 "-r--r--r--") | 30 | (cons 292 "-r--r--r--") |
| 31 | (cons 512 "----------") | 31 | (cons 512 "---------T") |
| 32 | (cons 1024 "------S---") ; Bug#28092 | 32 | (cons 1024 "------S---") ; Bug#28092 |
| 33 | (cons 2048 "---S------")))) | 33 | (cons 2048 "---S------")))) |
| 34 | (dolist (x alist) | 34 | (dolist (x alist) |
diff --git a/test/lisp/calc/calc-tests.el b/test/lisp/calc/calc-tests.el index 6db5426ff6d..c8cb97a8bca 100644 --- a/test/lisp/calc/calc-tests.el +++ b/test/lisp/calc/calc-tests.el | |||
| @@ -345,6 +345,58 @@ An existing calc stack is reused, otherwise a new one is created." | |||
| 345 | (should (Math-num-integerp '(float 1 0))) | 345 | (should (Math-num-integerp '(float 1 0))) |
| 346 | (should-not (Math-num-integerp nil))) | 346 | (should-not (Math-num-integerp nil))) |
| 347 | 347 | ||
| 348 | (ert-deftest calc-matrix-determinant () | ||
| 349 | (should (equal (calcFunc-det '(vec (vec 3))) | ||
| 350 | 3)) | ||
| 351 | (should (equal (calcFunc-det '(vec (vec 2 3) (vec 6 7))) | ||
| 352 | -4)) | ||
| 353 | (should (equal (calcFunc-det '(vec (vec 1 2 3) (vec 4 5 7) (vec 9 6 2))) | ||
| 354 | 15)) | ||
| 355 | (should (equal (calcFunc-det '(vec (vec 0 5 7 3) | ||
| 356 | (vec 0 0 2 0) | ||
| 357 | (vec 1 2 3 4) | ||
| 358 | (vec 0 0 0 3))) | ||
| 359 | 30)) | ||
| 360 | (should (equal (calcFunc-det '(vec (vec (var a var-a)))) | ||
| 361 | '(var a var-a))) | ||
| 362 | (should (equal (calcFunc-det '(vec (vec 2 (var a var-a)) | ||
| 363 | (vec 7 (var a var-a)))) | ||
| 364 | '(* -5 (var a var-a)))) | ||
| 365 | (should (equal (calcFunc-det '(vec (vec 1 0 0 0) | ||
| 366 | (vec 0 1 0 0) | ||
| 367 | (vec 0 0 0 1) | ||
| 368 | (vec 0 0 (var a var-a) 0))) | ||
| 369 | '(neg (var a var-a))))) | ||
| 370 | |||
| 371 | (ert-deftest calc-gcd () | ||
| 372 | (should (equal (calcFunc-gcd 3 4) 1)) | ||
| 373 | (should (equal (calcFunc-gcd 12 15) 3)) | ||
| 374 | (should (equal (calcFunc-gcd -12 15) 3)) | ||
| 375 | (should (equal (calcFunc-gcd 12 -15) 3)) | ||
| 376 | (should (equal (calcFunc-gcd -12 -15) 3)) | ||
| 377 | (should (equal (calcFunc-gcd 0 5) 5)) | ||
| 378 | (should (equal (calcFunc-gcd 5 0) 5)) | ||
| 379 | (should (equal (calcFunc-gcd 0 -5) 5)) | ||
| 380 | (should (equal (calcFunc-gcd -5 0) 5)) | ||
| 381 | (should (equal (calcFunc-gcd 0 0) 0)) | ||
| 382 | (should (equal (calcFunc-gcd 0 '(var x var-x)) | ||
| 383 | '(calcFunc-abs (var x var-x)))) | ||
| 384 | (should (equal (calcFunc-gcd '(var x var-x) 0) | ||
| 385 | '(calcFunc-abs (var x var-x))))) | ||
| 386 | |||
| 387 | (ert-deftest calc-sum-gcd () | ||
| 388 | ;; sum(gcd(0,n),n,-1,-1) | ||
| 389 | (should (equal (math-simplify '(calcFunc-sum (calcFunc-gcd 0 (var n var-n)) | ||
| 390 | (var n var-n) -1 -1)) | ||
| 391 | 1)) | ||
| 392 | ;; sum(sum(gcd(n,k),k,-1,1),n,-1,1) | ||
| 393 | (should (equal (math-simplify | ||
| 394 | '(calcFunc-sum | ||
| 395 | (calcFunc-sum (calcFunc-gcd (var n var-n) (var k var-k)) | ||
| 396 | (var k var-k) -1 1) | ||
| 397 | (var n var-n) -1 1)) | ||
| 398 | 8))) | ||
| 399 | |||
| 348 | (provide 'calc-tests) | 400 | (provide 'calc-tests) |
| 349 | ;;; calc-tests.el ends here | 401 | ;;; calc-tests.el ends here |
| 350 | 402 | ||
diff --git a/test/lisp/emacs-lisp/cl-macs-tests.el b/test/lisp/emacs-lisp/cl-macs-tests.el index 983e79ac57c..24bbad0cc6b 100644 --- a/test/lisp/emacs-lisp/cl-macs-tests.el +++ b/test/lisp/emacs-lisp/cl-macs-tests.el | |||
| @@ -425,7 +425,9 @@ collection clause." | |||
| 425 | '(2 3 4 5 6)))) | 425 | '(2 3 4 5 6)))) |
| 426 | 426 | ||
| 427 | (ert-deftest cl-macs-loop-across-ref () | 427 | (ert-deftest cl-macs-loop-across-ref () |
| 428 | (should (equal (cl-loop with my-vec = ["one" "two" "three"] | 428 | (should (equal (cl-loop with my-vec = (vector (cl-copy-seq "one") |
| 429 | (cl-copy-seq "two") | ||
| 430 | (cl-copy-seq "three")) | ||
| 429 | for x across-ref my-vec | 431 | for x across-ref my-vec |
| 430 | do (setf (aref x 0) (upcase (aref x 0))) | 432 | do (setf (aref x 0) (upcase (aref x 0))) |
| 431 | finally return my-vec) | 433 | finally return my-vec) |
diff --git a/test/lisp/erc/erc-track-tests.el b/test/lisp/erc/erc-track-tests.el index 7e924c22347..457f08cb73c 100644 --- a/test/lisp/erc/erc-track-tests.el +++ b/test/lisp/erc/erc-track-tests.el | |||
| @@ -107,8 +107,8 @@ | |||
| 107 | 107 | ||
| 108 | (ert-deftest erc-track--erc-faces-in () | 108 | (ert-deftest erc-track--erc-faces-in () |
| 109 | "`erc-faces-in' should pick up both 'face and 'font-lock-face properties." | 109 | "`erc-faces-in' should pick up both 'face and 'font-lock-face properties." |
| 110 | (let ((str0 "is bold") | 110 | (let ((str0 (copy-sequence "is bold")) |
| 111 | (str1 "is bold")) | 111 | (str1 (copy-sequence "is bold"))) |
| 112 | ;; Turn on Font Lock mode: this initialize `char-property-alias-alist' | 112 | ;; Turn on Font Lock mode: this initialize `char-property-alias-alist' |
| 113 | ;; to '((face font-lock-face)). Note that `font-lock-mode' don't | 113 | ;; to '((face font-lock-face)). Note that `font-lock-mode' don't |
| 114 | ;; turn on the mode if the test is run on batch mode or if the | 114 | ;; turn on the mode if the test is run on batch mode or if the |
diff --git a/test/lisp/files-tests.el b/test/lisp/files-tests.el index 05d9ceebf1d..4b902fd82ae 100644 --- a/test/lisp/files-tests.el +++ b/test/lisp/files-tests.el | |||
| @@ -1164,6 +1164,42 @@ works as expected if the default directory is quoted." | |||
| 1164 | (should-not (make-directory a/b t)) | 1164 | (should-not (make-directory a/b t)) |
| 1165 | (delete-directory dir 'recursive))) | 1165 | (delete-directory dir 'recursive))) |
| 1166 | 1166 | ||
| 1167 | (ert-deftest files-tests-file-modes-symbolic-to-number () | ||
| 1168 | (let ((alist (list (cons "a=rwx" #o777) | ||
| 1169 | (cons "o=t" #o1000) | ||
| 1170 | (cons "o=xt" #o1001) | ||
| 1171 | (cons "o=tx" #o1001) ; Order doesn't matter. | ||
| 1172 | (cons "u=rwx,g=rx,o=rx" #o755) | ||
| 1173 | (cons "u=rwx,g=,o=" #o700) | ||
| 1174 | (cons "u=rwx" #o700) ; Empty permissions can be ignored. | ||
| 1175 | (cons "u=rw,g=r,o=r" #o644) | ||
| 1176 | (cons "u=rw,g=r,o=t" #o1640) | ||
| 1177 | (cons "u=rw,g=r,o=xt" #o1641) | ||
| 1178 | (cons "u=rwxs,g=rs,o=xt" #o7741) | ||
| 1179 | (cons "u=rws,g=rs,o=t" #o7640) | ||
| 1180 | (cons "u=rws,g=rs,o=r" #o6644) | ||
| 1181 | (cons "a=r" #o444) | ||
| 1182 | (cons "u=S" nil) | ||
| 1183 | (cons "u=T" nil) | ||
| 1184 | (cons "u=Z" nil)))) | ||
| 1185 | (dolist (x alist) | ||
| 1186 | (if (cdr-safe x) | ||
| 1187 | (should (equal (cdr x) (file-modes-symbolic-to-number (car x)))) | ||
| 1188 | (should-error (file-modes-symbolic-to-number (car x))))))) | ||
| 1189 | |||
| 1190 | (ert-deftest files-tests-file-modes-number-to-symbolic () | ||
| 1191 | (let ((alist (list (cons #o755 "-rwxr-xr-x") | ||
| 1192 | (cons #o700 "-rwx------") | ||
| 1193 | (cons #o644 "-rw-r--r--") | ||
| 1194 | (cons #o1640 "-rw-r----T") | ||
| 1195 | (cons #o1641 "-rw-r----t") | ||
| 1196 | (cons #o7741 "-rwsr-S--t") | ||
| 1197 | (cons #o7640 "-rwSr-S--T") | ||
| 1198 | (cons #o6644 "-rwSr-Sr--") | ||
| 1199 | (cons #o444 "-r--r--r--")))) | ||
| 1200 | (dolist (x alist) | ||
| 1201 | (should (equal (cdr x) (file-modes-number-to-symbolic (car x))))))) | ||
| 1202 | |||
| 1167 | (ert-deftest files-tests-no-file-write-contents () | 1203 | (ert-deftest files-tests-no-file-write-contents () |
| 1168 | "Test that `write-contents-functions' permits saving a file. | 1204 | "Test that `write-contents-functions' permits saving a file. |
| 1169 | Usually `basic-save-buffer' will prompt for a file name if the | 1205 | Usually `basic-save-buffer' will prompt for a file name if the |
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el index de85f83982c..1f56baad7ce 100644 --- a/test/lisp/net/tramp-tests.el +++ b/test/lisp/net/tramp-tests.el | |||
| @@ -75,6 +75,7 @@ | |||
| 75 | ;; Needed for Emacs 26. | 75 | ;; Needed for Emacs 26. |
| 76 | (defvar async-shell-command-width) | 76 | (defvar async-shell-command-width) |
| 77 | ;; Needed for Emacs 27. | 77 | ;; Needed for Emacs 27. |
| 78 | (defvar process-file-return-signal-string) | ||
| 78 | (defvar shell-command-dont-erase-buffer) | 79 | (defvar shell-command-dont-erase-buffer) |
| 79 | 80 | ||
| 80 | ;; Beautify batch mode. | 81 | ;; Beautify batch mode. |
| @@ -4208,18 +4209,27 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'." | |||
| 4208 | (should (zerop (process-file "true"))) | 4209 | (should (zerop (process-file "true"))) |
| 4209 | (should-not (zerop (process-file "false"))) | 4210 | (should-not (zerop (process-file "false"))) |
| 4210 | (should-not (zerop (process-file "binary-does-not-exist"))) | 4211 | (should-not (zerop (process-file "binary-does-not-exist"))) |
| 4211 | (should | 4212 | ;; Return exit code. |
| 4212 | (= 42 | 4213 | (should (= 42 (process-file |
| 4214 | (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh") | ||
| 4215 | nil nil nil "-c" "exit 42"))) | ||
| 4216 | ;; Return exit code in case the process is interrupted, | ||
| 4217 | ;; and there's no indication for a signal describing string. | ||
| 4218 | (let (process-file-return-signal-string) | ||
| 4219 | (should | ||
| 4220 | (= (+ 128 2) | ||
| 4221 | (process-file | ||
| 4222 | (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh") | ||
| 4223 | nil nil nil "-c" "kill -2 $$")))) | ||
| 4224 | ;; Return string in case the process is interrupted and | ||
| 4225 | ;; there's an indication for a signal describing string. | ||
| 4226 | (let ((process-file-return-signal-string t)) | ||
| 4227 | (should | ||
| 4228 | (string-equal | ||
| 4229 | "Interrupt" | ||
| 4213 | (process-file | 4230 | (process-file |
| 4214 | (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh") | 4231 | (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh") |
| 4215 | nil nil nil "-c" "exit 42"))) | 4232 | nil nil nil "-c" "kill -2 $$")))) |
| 4216 | ;; Return string in case the process is interrupted. | ||
| 4217 | (should | ||
| 4218 | (string-equal | ||
| 4219 | "Signal 2" | ||
| 4220 | (process-file | ||
| 4221 | (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh") | ||
| 4222 | nil nil nil "-c" "kill -2 $$"))) | ||
| 4223 | 4233 | ||
| 4224 | (with-temp-buffer | 4234 | (with-temp-buffer |
| 4225 | (write-region "foo" nil tmp-name) | 4235 | (write-region "foo" nil tmp-name) |
diff --git a/test/lisp/password-cache-tests.el b/test/lisp/password-cache-tests.el index 01f4358fc59..55ebbfce7fe 100644 --- a/test/lisp/password-cache-tests.el +++ b/test/lisp/password-cache-tests.el | |||
| @@ -28,31 +28,31 @@ | |||
| 28 | 28 | ||
| 29 | (ert-deftest password-cache-tests-add-and-remove () | 29 | (ert-deftest password-cache-tests-add-and-remove () |
| 30 | (let ((password-data (copy-hash-table password-data))) | 30 | (let ((password-data (copy-hash-table password-data))) |
| 31 | (password-cache-add "foo" "bar") | 31 | (password-cache-add "foo" (copy-sequence "bar")) |
| 32 | (should (eq (password-in-cache-p "foo") t)) | 32 | (should (eq (password-in-cache-p "foo") t)) |
| 33 | (password-cache-remove "foo") | 33 | (password-cache-remove "foo") |
| 34 | (should (not (password-in-cache-p "foo"))))) | 34 | (should (not (password-in-cache-p "foo"))))) |
| 35 | 35 | ||
| 36 | (ert-deftest password-cache-tests-read-from-cache () | 36 | (ert-deftest password-cache-tests-read-from-cache () |
| 37 | (let ((password-data (copy-hash-table password-data))) | 37 | (let ((password-data (copy-hash-table password-data))) |
| 38 | (password-cache-add "foo" "bar") | 38 | (password-cache-add "foo" (copy-sequence "bar")) |
| 39 | (should (equal (password-read-from-cache "foo") "bar")) | 39 | (should (equal (password-read-from-cache "foo") "bar")) |
| 40 | (should (not (password-read-from-cache nil))))) | 40 | (should (not (password-read-from-cache nil))))) |
| 41 | 41 | ||
| 42 | (ert-deftest password-cache-tests-in-cache-p () | 42 | (ert-deftest password-cache-tests-in-cache-p () |
| 43 | (let ((password-data (copy-hash-table password-data))) | 43 | (let ((password-data (copy-hash-table password-data))) |
| 44 | (password-cache-add "foo" "bar") | 44 | (password-cache-add "foo" (copy-sequence "bar")) |
| 45 | (should (password-in-cache-p "foo")) | 45 | (should (password-in-cache-p "foo")) |
| 46 | (should (not (password-read-from-cache nil))))) | 46 | (should (not (password-read-from-cache nil))))) |
| 47 | 47 | ||
| 48 | (ert-deftest password-cache-tests-read () | 48 | (ert-deftest password-cache-tests-read () |
| 49 | (let ((password-data (copy-hash-table password-data))) | 49 | (let ((password-data (copy-hash-table password-data))) |
| 50 | (password-cache-add "foo" "bar") | 50 | (password-cache-add "foo" (copy-sequence "bar")) |
| 51 | (should (equal (password-read nil "foo") "bar")))) | 51 | (should (equal (password-read nil "foo") "bar")))) |
| 52 | 52 | ||
| 53 | (ert-deftest password-cache-tests-reset () | 53 | (ert-deftest password-cache-tests-reset () |
| 54 | (let ((password-data (copy-hash-table password-data))) | 54 | (let ((password-data (copy-hash-table password-data))) |
| 55 | (password-cache-add "foo" "bar") | 55 | (password-cache-add "foo" (copy-sequence "bar")) |
| 56 | (password-reset) | 56 | (password-reset) |
| 57 | (should (not (password-in-cache-p "foo"))))) | 57 | (should (not (password-in-cache-p "foo"))))) |
| 58 | 58 | ||
| @@ -60,14 +60,14 @@ | |||
| 60 | :tags '(:expensive-test) | 60 | :tags '(:expensive-test) |
| 61 | (let ((password-data (copy-hash-table password-data)) | 61 | (let ((password-data (copy-hash-table password-data)) |
| 62 | (password-cache-expiry 0.01)) | 62 | (password-cache-expiry 0.01)) |
| 63 | (password-cache-add "foo" "bar") | 63 | (password-cache-add "foo" (copy-sequence "bar")) |
| 64 | (sit-for 0.1) | 64 | (sit-for 0.1) |
| 65 | (should (not (password-in-cache-p "foo"))))) | 65 | (should (not (password-in-cache-p "foo"))))) |
| 66 | 66 | ||
| 67 | (ert-deftest password-cache-tests-no-password-cache () | 67 | (ert-deftest password-cache-tests-no-password-cache () |
| 68 | (let ((password-data (copy-hash-table password-data)) | 68 | (let ((password-data (copy-hash-table password-data)) |
| 69 | (password-cache nil)) | 69 | (password-cache nil)) |
| 70 | (password-cache-add "foo" "bar") | 70 | (password-cache-add "foo" (copy-sequence "bar")) |
| 71 | (should (not (password-in-cache-p "foo"))) | 71 | (should (not (password-in-cache-p "foo"))) |
| 72 | (should (not (password-read-from-cache "foo"))))) | 72 | (should (not (password-read-from-cache "foo"))))) |
| 73 | 73 | ||
diff --git a/test/lisp/progmodes/autoconf-tests.el b/test/lisp/progmodes/autoconf-tests.el new file mode 100644 index 00000000000..63cf2889ee2 --- /dev/null +++ b/test/lisp/progmodes/autoconf-tests.el | |||
| @@ -0,0 +1,55 @@ | |||
| 1 | ;;; autoconf-tests.el --- Tests for autoconf.el -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2020 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Simen Heggestøyl <simenheg@gmail.com> | ||
| 6 | ;; Keywords: | ||
| 7 | |||
| 8 | ;; This file is part of GNU Emacs. | ||
| 9 | |||
| 10 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 11 | ;; it under the terms of the GNU General Public License as published by | ||
| 12 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 13 | ;; (at your option) any later version. | ||
| 14 | |||
| 15 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 16 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 17 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 18 | ;; GNU General Public License for more details. | ||
| 19 | |||
| 20 | ;; You should have received a copy of the GNU General Public License | ||
| 21 | ;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. | ||
| 22 | |||
| 23 | ;;; Commentary: | ||
| 24 | |||
| 25 | ;; | ||
| 26 | |||
| 27 | ;;; Code: | ||
| 28 | |||
| 29 | (require 'autoconf) | ||
| 30 | (require 'ert) | ||
| 31 | |||
| 32 | (ert-deftest autoconf-tests-current-defun-function-define () | ||
| 33 | (with-temp-buffer | ||
| 34 | (insert "AC_DEFINE(HAVE_RSVG, 1, [Define to 1 if using librsvg.])") | ||
| 35 | (goto-char (point-min)) | ||
| 36 | (should-not (autoconf-current-defun-function)) | ||
| 37 | (forward-char 10) | ||
| 38 | (should (equal (autoconf-current-defun-function) "HAVE_RSVG")))) | ||
| 39 | |||
| 40 | (ert-deftest autoconf-tests-current-defun-function-subst () | ||
| 41 | (with-temp-buffer | ||
| 42 | (insert "AC_SUBST(srcdir)") | ||
| 43 | (goto-char (point-min)) | ||
| 44 | (should-not (autoconf-current-defun-function)) | ||
| 45 | (forward-char 9) | ||
| 46 | (should (equal (autoconf-current-defun-function) "srcdir")))) | ||
| 47 | |||
| 48 | (ert-deftest autoconf-tests-autoconf-mode-comment-syntax () | ||
| 49 | (with-temp-buffer | ||
| 50 | (autoconf-mode) | ||
| 51 | (insert "dnl Autoconf script for GNU Emacs") | ||
| 52 | (should (nth 4 (syntax-ppss))))) | ||
| 53 | |||
| 54 | (provide 'autoconf-tests) | ||
| 55 | ;;; autoconf-tests.el ends here | ||
diff --git a/test/lisp/startup-tests.el b/test/lisp/startup-tests.el new file mode 100644 index 00000000000..314ffc93e4a --- /dev/null +++ b/test/lisp/startup-tests.el | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | ;;; startup-tests.el --- unit tests for startup.el -*- lexical-binding: t; -*- | ||
| 2 | |||
| 3 | ;; Copyright (C) 2020 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; Author: Philipp Stephani <phst@google.com> | ||
| 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 <https://www.gnu.org/licenses/>. | ||
| 21 | |||
| 22 | ;;; Commentary: | ||
| 23 | |||
| 24 | ;; Unit tests for startup.el. | ||
| 25 | |||
| 26 | ;;; Code: | ||
| 27 | |||
| 28 | (ert-deftest startup-tests/command-switch-alist () | ||
| 29 | (let* ((foo-args ()) (bar-args ()) | ||
| 30 | (command-switch-alist | ||
| 31 | (list (cons "--foo" | ||
| 32 | (lambda (arg) | ||
| 33 | (ert-info ("Processing argument --foo") | ||
| 34 | (push arg foo-args) | ||
| 35 | (should (equal command-line-args-left | ||
| 36 | '("value" "--bar=value"))) | ||
| 37 | (pop command-line-args-left)))) | ||
| 38 | (cons "--bar=value" | ||
| 39 | (lambda (arg) | ||
| 40 | (ert-info ("Processing argument --bar") | ||
| 41 | (push arg bar-args) | ||
| 42 | (should-not command-line-args-left))))))) | ||
| 43 | (command-line-1 '("--foo" "value" "--bar=value")) | ||
| 44 | (should (equal foo-args '("--foo"))) | ||
| 45 | (should (equal bar-args '("--bar=value"))))) | ||
| 46 | |||
| 47 | ;;; startup-tests.el ends here | ||
diff --git a/test/lisp/tar-mode-tests.el b/test/lisp/tar-mode-tests.el index bc41b863da7..f05389df60f 100644 --- a/test/lisp/tar-mode-tests.el +++ b/test/lisp/tar-mode-tests.el | |||
| @@ -29,7 +29,8 @@ | |||
| 29 | (cons 420 "rw-r--r--") | 29 | (cons 420 "rw-r--r--") |
| 30 | (cons 292 "r--r--r--") | 30 | (cons 292 "r--r--r--") |
| 31 | (cons 512 "--------T") | 31 | (cons 512 "--------T") |
| 32 | (cons 1024 "-----S---")))) | 32 | (cons 1024 "-----S---") |
| 33 | (cons 2048 "--S------")))) | ||
| 33 | (dolist (x alist) | 34 | (dolist (x alist) |
| 34 | (should (equal (cdr x) (tar-grind-file-mode (car x))))))) | 35 | (should (equal (cdr x) (tar-grind-file-mode (car x))))))) |
| 35 | 36 | ||
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index c6ceae4a00e..b65543a64b5 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -49,21 +49,21 @@ | |||
| 49 | (should-error (nreverse)) | 49 | (should-error (nreverse)) |
| 50 | (should-error (nreverse 1)) | 50 | (should-error (nreverse 1)) |
| 51 | (should-error (nreverse (make-char-table 'foo))) | 51 | (should-error (nreverse (make-char-table 'foo))) |
| 52 | (should (equal (nreverse "xyzzy") "yzzyx")) | 52 | (should (equal (nreverse (copy-sequence "xyzzy")) "yzzyx")) |
| 53 | (let ((A [])) | 53 | (let ((A (vector))) |
| 54 | (nreverse A) | 54 | (nreverse A) |
| 55 | (should (equal A []))) | 55 | (should (equal A []))) |
| 56 | (let ((A [0])) | 56 | (let ((A (vector 0))) |
| 57 | (nreverse A) | 57 | (nreverse A) |
| 58 | (should (equal A [0]))) | 58 | (should (equal A [0]))) |
| 59 | (let ((A [1 2 3 4])) | 59 | (let ((A (vector 1 2 3 4))) |
| 60 | (nreverse A) | 60 | (nreverse A) |
| 61 | (should (equal A [4 3 2 1]))) | 61 | (should (equal A [4 3 2 1]))) |
| 62 | (let ((A [1 2 3 4])) | 62 | (let ((A (vector 1 2 3 4))) |
| 63 | (nreverse A) | 63 | (nreverse A) |
| 64 | (nreverse A) | 64 | (nreverse A) |
| 65 | (should (equal A [1 2 3 4]))) | 65 | (should (equal A [1 2 3 4]))) |
| 66 | (let* ((A [1 2 3 4]) | 66 | (let* ((A (vector 1 2 3 4)) |
| 67 | (B (nreverse (nreverse A)))) | 67 | (B (nreverse (nreverse A)))) |
| 68 | (should (equal A B)))) | 68 | (should (equal A B)))) |
| 69 | 69 | ||
| @@ -146,13 +146,13 @@ | |||
| 146 | ;; Invalid UTF-8 sequences shall be indicated. How to create such strings? | 146 | ;; Invalid UTF-8 sequences shall be indicated. How to create such strings? |
| 147 | 147 | ||
| 148 | (ert-deftest fns-tests-sort () | 148 | (ert-deftest fns-tests-sort () |
| 149 | (should (equal (sort '(9 5 2 -1 5 3 8 7 4) (lambda (x y) (< x y))) | 149 | (should (equal (sort (list 9 5 2 -1 5 3 8 7 4) (lambda (x y) (< x y))) |
| 150 | '(-1 2 3 4 5 5 7 8 9))) | 150 | '(-1 2 3 4 5 5 7 8 9))) |
| 151 | (should (equal (sort '(9 5 2 -1 5 3 8 7 4) (lambda (x y) (> x y))) | 151 | (should (equal (sort (list 9 5 2 -1 5 3 8 7 4) (lambda (x y) (> x y))) |
| 152 | '(9 8 7 5 5 4 3 2 -1))) | 152 | '(9 8 7 5 5 4 3 2 -1))) |
| 153 | (should (equal (sort '[9 5 2 -1 5 3 8 7 4] (lambda (x y) (< x y))) | 153 | (should (equal (sort (vector 9 5 2 -1 5 3 8 7 4) (lambda (x y) (< x y))) |
| 154 | [-1 2 3 4 5 5 7 8 9])) | 154 | [-1 2 3 4 5 5 7 8 9])) |
| 155 | (should (equal (sort '[9 5 2 -1 5 3 8 7 4] (lambda (x y) (> x y))) | 155 | (should (equal (sort (vector 9 5 2 -1 5 3 8 7 4) (lambda (x y) (> x y))) |
| 156 | [9 8 7 5 5 4 3 2 -1])) | 156 | [9 8 7 5 5 4 3 2 -1])) |
| 157 | (should (equal | 157 | (should (equal |
| 158 | (sort | 158 | (sort |
| @@ -172,7 +172,7 @@ | |||
| 172 | ;; Punctuation and whitespace characters are relevant for POSIX. | 172 | ;; Punctuation and whitespace characters are relevant for POSIX. |
| 173 | (should | 173 | (should |
| 174 | (equal | 174 | (equal |
| 175 | (sort '("11" "12" "1 1" "1 2" "1.1" "1.2") | 175 | (sort (list "11" "12" "1 1" "1 2" "1.1" "1.2") |
| 176 | (lambda (a b) (string-collate-lessp a b "POSIX"))) | 176 | (lambda (a b) (string-collate-lessp a b "POSIX"))) |
| 177 | '("1 1" "1 2" "1.1" "1.2" "11" "12"))) | 177 | '("1 1" "1 2" "1.1" "1.2" "11" "12"))) |
| 178 | ;; Punctuation and whitespace characters are not taken into account | 178 | ;; Punctuation and whitespace characters are not taken into account |
| @@ -180,7 +180,7 @@ | |||
| 180 | (when (eq system-type 'windows-nt) | 180 | (when (eq system-type 'windows-nt) |
| 181 | (should | 181 | (should |
| 182 | (equal | 182 | (equal |
| 183 | (sort '("11" "12" "1 1" "1 2" "1.1" "1.2") | 183 | (sort (list "11" "12" "1 1" "1 2" "1.1" "1.2") |
| 184 | (lambda (a b) | 184 | (lambda (a b) |
| 185 | (let ((w32-collate-ignore-punctuation t)) | 185 | (let ((w32-collate-ignore-punctuation t)) |
| 186 | (string-collate-lessp | 186 | (string-collate-lessp |
| @@ -190,7 +190,7 @@ | |||
| 190 | ;; Diacritics are different letters for POSIX, they sort lexicographical. | 190 | ;; Diacritics are different letters for POSIX, they sort lexicographical. |
| 191 | (should | 191 | (should |
| 192 | (equal | 192 | (equal |
| 193 | (sort '("Ævar" "Agustín" "Adrian" "Eli") | 193 | (sort (list "Ævar" "Agustín" "Adrian" "Eli") |
| 194 | (lambda (a b) (string-collate-lessp a b "POSIX"))) | 194 | (lambda (a b) (string-collate-lessp a b "POSIX"))) |
| 195 | '("Adrian" "Agustín" "Eli" "Ævar"))) | 195 | '("Adrian" "Agustín" "Eli" "Ævar"))) |
| 196 | ;; Diacritics are sorted between similar letters for other locales, | 196 | ;; Diacritics are sorted between similar letters for other locales, |
| @@ -198,7 +198,7 @@ | |||
| 198 | (when (eq system-type 'windows-nt) | 198 | (when (eq system-type 'windows-nt) |
| 199 | (should | 199 | (should |
| 200 | (equal | 200 | (equal |
| 201 | (sort '("Ævar" "Agustín" "Adrian" "Eli") | 201 | (sort (list "Ævar" "Agustín" "Adrian" "Eli") |
| 202 | (lambda (a b) | 202 | (lambda (a b) |
| 203 | (let ((w32-collate-ignore-punctuation t)) | 203 | (let ((w32-collate-ignore-punctuation t)) |
| 204 | (string-collate-lessp | 204 | (string-collate-lessp |
| @@ -212,7 +212,7 @@ | |||
| 212 | (should (not (string-version-lessp "foo20000.png" "foo12.png"))) | 212 | (should (not (string-version-lessp "foo20000.png" "foo12.png"))) |
| 213 | (should (string-version-lessp "foo.png" "foo2.png")) | 213 | (should (string-version-lessp "foo.png" "foo2.png")) |
| 214 | (should (not (string-version-lessp "foo2.png" "foo.png"))) | 214 | (should (not (string-version-lessp "foo2.png" "foo.png"))) |
| 215 | (should (equal (sort '("foo12.png" "foo2.png" "foo1.png") | 215 | (should (equal (sort (list "foo12.png" "foo2.png" "foo1.png") |
| 216 | 'string-version-lessp) | 216 | 'string-version-lessp) |
| 217 | '("foo1.png" "foo2.png" "foo12.png"))) | 217 | '("foo1.png" "foo2.png" "foo12.png"))) |
| 218 | (should (string-version-lessp "foo2" "foo1234")) | 218 | (should (string-version-lessp "foo2" "foo1234")) |
| @@ -432,9 +432,9 @@ | |||
| 432 | (should-error (mapcan)) | 432 | (should-error (mapcan)) |
| 433 | (should-error (mapcan #'identity)) | 433 | (should-error (mapcan #'identity)) |
| 434 | (should-error (mapcan #'identity (make-char-table 'foo))) | 434 | (should-error (mapcan #'identity (make-char-table 'foo))) |
| 435 | (should (equal (mapcan #'list '(1 2 3)) '(1 2 3))) | 435 | (should (equal (mapcan #'list (list 1 2 3)) '(1 2 3))) |
| 436 | ;; `mapcan' is destructive | 436 | ;; `mapcan' is destructive |
| 437 | (let ((data '((foo) (bar)))) | 437 | (let ((data (list (list 'foo) (list 'bar)))) |
| 438 | (should (equal (mapcan #'identity data) '(foo bar))) | 438 | (should (equal (mapcan #'identity data) '(foo bar))) |
| 439 | (should (equal data '((foo bar) (bar)))))) | 439 | (should (equal data '((foo bar) (bar)))))) |
| 440 | 440 | ||