diff options
| author | Michael R. Mauger | 2017-07-03 15:32:41 -0400 |
|---|---|---|
| committer | Michael R. Mauger | 2017-07-03 15:32:41 -0400 |
| commit | 776635c01abd4aa759e7aa9584b513146978568c (patch) | |
| tree | 554f444bc96cb6b05435e8bf195de4df1b00df8f /test/src | |
| parent | 77083e2d34ba5559ae2899d3b03cf08c2e6c5ad4 (diff) | |
| parent | 4cd0db3d6e6e4d5bd49283483bdafbbfc0f583f1 (diff) | |
| download | emacs-776635c01abd4aa759e7aa9584b513146978568c.tar.gz emacs-776635c01abd4aa759e7aa9584b513146978568c.zip | |
Merge branch 'master' of git.sv.gnu.org:/srv/git/emacs
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/alloc-tests.el | 20 | ||||
| -rw-r--r-- | test/src/casefiddle-tests.el | 129 | ||||
| -rw-r--r-- | test/src/data-tests.el | 80 | ||||
| -rw-r--r-- | test/src/editfns-tests.el | 103 | ||||
| -rw-r--r-- | test/src/emacs-module-tests.el | 218 | ||||
| -rw-r--r-- | test/src/eval-tests.el | 2 | ||||
| -rw-r--r-- | test/src/fns-tests.el | 1 | ||||
| -rw-r--r-- | test/src/lread-tests.el | 52 | ||||
| -rw-r--r-- | test/src/regex-tests.el | 2 | ||||
| -rw-r--r-- | test/src/undo-tests.el | 22 |
10 files changed, 531 insertions, 98 deletions
diff --git a/test/src/alloc-tests.el b/test/src/alloc-tests.el index af4ad6c6355..1cf1fc3be5c 100644 --- a/test/src/alloc-tests.el +++ b/test/src/alloc-tests.el | |||
| @@ -31,3 +31,23 @@ | |||
| 31 | 31 | ||
| 32 | (ert-deftest finalizer-object-type () | 32 | (ert-deftest finalizer-object-type () |
| 33 | (should (equal (type-of (make-finalizer nil)) 'finalizer))) | 33 | (should (equal (type-of (make-finalizer nil)) 'finalizer))) |
| 34 | |||
| 35 | (ert-deftest record-1 () | ||
| 36 | (let ((x (record 'foo 1 2 3))) | ||
| 37 | (should (recordp x)) | ||
| 38 | (should (eq (type-of x) 'foo)) | ||
| 39 | (should (eq (aref x 0) 'foo)) | ||
| 40 | (should (eql (aref x 3) 3)) | ||
| 41 | (should (eql (length x) 4)))) | ||
| 42 | |||
| 43 | (ert-deftest record-2 () | ||
| 44 | (let ((x (make-record 'bar 1 0))) | ||
| 45 | (should (eql (length x) 2)) | ||
| 46 | (should (eql (aref x 1) 0)))) | ||
| 47 | |||
| 48 | (ert-deftest record-3 () | ||
| 49 | (let* ((x (record 'foo 1 2 3)) | ||
| 50 | (y (copy-sequence x))) | ||
| 51 | (should-not (eq x y)) | ||
| 52 | (dotimes (i 4) | ||
| 53 | (should (eql (aref x i) (aref y i)))))) | ||
diff --git a/test/src/casefiddle-tests.el b/test/src/casefiddle-tests.el index 152d85de006..234d233c71a 100644 --- a/test/src/casefiddle-tests.el +++ b/test/src/casefiddle-tests.el | |||
| @@ -24,36 +24,40 @@ | |||
| 24 | 24 | ||
| 25 | (ert-deftest casefiddle-tests-char-properties () | 25 | (ert-deftest casefiddle-tests-char-properties () |
| 26 | "Sanity check of character Unicode properties." | 26 | "Sanity check of character Unicode properties." |
| 27 | (should-not | 27 | (let ((props '(uppercase lowercase titlecase |
| 28 | (let (errors) | 28 | special-uppercase special-lowercase special-titlecase)) |
| 29 | ;; character uppercase lowercase titlecase | 29 | (tests '((?A nil ?a nil nil nil nil) |
| 30 | (dolist (test '((?A nil ?a nil) | 30 | (?a ?A nil ?A nil nil nil) |
| 31 | (?a ?A nil ?A) | 31 | (?Ł nil ?ł nil nil nil nil) |
| 32 | (?Ł nil ?ł nil) | 32 | (?ł ?Ł nil ?Ł nil nil nil) |
| 33 | (?ł ?Ł nil ?Ł) | 33 | |
| 34 | 34 | (?DŽ nil ?dž ?Dž nil nil nil) | |
| 35 | (?DŽ nil ?dž ?Dž) | 35 | (?Dž ?DŽ ?dž ?Dž nil nil nil) |
| 36 | (?Dž ?DŽ ?dž ?Dž) | 36 | (?dž ?DŽ nil ?Dž nil nil nil) |
| 37 | (?dž ?DŽ nil ?Dž) | 37 | |
| 38 | 38 | (?Σ nil ?σ nil nil nil nil) | |
| 39 | (?Σ nil ?σ nil) | 39 | (?σ ?Σ nil ?Σ nil nil nil) |
| 40 | (?σ ?Σ nil ?Σ) | 40 | (?ς ?Σ nil ?Σ nil nil nil) |
| 41 | (?ς ?Σ nil ?Σ) | 41 | |
| 42 | 42 | (?ⅷ ?Ⅷ nil ?Ⅷ nil nil nil) | |
| 43 | (?ⅷ ?Ⅷ nil ?Ⅷ) | 43 | (?Ⅷ nil ?ⅷ nil nil nil nil) |
| 44 | (?Ⅷ nil ?ⅷ nil))) | 44 | |
| 45 | (let ((ch (car test)) | 45 | (?fi nil nil nil "FI" nil "Fi") |
| 46 | (expected (cdr test)) | 46 | (?ß nil nil nil "SS" nil "Ss") |
| 47 | (props '(uppercase lowercase titlecase))) | 47 | (?İ nil ?i nil nil "i\u0307" nil))) |
| 48 | (while props | 48 | errors) |
| 49 | (let ((got (get-char-code-property ch (car props)))) | 49 | (dolist (test tests) |
| 50 | (unless (equal (car expected) got) | 50 | (let ((ch (car test)) |
| 51 | (push (format "\n%c %s; expected: %s but got: %s" | 51 | (expected (cdr test))) |
| 52 | ch (car props) (car expected) got) | 52 | (dolist (prop props) |
| 53 | errors))) | 53 | (let ((got (get-char-code-property ch prop))) |
| 54 | (setq props (cdr props) expected (cdr expected))))) | 54 | (unless (equal (car expected) got) |
| 55 | (when errors | 55 | (push (format "\n%c %s; expected: %s but got: %s" |
| 56 | (mapconcat (lambda (line) line) (nreverse errors) ""))))) | 56 | ch prop (car expected) got) |
| 57 | errors))) | ||
| 58 | (setq expected (cdr expected))))) | ||
| 59 | (when errors | ||
| 60 | (ert-fail (mapconcat (lambda (line) line) (nreverse errors) ""))))) | ||
| 57 | 61 | ||
| 58 | 62 | ||
| 59 | (defconst casefiddle-tests--characters | 63 | (defconst casefiddle-tests--characters |
| @@ -63,13 +67,9 @@ | |||
| 63 | (?Ł ?Ł ?ł ?Ł) | 67 | (?Ł ?Ł ?ł ?Ł) |
| 64 | (?ł ?Ł ?ł ?Ł) | 68 | (?ł ?Ł ?ł ?Ł) |
| 65 | 69 | ||
| 66 | ;; FIXME(bug#24603): Commented ones are what we want. | 70 | (?DŽ ?DŽ ?dž ?Dž) |
| 67 | ;;(?DŽ ?DŽ ?dž ?Dž) | 71 | (?Dž ?DŽ ?dž ?Dž) |
| 68 | (?DŽ ?DŽ ?dž ?DŽ) | 72 | (?dž ?DŽ ?dž ?Dž) |
| 69 | ;;(?Dž ?DŽ ?dž ?Dž) | ||
| 70 | (?Dž ?DŽ ?dž ?DŽ) | ||
| 71 | ;;(?dž ?DŽ ?dž ?Dž) | ||
| 72 | (?dž ?DŽ ?dž ?DŽ) | ||
| 73 | 73 | ||
| 74 | (?Σ ?Σ ?σ ?Σ) | 74 | (?Σ ?Σ ?σ ?Σ) |
| 75 | (?σ ?Σ ?σ ?Σ) | 75 | (?σ ?Σ ?σ ?Σ) |
| @@ -186,25 +186,25 @@ | |||
| 186 | ;; input upper lower capitalize up-initials | 186 | ;; input upper lower capitalize up-initials |
| 187 | '(("Foo baR" "FOO BAR" "foo bar" "Foo Bar" "Foo BaR") | 187 | '(("Foo baR" "FOO BAR" "foo bar" "Foo Bar" "Foo BaR") |
| 188 | ("Ⅷ ⅷ" "Ⅷ Ⅷ" "ⅷ ⅷ" "Ⅷ Ⅷ" "Ⅷ Ⅷ") | 188 | ("Ⅷ ⅷ" "Ⅷ Ⅷ" "ⅷ ⅷ" "Ⅷ Ⅷ" "Ⅷ Ⅷ") |
| 189 | ;; FIXME(bug#24603): Everything below is broken at the moment. | 189 | ;; "DžUNGLA" is an unfortunate result but it’s really best we can |
| 190 | ;; Here’s what should happen: | 190 | ;; do while still being consistent. Hopefully, users only ever |
| 191 | ;;("DŽUNGLA" "DŽUNGLA" "džungla" "Džungla" "DžUNGLA") | 191 | ;; use upcase-initials on camelCase identifiers not real words. |
| 192 | ;;("ungla" "DŽUNGLA" "džungla" "Džungla" "Džungla") | 192 | ("UNGLA" "DŽUNGLA" "džungla" "Džungla" "DžUNGLA") |
| 193 | ;;("ungla" "DŽUNGLA" "džungla" "Džungla" "Džungla") | 193 | ("ungla" "DŽUNGLA" "džungla" "Džungla" "Džungla") |
| 194 | ;;("define" "DEFINE" "define" "Define" "Define") | 194 | ("džungla" "DŽUNGLA" "džungla" "Džungla" "Džungla") |
| 195 | ;;("fish" "FIsh" "fish" "Fish" "Fish") | 195 | ("define" "DEFINE" "define" "Define" "Define") |
| 196 | ;;("Straße" "STRASSE" "straße" "Straße" "Straße") | 196 | ("fish" "FISH" "fish" "Fish" "Fish") |
| 197 | ;;("ΌΣΣ" "ΌΣΟΣ" "όσος" "Όσος" "Όσος") | 197 | ("Strae" "STRASSE" "straße" "Straße" "Straße") |
| 198 | ;; And here’s what is actually happening: | 198 | |
| 199 | ("DŽUNGLA" "DŽUNGLA" "džungla" "DŽungla" "DŽUNGLA") | 199 | ;; The word repeated twice to test behaviour at the end of a word |
| 200 | ("Džungla" "DŽUNGLA" "džungla" "DŽungla" "DŽungla") | 200 | ;; inside of an input string as well as at the end of the string. |
| 201 | ("džungla" "DŽUNGLA" "džungla" "DŽungla" "DŽungla") | 201 | ("ΌΣΟΣ ΌΣΟΣ" "ΌΣΟΣ ΌΣΟΣ" "όσος όσος" "Όσος Όσος" "ΌΣΟΣ ΌΣΟΣ") |
| 202 | ("define" "DEfiNE" "define" "Define" "Define") | 202 | ;; What should be done with sole sigma? It is ‘final’ but on the |
| 203 | ("fish" "fiSH" "fish" "fish" "fish") | 203 | ;; other hand it does not form a word. We’re using regular sigma. |
| 204 | ("Straße" "STRAßE" "straße" "Straße" "Straße") | 204 | ("Σ Σ" "Σ Σ" "σ σ" "Σ Σ" "Σ Σ") |
| 205 | ("ΟΣ" "ΌΣΟΣ" "όσο" "Όσο" "ΌΟΣ") | 205 | ("σς" "ΌΣΟΣ" "όσο" "Όσο" "Όσς") |
| 206 | 206 | ;; If sigma is already lower case, we don’t want to change it. | |
| 207 | ("όσο" "ΌΣΟΣ" "όσο" "Όσο" "Όσο")))))) | 207 | ("όσο" "ΌΣΟΣ" "όσο" "Όσο" "Όσο")))))) |
| 208 | 208 | ||
| 209 | (ert-deftest casefiddle-tests-casing-byte8 () | 209 | (ert-deftest casefiddle-tests-casing-byte8 () |
| 210 | (should-not | 210 | (should-not |
| @@ -243,4 +243,21 @@ | |||
| 243 | "\xef\xff\xef Zażółć GĘŚlą \xcf\xcf"))))))) | 243 | "\xef\xff\xef Zażółć GĘŚlą \xcf\xcf"))))))) |
| 244 | 244 | ||
| 245 | 245 | ||
| 246 | (ert-deftest casefiddle-tests-char-casing () | ||
| 247 | ;; input upcase downcase [titlecase] | ||
| 248 | (dolist (test '((?a ?A ?a) (?A ?A ?a) | ||
| 249 | (?ł ?Ł ?ł) (?Ł ?Ł ?ł) | ||
| 250 | (?ß ?ß ?ß) (?ẞ ?ẞ ?ß) | ||
| 251 | (?ⅷ ?Ⅷ ?ⅷ) (?Ⅷ ?Ⅷ ?ⅷ) | ||
| 252 | (?DŽ ?DŽ ?dž ?Dž) (?Dž ?DŽ ?dž ?Dž) (?dž ?DŽ ?dž ?Dž))) | ||
| 253 | (let ((ch (car test)) | ||
| 254 | (up (nth 1 test)) | ||
| 255 | (lo (nth 2 test)) | ||
| 256 | (tc (or (nth 3 test) (nth 1 test)))) | ||
| 257 | (should (eq up (upcase ch))) | ||
| 258 | (should (eq lo (downcase ch))) | ||
| 259 | (should (eq tc (capitalize ch))) | ||
| 260 | (should (eq tc (upcase-initials ch)))))) | ||
| 261 | |||
| 262 | |||
| 246 | ;;; casefiddle-tests.el ends here | 263 | ;;; casefiddle-tests.el ends here |
diff --git a/test/src/data-tests.el b/test/src/data-tests.el index 67d00a7f930..00a30559e32 100644 --- a/test/src/data-tests.el +++ b/test/src/data-tests.el | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'cl-lib) | 24 | (require 'cl-lib) |
| 25 | (eval-when-compile (require 'cl)) | ||
| 26 | 25 | ||
| 27 | (ert-deftest data-tests-= () | 26 | (ert-deftest data-tests-= () |
| 28 | (should-error (=)) | 27 | (should-error (=)) |
| @@ -141,9 +140,9 @@ | |||
| 141 | 43)))) | 140 | 43)))) |
| 142 | 141 | ||
| 143 | (defun mock-bool-vector-count-consecutive (a b i) | 142 | (defun mock-bool-vector-count-consecutive (a b i) |
| 144 | (loop for i from i below (length a) | 143 | (cl-loop for i from i below (length a) |
| 145 | while (eq (aref a i) b) | 144 | while (eq (aref a i) b) |
| 146 | sum 1)) | 145 | sum 1)) |
| 147 | 146 | ||
| 148 | (defun test-bool-vector-bv-from-hex-string (desc) | 147 | (defun test-bool-vector-bv-from-hex-string (desc) |
| 149 | (let (bv nchars nibbles) | 148 | (let (bv nchars nibbles) |
| @@ -157,7 +156,7 @@ | |||
| 157 | (dolist (n (nreverse nibbles)) | 156 | (dolist (n (nreverse nibbles)) |
| 158 | (dotimes (_ 4) | 157 | (dotimes (_ 4) |
| 159 | (aset bv i (> (logand 1 n) 0)) | 158 | (aset bv i (> (logand 1 n) 0)) |
| 160 | (incf i) | 159 | (cl-incf i) |
| 161 | (setf n (lsh n -1))))) | 160 | (setf n (lsh n -1))))) |
| 162 | bv)) | 161 | bv)) |
| 163 | 162 | ||
| @@ -182,9 +181,9 @@ hexadecimal digits describing the bool vector. We exhaustively | |||
| 182 | test all counts at all possible positions in the vector by | 181 | test all counts at all possible positions in the vector by |
| 183 | comparing the subr with a much slower lisp implementation." | 182 | comparing the subr with a much slower lisp implementation." |
| 184 | (let ((bv (test-bool-vector-bv-from-hex-string desc))) | 183 | (let ((bv (test-bool-vector-bv-from-hex-string desc))) |
| 185 | (loop | 184 | (cl-loop |
| 186 | for lf in '(nil t) | 185 | for lf in '(nil t) |
| 187 | do (loop | 186 | do (cl-loop |
| 188 | for pos from 0 upto (length bv) | 187 | for pos from 0 upto (length bv) |
| 189 | for cnt = (mock-bool-vector-count-consecutive bv lf pos) | 188 | for cnt = (mock-bool-vector-count-consecutive bv lf pos) |
| 190 | for rcnt = (bool-vector-count-consecutive bv lf pos) | 189 | for rcnt = (bool-vector-count-consecutive bv lf pos) |
| @@ -217,36 +216,36 @@ comparing the subr with a much slower lisp implementation." | |||
| 217 | (defun test-bool-vector-apply-mock-op (mock a b c) | 216 | (defun test-bool-vector-apply-mock-op (mock a b c) |
| 218 | "Compute (slowly) the correct result of a bool-vector set operation." | 217 | "Compute (slowly) the correct result of a bool-vector set operation." |
| 219 | (let (changed nv) | 218 | (let (changed nv) |
| 220 | (assert (eql (length b) (length c))) | 219 | (cl-assert (eql (length b) (length c))) |
| 221 | (if a (setf nv a) | 220 | (if a (setf nv a) |
| 222 | (setf a (make-bool-vector (length b) nil)) | 221 | (setf a (make-bool-vector (length b) nil)) |
| 223 | (setf changed t)) | 222 | (setf changed t)) |
| 224 | 223 | ||
| 225 | (loop for i below (length b) | 224 | (cl-loop for i below (length b) |
| 226 | for mockr = (funcall mock | 225 | for mockr = (funcall mock |
| 227 | (if (aref b i) 1 0) | 226 | (if (aref b i) 1 0) |
| 228 | (if (aref c i) 1 0)) | 227 | (if (aref c i) 1 0)) |
| 229 | for r = (not (= 0 mockr)) | 228 | for r = (not (= 0 mockr)) |
| 230 | do (progn | 229 | do (progn |
| 231 | (unless (eq (aref a i) r) | 230 | (unless (eq (aref a i) r) |
| 232 | (setf changed t)) | 231 | (setf changed t)) |
| 233 | (setf (aref a i) r))) | 232 | (setf (aref a i) r))) |
| 234 | (if changed a))) | 233 | (if changed a))) |
| 235 | 234 | ||
| 236 | (defun test-bool-vector-binop (mock real) | 235 | (defun test-bool-vector-binop (mock real) |
| 237 | "Test a binary set operation." | 236 | "Test a binary set operation." |
| 238 | (loop for s1 in bool-vector-test-vectors | 237 | (cl-loop for s1 in bool-vector-test-vectors |
| 239 | for bv1 = (test-bool-vector-bv-from-hex-string s1) | 238 | for bv1 = (test-bool-vector-bv-from-hex-string s1) |
| 240 | for vecs2 = (cl-remove-if-not | 239 | for vecs2 = (cl-remove-if-not |
| 241 | (lambda (x) (eql (length x) (length s1))) | 240 | (lambda (x) (eql (length x) (length s1))) |
| 242 | bool-vector-test-vectors) | 241 | bool-vector-test-vectors) |
| 243 | do (loop for s2 in vecs2 | 242 | do (cl-loop for s2 in vecs2 |
| 244 | for bv2 = (test-bool-vector-bv-from-hex-string s2) | 243 | for bv2 = (test-bool-vector-bv-from-hex-string s2) |
| 245 | for mock-result = (test-bool-vector-apply-mock-op | 244 | for mock-result = (test-bool-vector-apply-mock-op |
| 246 | mock nil bv1 bv2) | 245 | mock nil bv1 bv2) |
| 247 | for real-result = (funcall real bv1 bv2) | 246 | for real-result = (funcall real bv1 bv2) |
| 248 | do (progn | 247 | do (progn |
| 249 | (should (equal mock-result real-result)))))) | 248 | (should (equal mock-result real-result)))))) |
| 250 | 249 | ||
| 251 | (ert-deftest bool-vector-intersection-op () | 250 | (ert-deftest bool-vector-intersection-op () |
| 252 | (test-bool-vector-binop | 251 | (test-bool-vector-binop |
| @@ -300,8 +299,7 @@ comparing the subr with a much slower lisp implementation." | |||
| 300 | 299 | ||
| 301 | (ert-deftest binding-test-manual () | 300 | (ert-deftest binding-test-manual () |
| 302 | "A test case from the elisp manual." | 301 | "A test case from the elisp manual." |
| 303 | (save-excursion | 302 | (with-current-buffer binding-test-buffer-A |
| 304 | (set-buffer binding-test-buffer-A) | ||
| 305 | (let ((binding-test-some-local 'something-else)) | 303 | (let ((binding-test-some-local 'something-else)) |
| 306 | (should (eq binding-test-some-local 'something-else)) | 304 | (should (eq binding-test-some-local 'something-else)) |
| 307 | (set-buffer binding-test-buffer-B) | 305 | (set-buffer binding-test-buffer-B) |
| @@ -312,8 +310,7 @@ comparing the subr with a much slower lisp implementation." | |||
| 312 | 310 | ||
| 313 | (ert-deftest binding-test-setq-default () | 311 | (ert-deftest binding-test-setq-default () |
| 314 | "Test that a setq-default has no effect when there is a local binding." | 312 | "Test that a setq-default has no effect when there is a local binding." |
| 315 | (save-excursion | 313 | (with-current-buffer binding-test-buffer-B |
| 316 | (set-buffer binding-test-buffer-B) | ||
| 317 | ;; This variable is not local in this buffer. | 314 | ;; This variable is not local in this buffer. |
| 318 | (let ((binding-test-some-local 'something-else)) | 315 | (let ((binding-test-some-local 'something-else)) |
| 319 | (setq-default binding-test-some-local 'new-default)) | 316 | (setq-default binding-test-some-local 'new-default)) |
| @@ -321,8 +318,7 @@ comparing the subr with a much slower lisp implementation." | |||
| 321 | 318 | ||
| 322 | (ert-deftest binding-test-makunbound () | 319 | (ert-deftest binding-test-makunbound () |
| 323 | "Tests of makunbound, from the manual." | 320 | "Tests of makunbound, from the manual." |
| 324 | (save-excursion | 321 | (with-current-buffer binding-test-buffer-B |
| 325 | (set-buffer binding-test-buffer-B) | ||
| 326 | (should (boundp 'binding-test-some-local)) | 322 | (should (boundp 'binding-test-some-local)) |
| 327 | (let ((binding-test-some-local 'outer)) | 323 | (let ((binding-test-some-local 'outer)) |
| 328 | (let ((binding-test-some-local 'inner)) | 324 | (let ((binding-test-some-local 'inner)) |
| @@ -342,19 +338,19 @@ comparing the subr with a much slower lisp implementation." | |||
| 342 | 338 | ||
| 343 | (ert-deftest binding-test-set-constant-t () | 339 | (ert-deftest binding-test-set-constant-t () |
| 344 | "Test setting the constant t" | 340 | "Test setting the constant t" |
| 345 | (should-error (setq t 'bob) :type 'setting-constant)) | 341 | (with-no-warnings (should-error (setq t 'bob) :type 'setting-constant))) |
| 346 | 342 | ||
| 347 | (ert-deftest binding-test-set-constant-nil () | 343 | (ert-deftest binding-test-set-constant-nil () |
| 348 | "Test setting the constant nil" | 344 | "Test setting the constant nil" |
| 349 | (should-error (setq nil 'bob) :type 'setting-constant)) | 345 | (with-no-warnings (should-error (setq nil 'bob) :type 'setting-constant))) |
| 350 | 346 | ||
| 351 | (ert-deftest binding-test-set-constant-keyword () | 347 | (ert-deftest binding-test-set-constant-keyword () |
| 352 | "Test setting a keyword constant" | 348 | "Test setting a keyword constant" |
| 353 | (should-error (setq :keyword 'bob) :type 'setting-constant)) | 349 | (with-no-warnings (should-error (setq :keyword 'bob) :type 'setting-constant))) |
| 354 | 350 | ||
| 355 | (ert-deftest binding-test-set-constant-nil () | 351 | (ert-deftest binding-test-set-constant-nil () |
| 356 | "Test setting a keyword to itself" | 352 | "Test setting a keyword to itself" |
| 357 | (should (setq :keyword :keyword))) | 353 | (with-no-warnings (should (setq :keyword :keyword)))) |
| 358 | 354 | ||
| 359 | ;; More tests to write - | 355 | ;; More tests to write - |
| 360 | ;; kill-local-variable | 356 | ;; kill-local-variable |
| @@ -406,12 +402,14 @@ comparing the subr with a much slower lisp implementation." | |||
| 406 | (should (null watch-data)))) | 402 | (should (null watch-data)))) |
| 407 | ;; Watch var0, then alias it. | 403 | ;; Watch var0, then alias it. |
| 408 | (add-variable-watcher 'data-tests-var0 collect-watch-data) | 404 | (add-variable-watcher 'data-tests-var0 collect-watch-data) |
| 405 | (defvar data-tests-var0-alias) | ||
| 409 | (defvaralias 'data-tests-var0-alias 'data-tests-var0) | 406 | (defvaralias 'data-tests-var0-alias 'data-tests-var0) |
| 410 | (setq data-tests-var0 1) | 407 | (setq data-tests-var0 1) |
| 411 | (should-have-watch-data '(data-tests-var0 1 set nil)) | 408 | (should-have-watch-data '(data-tests-var0 1 set nil)) |
| 412 | (setq data-tests-var0-alias 2) | 409 | (setq data-tests-var0-alias 2) |
| 413 | (should-have-watch-data '(data-tests-var0 2 set nil)) | 410 | (should-have-watch-data '(data-tests-var0 2 set nil)) |
| 414 | ;; Alias var1, then watch var1-alias. | 411 | ;; Alias var1, then watch var1-alias. |
| 412 | (defvar data-tests-var1-alias) | ||
| 415 | (defvaralias 'data-tests-var1-alias 'data-tests-var1) | 413 | (defvaralias 'data-tests-var1-alias 'data-tests-var1) |
| 416 | (add-variable-watcher 'data-tests-var1-alias collect-watch-data) | 414 | (add-variable-watcher 'data-tests-var1-alias collect-watch-data) |
| 417 | (setq data-tests-var1 1) | 415 | (setq data-tests-var1 1) |
| @@ -419,6 +417,7 @@ comparing the subr with a much slower lisp implementation." | |||
| 419 | (setq data-tests-var1-alias 2) | 417 | (setq data-tests-var1-alias 2) |
| 420 | (should-have-watch-data '(data-tests-var1 2 set nil)) | 418 | (should-have-watch-data '(data-tests-var1 2 set nil)) |
| 421 | ;; Alias var2, then watch it. | 419 | ;; Alias var2, then watch it. |
| 420 | (defvar data-tests-var2-alias) | ||
| 422 | (defvaralias 'data-tests-var2-alias 'data-tests-var2) | 421 | (defvaralias 'data-tests-var2-alias 'data-tests-var2) |
| 423 | (add-variable-watcher 'data-tests-var2 collect-watch-data) | 422 | (add-variable-watcher 'data-tests-var2 collect-watch-data) |
| 424 | (setq data-tests-var2 1) | 423 | (setq data-tests-var2 1) |
| @@ -437,7 +436,8 @@ comparing the subr with a much slower lisp implementation." | |||
| 437 | (should (null watch-data))))) | 436 | (should (null watch-data))))) |
| 438 | 437 | ||
| 439 | (ert-deftest data-tests-local-variable-watchers () | 438 | (ert-deftest data-tests-local-variable-watchers () |
| 440 | (defvar-local data-tests-lvar 0) | 439 | (with-no-warnings |
| 440 | (defvar-local data-tests-lvar 0)) | ||
| 441 | (let* ((buf1 (current-buffer)) | 441 | (let* ((buf1 (current-buffer)) |
| 442 | (buf2 nil) | 442 | (buf2 nil) |
| 443 | (watch-data nil) | 443 | (watch-data nil) |
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index 14124ef85fb..a3ea8ab60b5 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el | |||
| @@ -136,4 +136,107 @@ | |||
| 136 | (ert-deftest format-c-float () | 136 | (ert-deftest format-c-float () |
| 137 | (should-error (format "%c" 0.5))) | 137 | (should-error (format "%c" 0.5))) |
| 138 | 138 | ||
| 139 | ;;; Check format-time-string with various TZ settings. | ||
| 140 | ;;; Use only POSIX-compatible TZ values, since the tests should work | ||
| 141 | ;;; even if tzdb is not in use. | ||
| 142 | (ert-deftest format-time-string-with-zone () | ||
| 143 | ;; Don’t use (0 0 0 0) as the test case, as there are too many bugs | ||
| 144 | ;; in MS-Windows (and presumably other) C libraries when formatting | ||
| 145 | ;; time stamps near the Epoch of 1970-01-01 00:00:00 UTC, and this | ||
| 146 | ;; test is for GNU Emacs, not for C runtimes. Instead, look before | ||
| 147 | ;; you leap: "look" is the timestamp just before the first leap | ||
| 148 | ;; second on 1972-06-30 23:59:60 UTC, so it should format to the | ||
| 149 | ;; same string regardless of whether the underlying C library | ||
| 150 | ;; ignores leap seconds, while avoiding circa-1970 glitches. | ||
| 151 | ;; | ||
| 152 | ;; Similarly, stick to the limited set of time zones that are | ||
| 153 | ;; supported by both POSIX and MS-Windows: exactly 3 ASCII letters | ||
| 154 | ;; in the abbreviation, and no DST. | ||
| 155 | (let ((look '(1202 22527 999999 999999)) | ||
| 156 | (format "%Y-%m-%d %H:%M:%S.%3N %z (%Z)")) | ||
| 157 | ;; UTC. | ||
| 158 | (should (string-equal | ||
| 159 | (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" look t) | ||
| 160 | "1972-06-30 23:59:59.999 +0000")) | ||
| 161 | ;; "UTC0". | ||
| 162 | (should (string-equal | ||
| 163 | (format-time-string format look "UTC0") | ||
| 164 | "1972-06-30 23:59:59.999 +0000 (UTC)")) | ||
| 165 | ;; Negative UTC offset, as a Lisp list. | ||
| 166 | (should (string-equal | ||
| 167 | (format-time-string format look '(-28800 "PST")) | ||
| 168 | "1972-06-30 15:59:59.999 -0800 (PST)")) | ||
| 169 | ;; Positive UTC offset that is not an hour multiple, as a string. | ||
| 170 | (should (string-equal | ||
| 171 | (format-time-string format look "IST-5:30") | ||
| 172 | "1972-07-01 05:29:59.999 +0530 (IST)")))) | ||
| 173 | |||
| 174 | ;;; This should not dump core. | ||
| 175 | (ert-deftest format-time-string-with-outlandish-zone () | ||
| 176 | (should (stringp | ||
| 177 | (format-time-string "%Y-%m-%d %H:%M:%S.%3N %z" nil | ||
| 178 | (concat (make-string 2048 ?X) "0"))))) | ||
| 179 | |||
| 180 | (ert-deftest format-with-field () | ||
| 181 | (should (equal (format "First argument %2$s, then %3$s, then %1$s" 1 2 3) | ||
| 182 | "First argument 2, then 3, then 1")) | ||
| 183 | (should (equal (format "a %2$s %3$d %1$d %2$S %3$d %4$d b" 11 "22" 33 44) | ||
| 184 | "a 22 33 11 \"22\" 33 44 b")) | ||
| 185 | (should (equal (format "a %08$s %0000000000000000009$s b" 1 2 3 4 5 6 7 8 9) | ||
| 186 | "a 8 9 b")) | ||
| 187 | (should (equal (should-error (format "a %999999$s b" 11)) | ||
| 188 | '(error "Not enough arguments for format string"))) | ||
| 189 | (should (equal (should-error (format "a %2147483647$s b")) | ||
| 190 | '(error "Not enough arguments for format string"))) | ||
| 191 | (should (equal (should-error (format "a %9223372036854775807$s b")) | ||
| 192 | '(error "Not enough arguments for format string"))) | ||
| 193 | (should (equal (should-error (format "a %9223372036854775808$s b")) | ||
| 194 | '(error "Not enough arguments for format string"))) | ||
| 195 | (should (equal (should-error (format "a %18446744073709551615$s b")) | ||
| 196 | '(error "Not enough arguments for format string"))) | ||
| 197 | (should (equal (should-error (format "a %18446744073709551616$s b")) | ||
| 198 | '(error "Not enough arguments for format string"))) | ||
| 199 | (should (equal (should-error | ||
| 200 | (format (format "a %%%d$d b" most-positive-fixnum))) | ||
| 201 | '(error "Not enough arguments for format string"))) | ||
| 202 | (should (equal (should-error | ||
| 203 | (format (format "a %%%d$d b" (+ 1.0 most-positive-fixnum)))) | ||
| 204 | '(error "Not enough arguments for format string"))) | ||
| 205 | (should (equal (should-error (format "a %$s b" 11)) | ||
| 206 | '(error "Invalid format operation %$"))) | ||
| 207 | (should (equal (should-error (format "a %-1$s b" 11)) | ||
| 208 | '(error "Invalid format operation %$"))) | ||
| 209 | (should (equal (format "%1$c %1$s" ?±) "± 177"))) | ||
| 210 | |||
| 211 | (ert-deftest replace-buffer-contents-1 () | ||
| 212 | (with-temp-buffer | ||
| 213 | (insert #("source" 2 4 (prop 7))) | ||
| 214 | (let ((source (current-buffer))) | ||
| 215 | (with-temp-buffer | ||
| 216 | (insert "before dest after") | ||
| 217 | (let ((marker (set-marker (make-marker) 14))) | ||
| 218 | (save-restriction | ||
| 219 | (narrow-to-region 8 12) | ||
| 220 | (replace-buffer-contents source)) | ||
| 221 | (should (equal (marker-buffer marker) (current-buffer))) | ||
| 222 | (should (equal (marker-position marker) 16))) | ||
| 223 | (should (equal-including-properties | ||
| 224 | (buffer-string) | ||
| 225 | #("before source after" 9 11 (prop 7)))) | ||
| 226 | (should (equal (point) 9)))) | ||
| 227 | (should (equal-including-properties | ||
| 228 | (buffer-string) | ||
| 229 | #("source" 2 4 (prop 7)))))) | ||
| 230 | |||
| 231 | (ert-deftest replace-buffer-contents-2 () | ||
| 232 | (with-temp-buffer | ||
| 233 | (insert "foo bar baz qux") | ||
| 234 | (let ((source (current-buffer))) | ||
| 235 | (with-temp-buffer | ||
| 236 | (insert "foo BAR baz qux") | ||
| 237 | (replace-buffer-contents source) | ||
| 238 | (should (equal-including-properties | ||
| 239 | (buffer-string) | ||
| 240 | "foo bar baz qux")))))) | ||
| 241 | |||
| 139 | ;;; editfns-tests.el ends here | 242 | ;;; editfns-tests.el ends here |
diff --git a/test/src/emacs-module-tests.el b/test/src/emacs-module-tests.el new file mode 100644 index 00000000000..a4994b6223b --- /dev/null +++ b/test/src/emacs-module-tests.el | |||
| @@ -0,0 +1,218 @@ | |||
| 1 | ;;; Test GNU Emacs modules. | ||
| 2 | |||
| 3 | ;; Copyright 2015-2017 Free Software Foundation, Inc. | ||
| 4 | |||
| 5 | ;; This file is part of GNU Emacs. | ||
| 6 | |||
| 7 | ;; GNU Emacs is free software: you can redistribute it and/or modify | ||
| 8 | ;; it under the terms of the GNU General Public License as published by | ||
| 9 | ;; the Free Software Foundation, either version 3 of the License, or | ||
| 10 | ;; (at your option) any later version. | ||
| 11 | |||
| 12 | ;; GNU Emacs is distributed in the hope that it will be useful, | ||
| 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | ;; GNU General Public License for more details. | ||
| 16 | |||
| 17 | ;; You should have received a copy of the GNU General Public License | ||
| 18 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | ||
| 19 | |||
| 20 | (require 'ert) | ||
| 21 | |||
| 22 | (defconst mod-test-emacs | ||
| 23 | (expand-file-name invocation-name invocation-directory) | ||
| 24 | "File name of the Emacs binary currently running.") | ||
| 25 | |||
| 26 | (eval-and-compile | ||
| 27 | (defconst mod-test-file | ||
| 28 | (substitute-in-file-name | ||
| 29 | "$EMACS_TEST_DIRECTORY/data/emacs-module/mod-test") | ||
| 30 | "File name of the module test file.")) | ||
| 31 | |||
| 32 | (require 'mod-test mod-test-file) | ||
| 33 | |||
| 34 | ;; | ||
| 35 | ;; Basic tests. | ||
| 36 | ;; | ||
| 37 | |||
| 38 | (ert-deftest mod-test-sum-test () | ||
| 39 | (should (= (mod-test-sum 1 2) 3)) | ||
| 40 | (let ((descr (should-error (mod-test-sum 1 2 3)))) | ||
| 41 | (should (eq (car descr) 'wrong-number-of-arguments)) | ||
| 42 | (should (module-function-p (nth 1 descr))) | ||
| 43 | (should (eq 0 | ||
| 44 | (string-match | ||
| 45 | (concat "#<module function " | ||
| 46 | "\\(at \\(0x\\)?[0-9a-fA-F]+\\( from .*\\)?" | ||
| 47 | "\\|Fmod_test_sum from .*\\)>") | ||
| 48 | (prin1-to-string (nth 1 descr))))) | ||
| 49 | (should (= (nth 2 descr) 3))) | ||
| 50 | (should-error (mod-test-sum "1" 2) :type 'wrong-type-argument) | ||
| 51 | (should-error (mod-test-sum 1 "2") :type 'wrong-type-argument) | ||
| 52 | ;; The following tests are for 32-bit build --with-wide-int. | ||
| 53 | (should (= (mod-test-sum -1 most-positive-fixnum) | ||
| 54 | (1- most-positive-fixnum))) | ||
| 55 | (should (= (mod-test-sum 1 most-negative-fixnum) | ||
| 56 | (1+ most-negative-fixnum))) | ||
| 57 | (when (< #x1fffffff most-positive-fixnum) | ||
| 58 | (should (= (mod-test-sum 1 #x1fffffff) | ||
| 59 | (1+ #x1fffffff))) | ||
| 60 | (should (= (mod-test-sum -1 #x20000000) | ||
| 61 | #x1fffffff))) | ||
| 62 | (should-error (mod-test-sum 1 most-positive-fixnum) | ||
| 63 | :type 'overflow-error) | ||
| 64 | (should-error (mod-test-sum -1 most-negative-fixnum) | ||
| 65 | :type 'overflow-error)) | ||
| 66 | |||
| 67 | (ert-deftest mod-test-sum-docstring () | ||
| 68 | (should (string= (documentation 'mod-test-sum) "Return A + B\n\n(fn a b)"))) | ||
| 69 | |||
| 70 | (ert-deftest module-function-object () | ||
| 71 | "Extract and test the implementation of a module function. | ||
| 72 | This test needs to be changed whenever the implementation | ||
| 73 | changes." | ||
| 74 | (let ((func (symbol-function #'mod-test-sum))) | ||
| 75 | (should (module-function-p func)) | ||
| 76 | (should (equal (type-of func) 'module-function)) | ||
| 77 | (should (string-match-p | ||
| 78 | (rx bos "#<module function " | ||
| 79 | (or "Fmod_test_sum" | ||
| 80 | (and "at 0x" (+ hex-digit))) | ||
| 81 | (? " from " (* nonl) "mod-test" (* nonl) ) | ||
| 82 | ">" eos) | ||
| 83 | (prin1-to-string func))))) | ||
| 84 | |||
| 85 | ;; | ||
| 86 | ;; Non-local exists (throw, signal). | ||
| 87 | ;; | ||
| 88 | |||
| 89 | (ert-deftest mod-test-non-local-exit-signal-test () | ||
| 90 | (should-error (mod-test-signal)) | ||
| 91 | (let (debugger-args backtrace) | ||
| 92 | (should-error | ||
| 93 | (let ((debugger (lambda (&rest args) | ||
| 94 | (setq debugger-args args | ||
| 95 | backtrace (with-output-to-string (backtrace))) | ||
| 96 | (cl-incf num-nonmacro-input-events))) | ||
| 97 | (debug-on-signal t)) | ||
| 98 | (mod-test-signal))) | ||
| 99 | (should (equal debugger-args '(error (error . 56)))) | ||
| 100 | (should (string-match-p | ||
| 101 | (rx bol " mod-test-signal()" eol) | ||
| 102 | backtrace)))) | ||
| 103 | |||
| 104 | (ert-deftest mod-test-non-local-exit-throw-test () | ||
| 105 | (should (equal | ||
| 106 | (catch 'tag | ||
| 107 | (mod-test-throw) | ||
| 108 | (ert-fail "expected throw")) | ||
| 109 | 65))) | ||
| 110 | |||
| 111 | (ert-deftest mod-test-non-local-exit-funcall-normal () | ||
| 112 | (should (equal (mod-test-non-local-exit-funcall (lambda () 23)) | ||
| 113 | 23))) | ||
| 114 | |||
| 115 | (ert-deftest mod-test-non-local-exit-funcall-signal () | ||
| 116 | (should (equal (mod-test-non-local-exit-funcall | ||
| 117 | (lambda () (signal 'error '(32)))) | ||
| 118 | '(signal error (32))))) | ||
| 119 | |||
| 120 | (ert-deftest mod-test-non-local-exit-funcall-throw () | ||
| 121 | (should (equal (mod-test-non-local-exit-funcall (lambda () (throw 'tag 32))) | ||
| 122 | '(throw tag 32)))) | ||
| 123 | |||
| 124 | ;; | ||
| 125 | ;; String tests. | ||
| 126 | ;; | ||
| 127 | |||
| 128 | (defun multiply-string (s n) | ||
| 129 | (let ((res "")) | ||
| 130 | (dotimes (i n res) | ||
| 131 | (setq res (concat res s))))) | ||
| 132 | |||
| 133 | (ert-deftest mod-test-globref-make-test () | ||
| 134 | (let ((mod-str (mod-test-globref-make)) | ||
| 135 | (ref-str (multiply-string "abcdefghijklmnopqrstuvwxyz" 100))) | ||
| 136 | (garbage-collect) ;; XXX: not enough to really test but it's something.. | ||
| 137 | (should (string= ref-str mod-str)))) | ||
| 138 | |||
| 139 | (ert-deftest mod-test-string-a-to-b-test () | ||
| 140 | (should (string= (mod-test-string-a-to-b "aaa") "bbb"))) | ||
| 141 | |||
| 142 | ;; | ||
| 143 | ;; User-pointer tests. | ||
| 144 | ;; | ||
| 145 | |||
| 146 | (ert-deftest mod-test-userptr-fun-test () | ||
| 147 | (let* ((n 42) | ||
| 148 | (v (mod-test-userptr-make n)) | ||
| 149 | (r (mod-test-userptr-get v))) | ||
| 150 | |||
| 151 | (should (eq (type-of v) 'user-ptr)) | ||
| 152 | (should (integerp r)) | ||
| 153 | (should (= r n)))) | ||
| 154 | |||
| 155 | ;; TODO: try to test finalizer | ||
| 156 | |||
| 157 | ;; | ||
| 158 | ;; Vector tests. | ||
| 159 | ;; | ||
| 160 | |||
| 161 | (ert-deftest mod-test-vector-test () | ||
| 162 | (dolist (s '(2 10 100 1000)) | ||
| 163 | (dolist (e '(42 foo "foo")) | ||
| 164 | (let* ((v-ref (make-vector 2 e)) | ||
| 165 | (eq-ref (eq (aref v-ref 0) (aref v-ref 1))) | ||
| 166 | (v-test (make-vector s nil))) | ||
| 167 | |||
| 168 | (should (eq (mod-test-vector-fill v-test e) t)) | ||
| 169 | (should (eq (mod-test-vector-eq v-test e) eq-ref)))))) | ||
| 170 | |||
| 171 | (ert-deftest module--func-arity () | ||
| 172 | (should (equal (func-arity #'mod-test-return-t) '(1 . 1))) | ||
| 173 | (should (equal (func-arity #'mod-test-sum) '(2 . 2)))) | ||
| 174 | |||
| 175 | (ert-deftest module--help-function-arglist () | ||
| 176 | (should (equal (help-function-arglist #'mod-test-return-t :preserve-names) | ||
| 177 | '(arg1))) | ||
| 178 | (should (equal (help-function-arglist #'mod-test-return-t) | ||
| 179 | '(arg1))) | ||
| 180 | (should (equal (help-function-arglist #'mod-test-sum :preserve-names) | ||
| 181 | '(a b))) | ||
| 182 | (should (equal (help-function-arglist #'mod-test-sum) | ||
| 183 | '(arg1 arg2)))) | ||
| 184 | |||
| 185 | (ert-deftest module--test-assertions () | ||
| 186 | "Check that -module-assertions work." | ||
| 187 | (skip-unless (file-executable-p mod-test-emacs)) | ||
| 188 | ;; This doesn’t yet cause undefined behavior. | ||
| 189 | (should (eq (mod-test-invalid-store) 123)) | ||
| 190 | ;; To contain any core dumps. | ||
| 191 | (let ((tempdir (make-temp-file "emacs-module-test" t))) | ||
| 192 | (unwind-protect | ||
| 193 | (with-temp-buffer | ||
| 194 | (should (string-match-p | ||
| 195 | "Abort" ; eg "Aborted" or "Abort trap: 6" | ||
| 196 | (let ((default-directory tempdir)) | ||
| 197 | (call-process mod-test-emacs nil t nil | ||
| 198 | "-batch" "-Q" "-module-assertions" "-eval" | ||
| 199 | (prin1-to-string | ||
| 200 | `(progn | ||
| 201 | (require 'mod-test ,mod-test-file) | ||
| 202 | ;; Storing and reloading a local | ||
| 203 | ;; value causes undefined behavior, | ||
| 204 | ;; which should be detected by the | ||
| 205 | ;; module assertions. | ||
| 206 | (mod-test-invalid-store) | ||
| 207 | (mod-test-invalid-load))))))) | ||
| 208 | (search-backward "Emacs module assertion:") | ||
| 209 | (should (string-match-p (rx bos "Emacs module assertion: " | ||
| 210 | "Emacs value not found in " | ||
| 211 | (+ digit) " values of " | ||
| 212 | (+ digit) " environments" eos) | ||
| 213 | (buffer-substring-no-properties | ||
| 214 | (line-beginning-position) | ||
| 215 | (line-end-position))))) | ||
| 216 | (delete-directory tempdir t)))) | ||
| 217 | |||
| 218 | ;;; emacs-module-tests.el ends here | ||
diff --git a/test/src/eval-tests.el b/test/src/eval-tests.el index 95655eac826..03f408716b1 100644 --- a/test/src/eval-tests.el +++ b/test/src/eval-tests.el | |||
| @@ -32,6 +32,8 @@ | |||
| 32 | ;; This should not crash. | 32 | ;; This should not crash. |
| 33 | (should-error (funcall '(closure)) :type 'invalid-function)) | 33 | (should-error (funcall '(closure)) :type 'invalid-function)) |
| 34 | 34 | ||
| 35 | (defvar byte-compile-debug) | ||
| 36 | |||
| 35 | (ert-deftest eval-tests--bugs-24912-and-24913 () | 37 | (ert-deftest eval-tests--bugs-24912-and-24913 () |
| 36 | "Checks that Emacs doesn’t accept weird argument lists. | 38 | "Checks that Emacs doesn’t accept weird argument lists. |
| 37 | Bug#24912 and Bug#24913." | 39 | Bug#24912 and Bug#24913." |
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index a1b48a643e1..2e463455f0c 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | ;;; Code: | 22 | ;;; Code: |
| 23 | 23 | ||
| 24 | (require 'cl-lib) | 24 | (require 'cl-lib) |
| 25 | (eval-when-compile (require 'cl)) | ||
| 26 | 25 | ||
| 27 | (ert-deftest fns-tests-reverse () | 26 | (ert-deftest fns-tests-reverse () |
| 28 | (should-error (reverse)) | 27 | (should-error (reverse)) |
diff --git a/test/src/lread-tests.el b/test/src/lread-tests.el index a783afd3128..98cbb6a301d 100644 --- a/test/src/lread-tests.el +++ b/test/src/lread-tests.el | |||
| @@ -112,4 +112,56 @@ | |||
| 112 | (should-error (read "#24r") :type 'invalid-read-syntax) | 112 | (should-error (read "#24r") :type 'invalid-read-syntax) |
| 113 | (should-error (read "#") :type 'invalid-read-syntax)) | 113 | (should-error (read "#") :type 'invalid-read-syntax)) |
| 114 | 114 | ||
| 115 | (ert-deftest lread-record-1 () | ||
| 116 | (should (equal '(#s(foo) #s(foo)) | ||
| 117 | (read "(#1=#s(foo) #1#)")))) | ||
| 118 | |||
| 119 | (defmacro lread-tests--with-temp-file (file-name-var &rest body) | ||
| 120 | (declare (indent 1)) | ||
| 121 | (cl-check-type file-name-var symbol) | ||
| 122 | `(let ((,file-name-var (make-temp-file "emacs"))) | ||
| 123 | (unwind-protect | ||
| 124 | (progn ,@body) | ||
| 125 | (delete-file ,file-name-var)))) | ||
| 126 | |||
| 127 | (defun lread-tests--last-message () | ||
| 128 | (with-current-buffer "*Messages*" | ||
| 129 | (save-excursion | ||
| 130 | (goto-char (point-max)) | ||
| 131 | (skip-chars-backward "\n") | ||
| 132 | (buffer-substring (line-beginning-position) (point))))) | ||
| 133 | |||
| 134 | (ert-deftest lread-tests--unescaped-char-literals () | ||
| 135 | "Check that loading warns about unescaped character | ||
| 136 | literals (Bug#20852)." | ||
| 137 | (lread-tests--with-temp-file file-name | ||
| 138 | (write-region "?) ?( ?; ?\" ?[ ?]" nil file-name) | ||
| 139 | (should (equal (load file-name nil :nomessage :nosuffix) t)) | ||
| 140 | (should (equal (lread-tests--last-message) | ||
| 141 | (concat (format-message "Loading `%s': " file-name) | ||
| 142 | "unescaped character literals " | ||
| 143 | "`?\"', `?(', `?)', `?;', `?[', `?]' detected!"))))) | ||
| 144 | |||
| 145 | (ert-deftest lread-test-bug26837 () | ||
| 146 | "Test for http://debbugs.gnu.org/26837 ." | ||
| 147 | (let ((load-path (cons | ||
| 148 | (file-name-as-directory | ||
| 149 | (expand-file-name "data" (getenv "EMACS_TEST_DIRECTORY"))) | ||
| 150 | load-path))) | ||
| 151 | (load "somelib" nil t) | ||
| 152 | (should (string-suffix-p "/somelib.el" (caar load-history))) | ||
| 153 | (load "somelib2" nil t) | ||
| 154 | (should (string-suffix-p "/somelib2.el" (caar load-history))) | ||
| 155 | (load "somelib" nil t) | ||
| 156 | (should (string-suffix-p "/somelib.el" (caar load-history))))) | ||
| 157 | |||
| 158 | (ert-deftest lread-tests--old-style-backquotes () | ||
| 159 | "Check that loading warns about old-style backquotes." | ||
| 160 | (lread-tests--with-temp-file file-name | ||
| 161 | (write-region "(` (a b))" nil file-name) | ||
| 162 | (should (equal (load file-name nil :nomessage :nosuffix) t)) | ||
| 163 | (should (equal (lread-tests--last-message) | ||
| 164 | (concat (format-message "Loading `%s': " file-name) | ||
| 165 | "old-style backquotes detected!"))))) | ||
| 166 | |||
| 115 | ;;; lread-tests.el ends here | 167 | ;;; lread-tests.el ends here |
diff --git a/test/src/regex-tests.el b/test/src/regex-tests.el index db187fd4a6a..1364bf6848a 100644 --- a/test/src/regex-tests.el +++ b/test/src/regex-tests.el | |||
| @@ -424,7 +424,7 @@ differences in behavior.") | |||
| 424 | (let (failures | 424 | (let (failures |
| 425 | basic icase notbol noteol) | 425 | basic icase notbol noteol) |
| 426 | (regex-tests-generic-line | 426 | (regex-tests-generic-line |
| 427 | ?; "BOOST.tests" regex-tests-BOOST-whitelist | 427 | ?\; "BOOST.tests" regex-tests-BOOST-whitelist |
| 428 | (if (save-excursion (re-search-forward "^-" nil t)) | 428 | (if (save-excursion (re-search-forward "^-" nil t)) |
| 429 | (setq basic (save-excursion (re-search-forward "REG_BASIC" nil t)) | 429 | (setq basic (save-excursion (re-search-forward "REG_BASIC" nil t)) |
| 430 | icase (save-excursion (re-search-forward "REG_ICASE" nil t)) | 430 | icase (save-excursion (re-search-forward "REG_ICASE" nil t)) |
diff --git a/test/src/undo-tests.el b/test/src/undo-tests.el index fbd3bf84a42..0cf7fc9f59c 100644 --- a/test/src/undo-tests.el +++ b/test/src/undo-tests.el | |||
| @@ -444,5 +444,27 @@ Demonstrates bug 16818." | |||
| 444 | (ert-run-tests-interactively "^undo-") | 444 | (ert-run-tests-interactively "^undo-") |
| 445 | (ert-run-tests-batch "^undo-"))) | 445 | (ert-run-tests-batch "^undo-"))) |
| 446 | 446 | ||
| 447 | (ert-deftest undo-test-skip-invalidated-markers () | ||
| 448 | "Test marker adjustment when the marker points nowhere. | ||
| 449 | Demonstrates bug 25599." | ||
| 450 | (with-temp-buffer | ||
| 451 | (buffer-enable-undo) | ||
| 452 | (insert ";; aaaaaaaaa | ||
| 453 | ;; bbbbbbbb") | ||
| 454 | (let ((overlay-modified | ||
| 455 | (lambda (ov after-p _beg _end &optional length) | ||
| 456 | (unless after-p | ||
| 457 | (when (overlay-buffer ov) | ||
| 458 | (delete-overlay ov)))))) | ||
| 459 | (save-excursion | ||
| 460 | (goto-char (point-min)) | ||
| 461 | (let ((ov (make-overlay (line-beginning-position 2) | ||
| 462 | (line-end-position 2)))) | ||
| 463 | (overlay-put ov 'insert-in-front-hooks | ||
| 464 | (list overlay-modified))))) | ||
| 465 | (kill-region (point-min) (line-beginning-position 2)) | ||
| 466 | (undo-boundary) | ||
| 467 | (undo))) | ||
| 468 | |||
| 447 | (provide 'undo-tests) | 469 | (provide 'undo-tests) |
| 448 | ;;; undo-tests.el ends here | 470 | ;;; undo-tests.el ends here |