diff options
| author | Stephen Gildea | 2018-07-31 22:34:35 -0700 |
|---|---|---|
| committer | Stephen Gildea | 2018-07-31 22:34:35 -0700 |
| commit | 1804fece02691798394c9e9bd519cd4a53776018 (patch) | |
| tree | 9d5d441db29404f04417332be3507ba968eec42f /test/src | |
| parent | 17205d361795eaaa8e09ae62875c7439bb57a078 (diff) | |
| parent | 82d6416a28dc5b4ab65b8081f035679bec4e3604 (diff) | |
| download | emacs-1804fece02691798394c9e9bd519cd4a53776018.tar.gz emacs-1804fece02691798394c9e9bd519cd4a53776018.zip | |
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
Diffstat (limited to 'test/src')
| -rw-r--r-- | test/src/editfns-tests.el | 10 | ||||
| -rw-r--r-- | test/src/fns-tests.el | 11 | ||||
| -rw-r--r-- | test/src/thread-tests.el | 34 |
3 files changed, 44 insertions, 11 deletions
diff --git a/test/src/editfns-tests.el b/test/src/editfns-tests.el index c828000bb4f..2951270dbf7 100644 --- a/test/src/editfns-tests.el +++ b/test/src/editfns-tests.el | |||
| @@ -165,10 +165,12 @@ | |||
| 165 | :type 'overflow-error) | 165 | :type 'overflow-error) |
| 166 | (should-error (read (substring (format "%d" most-negative-fixnum) 1)) | 166 | (should-error (read (substring (format "%d" most-negative-fixnum) 1)) |
| 167 | :type 'overflow-error) | 167 | :type 'overflow-error) |
| 168 | (should-error (read (format "#x%x" most-negative-fixnum)) | 168 | (let ((binary-as-unsigned nil)) |
| 169 | :type 'overflow-error) | 169 | (dolist (fmt '("%d" "%s" "#o%o" "#x%x")) |
| 170 | (should-error (read (format "#o%o" most-negative-fixnum)) | 170 | (dolist (val (list most-negative-fixnum (1+ most-negative-fixnum) |
| 171 | :type 'overflow-error) | 171 | -1 0 1 |
| 172 | (1- most-positive-fixnum) most-positive-fixnum)) | ||
| 173 | (should (eq val (read (format fmt val))))))) | ||
| 172 | (should-error (read (format "#32rG%x" most-positive-fixnum)) | 174 | (should-error (read (format "#32rG%x" most-positive-fixnum)) |
| 173 | :type 'overflow-error)) | 175 | :type 'overflow-error)) |
| 174 | 176 | ||
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index d9cca557cf2..e4b9cbe25a4 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -23,6 +23,17 @@ | |||
| 23 | 23 | ||
| 24 | (require 'cl-lib) | 24 | (require 'cl-lib) |
| 25 | 25 | ||
| 26 | ;; Test that equality predicates work correctly on NaNs when combined | ||
| 27 | ;; with hash tables based on those predicates. This was not the case | ||
| 28 | ;; for eql in Emacs 26. | ||
| 29 | (ert-deftest fns-tests-equality-nan () | ||
| 30 | (dolist (test (list #'eq #'eql #'equal)) | ||
| 31 | (let* ((h (make-hash-table :test test)) | ||
| 32 | (nan 0.0e+NaN) | ||
| 33 | (-nan (- nan))) | ||
| 34 | (puthash nan t h) | ||
| 35 | (should (eq (funcall test nan -nan) (gethash -nan h)))))) | ||
| 36 | |||
| 26 | (ert-deftest fns-tests-reverse () | 37 | (ert-deftest fns-tests-reverse () |
| 27 | (should-error (reverse)) | 38 | (should-error (reverse)) |
| 28 | (should-error (reverse 1)) | 39 | (should-error (reverse 1)) |
diff --git a/test/src/thread-tests.el b/test/src/thread-tests.el index a00a9c84bd6..364f6d61f05 100644 --- a/test/src/thread-tests.el +++ b/test/src/thread-tests.el | |||
| @@ -34,10 +34,11 @@ | |||
| 34 | (declare-function thread--blocker "thread.c" (thread)) | 34 | (declare-function thread--blocker "thread.c" (thread)) |
| 35 | (declare-function thread-alive-p "thread.c" (thread)) | 35 | (declare-function thread-alive-p "thread.c" (thread)) |
| 36 | (declare-function thread-join "thread.c" (thread)) | 36 | (declare-function thread-join "thread.c" (thread)) |
| 37 | (declare-function thread-last-error "thread.c" ()) | 37 | (declare-function thread-last-error "thread.c" (&optional cleanup)) |
| 38 | (declare-function thread-name "thread.c" (thread)) | 38 | (declare-function thread-name "thread.c" (thread)) |
| 39 | (declare-function thread-signal "thread.c" (thread error-symbol data)) | 39 | (declare-function thread-signal "thread.c" (thread error-symbol data)) |
| 40 | (declare-function thread-yield "thread.c" ()) | 40 | (declare-function thread-yield "thread.c" ()) |
| 41 | (defvar main-thread) | ||
| 41 | 42 | ||
| 42 | (ert-deftest threads-is-one () | 43 | (ert-deftest threads-is-one () |
| 43 | "Test for existence of a thread." | 44 | "Test for existence of a thread." |
| @@ -71,6 +72,11 @@ | |||
| 71 | (skip-unless (featurep 'threads)) | 72 | (skip-unless (featurep 'threads)) |
| 72 | (should (listp (all-threads)))) | 73 | (should (listp (all-threads)))) |
| 73 | 74 | ||
| 75 | (ert-deftest threads-main-thread () | ||
| 76 | "Simple test for all-threads." | ||
| 77 | (skip-unless (featurep 'threads)) | ||
| 78 | (should (eq main-thread (car (all-threads))))) | ||
| 79 | |||
| 74 | (defvar threads-test-global nil) | 80 | (defvar threads-test-global nil) |
| 75 | 81 | ||
| 76 | (defun threads-test-thread1 () | 82 | (defun threads-test-thread1 () |
| @@ -94,15 +100,24 @@ | |||
| 94 | (progn | 100 | (progn |
| 95 | (setq threads-test-global nil) | 101 | (setq threads-test-global nil) |
| 96 | (let ((thread (make-thread #'threads-test-thread1))) | 102 | (let ((thread (make-thread #'threads-test-thread1))) |
| 97 | (thread-join thread) | 103 | (and (= (thread-join thread) 23) |
| 98 | (and threads-test-global | 104 | (= threads-test-global 23) |
| 99 | (not (thread-alive-p thread))))))) | 105 | (not (thread-alive-p thread))))))) |
| 100 | 106 | ||
| 101 | (ert-deftest threads-join-self () | 107 | (ert-deftest threads-join-self () |
| 102 | "Cannot `thread-join' the current thread." | 108 | "Cannot `thread-join' the current thread." |
| 103 | (skip-unless (featurep 'threads)) | 109 | (skip-unless (featurep 'threads)) |
| 104 | (should-error (thread-join (current-thread)))) | 110 | (should-error (thread-join (current-thread)))) |
| 105 | 111 | ||
| 112 | (ert-deftest threads-join-error () | ||
| 113 | "Test of error signalling from `thread-join'." | ||
| 114 | :tags '(:unstable) | ||
| 115 | (skip-unless (featurep 'threads)) | ||
| 116 | (let ((thread (make-thread #'threads-call-error))) | ||
| 117 | (while (thread-alive-p thread) | ||
| 118 | (thread-yield)) | ||
| 119 | (should-error (thread-join thread)))) | ||
| 120 | |||
| 106 | (defvar threads-test-binding nil) | 121 | (defvar threads-test-binding nil) |
| 107 | 122 | ||
| 108 | (defun threads-test-thread2 () | 123 | (defun threads-test-thread2 () |
| @@ -191,7 +206,7 @@ | |||
| 191 | (ert-deftest threads-mutex-signal () | 206 | (ert-deftest threads-mutex-signal () |
| 192 | "Test signaling a blocked thread." | 207 | "Test signaling a blocked thread." |
| 193 | (skip-unless (featurep 'threads)) | 208 | (skip-unless (featurep 'threads)) |
| 194 | (should | 209 | (should-error |
| 195 | (progn | 210 | (progn |
| 196 | (setq threads-mutex (make-mutex)) | 211 | (setq threads-mutex (make-mutex)) |
| 197 | (setq threads-mutex-key nil) | 212 | (setq threads-mutex-key nil) |
| @@ -200,8 +215,10 @@ | |||
| 200 | (while (not threads-mutex-key) | 215 | (while (not threads-mutex-key) |
| 201 | (thread-yield)) | 216 | (thread-yield)) |
| 202 | (thread-signal thr 'quit nil) | 217 | (thread-signal thr 'quit nil) |
| 203 | (thread-join thr)) | 218 | ;; `quit' is not catched by `should-error'. We must indicate it. |
| 204 | t))) | 219 | (condition-case nil |
| 220 | (thread-join thr) | ||
| 221 | (quit (signal 'error nil))))))) | ||
| 205 | 222 | ||
| 206 | (defun threads-test-io-switch () | 223 | (defun threads-test-io-switch () |
| 207 | (setq threads-test-global 23)) | 224 | (setq threads-test-global 23)) |
| @@ -275,6 +292,9 @@ | |||
| 275 | (thread-yield)) | 292 | (thread-yield)) |
| 276 | (should (equal (thread-last-error) | 293 | (should (equal (thread-last-error) |
| 277 | '(error "Error is called"))) | 294 | '(error "Error is called"))) |
| 295 | (should (equal (thread-last-error 'cleanup) | ||
| 296 | '(error "Error is called"))) | ||
| 297 | (should-not (thread-last-error)) | ||
| 278 | (setq th2 (make-thread #'threads-custom "threads-custom")) | 298 | (setq th2 (make-thread #'threads-custom "threads-custom")) |
| 279 | (should (threadp th2)))) | 299 | (should (threadp th2)))) |
| 280 | 300 | ||