aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVibhav Pant2017-02-07 19:35:20 +0530
committerVibhav Pant2017-02-07 19:35:20 +0530
commit96c4e367f973626cbab38af55a2c448b7274eeee (patch)
treeb95fd4223405cacee6710d8658f5ebd742c34301
parentc4316a266185c4adbb8d15a04b9552882b3c34a8 (diff)
downloademacs-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.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 @@
247Each element will be executed by interpreter and with 247Each element will be executed by interpreter and with
248bytecompiled code, and their results compared.") 248bytecompiled 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.
281Subtests signal errors if something goes wrong." 295Subtests signal errors if something goes wrong."