diff options
| author | Vibhav Pant | 2017-02-07 19:35:20 +0530 |
|---|---|---|
| committer | Vibhav Pant | 2017-02-07 19:35:20 +0530 |
| commit | 96c4e367f973626cbab38af55a2c448b7274eeee (patch) | |
| tree | b95fd4223405cacee6710d8658f5ebd742c34301 | |
| parent | c4316a266185c4adbb8d15a04b9552882b3c34a8 (diff) | |
| download | emacs-96c4e367f973626cbab38af55a2c448b7274eeee.tar.gz emacs-96c4e367f973626cbab38af55a2c448b7274eeee.zip | |
Add tests for checking byte-switch code.
* test/lisp/emacs-lisp/bytecomp-tests.el (bytecomp-cond): New test,
test byte-switch bytecode.
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index bc47c82c1e1..2233b28d331 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -247,6 +247,15 @@ | |||
| 247 | Each element will be executed by interpreter and with | 247 | Each element will be executed by interpreter and with |
| 248 | bytecompiled code, and their results compared.") | 248 | bytecompiled code, and their results compared.") |
| 249 | 249 | ||
| 250 | (defconst byte-opt-testsuite-cond-data | ||
| 251 | '( | ||
| 252 | (let ((a 3)) (cond ((eq a 1) 'one) ((eq a 2) 'two) ((eq a 3) 'three) (t t))) | ||
| 253 | (let ((a 'three)) (cond ((eq a 'one) 1) ((eq a 2) 'two) ((eq a 'three) 3) | ||
| 254 | (t t))) | ||
| 255 | (let ((a 2)) (cond ((eq a 'one) 1) ((eq a 1) 'one) ((eq a 2) 'two) | ||
| 256 | (t nil)))) | ||
| 257 | "List of expressions for testing byte-switch.") | ||
| 258 | |||
| 250 | (defun bytecomp-check-1 (pat) | 259 | (defun bytecomp-check-1 (pat) |
| 251 | "Return non-nil if PAT is the same whether directly evalled or compiled." | 260 | "Return non-nil if PAT is the same whether directly evalled or compiled." |
| 252 | (let ((warning-minimum-log-level :emergency) | 261 | (let ((warning-minimum-log-level :emergency) |
| @@ -276,6 +285,11 @@ bytecompiled code, and their results compared.") | |||
| 276 | (dolist (pat byte-opt-testsuite-arith-data) | 285 | (dolist (pat byte-opt-testsuite-arith-data) |
| 277 | (should (bytecomp-check-1 pat)))) | 286 | (should (bytecomp-check-1 pat)))) |
| 278 | 287 | ||
| 288 | (ert-deftest bytecomp-cond () | ||
| 289 | "Test the Emacs byte compiler." | ||
| 290 | (dolist (pat byte-opt-testsuite-cond-data) | ||
| 291 | (should (bytecomp-check-1 pat)))) | ||
| 292 | |||
| 279 | (defun test-byte-opt-arithmetic (&optional arg) | 293 | (defun test-byte-opt-arithmetic (&optional arg) |
| 280 | "Unit test for byte-opt arithmetic operations. | 294 | "Unit test for byte-opt arithmetic operations. |
| 281 | Subtests signal errors if something goes wrong." | 295 | Subtests signal errors if something goes wrong." |