summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVibhav Pant <vibhavp@gmail.com>2017-02-07 19:35:20 +0530
committerVibhav Pant <vibhavp@gmail.com>2017-02-07 19:35:20 +0530
commit96c4e367f973626cbab38af55a2c448b7274eeee (patch)
treeb95fd4223405cacee6710d8658f5ebd742c34301
parentc4316a266185c4adbb8d15a04b9552882b3c34a8 (diff)
downloademacs-96c4e367f973626cbab38af55a2c448b7274eeee.tar.gz
emacs-96c4e367f973626cbab38af55a2c448b7274eeee.tar.bz2
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.el14
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 @@
Each element will be executed by interpreter and with
bytecompiled code, and their results compared.")
+(defconst byte-opt-testsuite-cond-data
+ '(
+ (let ((a 3)) (cond ((eq a 1) 'one) ((eq a 2) 'two) ((eq a 3) 'three) (t t)))
+ (let ((a 'three)) (cond ((eq a 'one) 1) ((eq a 2) 'two) ((eq a 'three) 3)
+ (t t)))
+ (let ((a 2)) (cond ((eq a 'one) 1) ((eq a 1) 'one) ((eq a 2) 'two)
+ (t nil))))
+ "List of expressions for testing byte-switch.")
+
(defun bytecomp-check-1 (pat)
"Return non-nil if PAT is the same whether directly evalled or compiled."
(let ((warning-minimum-log-level :emergency)
@@ -276,6 +285,11 @@ bytecompiled code, and their results compared.")
(dolist (pat byte-opt-testsuite-arith-data)
(should (bytecomp-check-1 pat))))
+(ert-deftest bytecomp-cond ()
+ "Test the Emacs byte compiler."
+ (dolist (pat byte-opt-testsuite-cond-data)
+ (should (bytecomp-check-1 pat))))
+
(defun test-byte-opt-arithmetic (&optional arg)
"Unit test for byte-opt arithmetic operations.
Subtests signal errors if something goes wrong."