diff options
| author | Vibhav Pant | 2017-02-15 21:03:05 +0530 |
|---|---|---|
| committer | Vibhav Pant | 2017-02-15 21:12:44 +0530 |
| commit | 96e18ebb99ccd835028b8a12284f89c92cba2e5c (patch) | |
| tree | f38bf7ee48bd48e1f3114078be421e2a2b1807b0 | |
| parent | 1b685e7a0bd0e2ae26e9930075b826c9f40aa848 (diff) | |
| download | emacs-96e18ebb99ccd835028b8a12284f89c92cba2e5c.tar.gz emacs-96e18ebb99ccd835028b8a12284f89c92cba2e5c.zip | |
bytecomp-tests.el: Store all test forms in one constant.
* test/lisp/emacs-lisp/bytecomp-tests.el: Store all test expressions
in a single constant (byte-opt-testsuite-arith-data), add new forms
which generate lapcode with adjacent/redundant tags.
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 47 |
1 files changed, 33 insertions, 14 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index acf9343914d..d0b97907389 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | ;;; Commentary: | 26 | ;;; Commentary: |
| 27 | 27 | ||
| 28 | (require 'ert) | 28 | (require 'ert) |
| 29 | (require 'cl-lib) | ||
| 29 | 30 | ||
| 30 | ;;; Code: | 31 | ;;; Code: |
| 31 | (defconst byte-opt-testsuite-arith-data | 32 | (defconst byte-opt-testsuite-arith-data |
| @@ -242,13 +243,8 @@ | |||
| 242 | (let ((a 3) (b 2) (c 1.0)) (/ 1 a b c)) | 243 | (let ((a 3) (b 2) (c 1.0)) (/ 1 a b c)) |
| 243 | (let ((a 3) (b 2) (c 1.0)) (/ a b c 0)) | 244 | (let ((a 3) (b 2) (c 1.0)) (/ a b c 0)) |
| 244 | (let ((a 3) (b 2) (c 1.0)) (/ a b c 1)) | 245 | (let ((a 3) (b 2) (c 1.0)) (/ a b c 1)) |
| 245 | (let ((a 3) (b 2) (c 1.0)) (/ a b c -1))) | 246 | (let ((a 3) (b 2) (c 1.0)) (/ a b c -1)) |
| 246 | "List of expression for test. | 247 | ;; Test switch bytecode |
| 247 | Each element will be executed by interpreter and with | ||
| 248 | bytecompiled code, and their results compared.") | ||
| 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))) | 248 | (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) | 249 | (let ((a 'three)) (cond ((eq a 'one) 1) ((eq a 2) 'two) ((eq a 'three) 3) |
| 254 | (t t))) | 250 | (t t))) |
| @@ -258,8 +254,36 @@ bytecompiled code, and their results compared.") | |||
| 258 | (let ((a "foobar")) (cond ((equal "notfoobar" a) 'incorrect) | 254 | (let ((a "foobar")) (cond ((equal "notfoobar" a) 'incorrect) |
| 259 | ((equal 1 a) 'incorrect) | 255 | ((equal 1 a) 'incorrect) |
| 260 | ((equal a "foobar") 'correct) | 256 | ((equal a "foobar") 'correct) |
| 261 | (t 'incorrect)))) | 257 | (t 'incorrect))) |
| 262 | "List of expressions for testing byte-switch.") | 258 | (let ((a "foobar") (l t)) (pcase a |
| 259 | ("bar" 'incorrect) | ||
| 260 | ("foobar" (while l | ||
| 261 | a (setq l nil)) | ||
| 262 | 'correct))) | ||
| 263 | (let ((a 'foobar) (l t)) (cl-case a | ||
| 264 | ('foo 'incorrect) | ||
| 265 | ('bar 'incorrect) | ||
| 266 | ('foobar (while l | ||
| 267 | a (setq l nil)) | ||
| 268 | 'correct))) | ||
| 269 | (let ((a 'foobar) (l t)) (cond | ||
| 270 | ((eq a 'bar) 'incorrect) | ||
| 271 | ((eq a 'foo) 'incorrect) | ||
| 272 | ((eq a 'bar) 'incorrect) | ||
| 273 | (t (while l | ||
| 274 | a (setq l nil)) | ||
| 275 | 'correct))) | ||
| 276 | (let ((a 'foobar) (l t)) (cond | ||
| 277 | ((eq a 'bar) 'incorrect) | ||
| 278 | ((eq a 'foo) 'incorrect) | ||
| 279 | ((eq a 'foobar) | ||
| 280 | (while l | ||
| 281 | a (setq l nil)) | ||
| 282 | 'correct) | ||
| 283 | (t 'incorrect)))) | ||
| 284 | "List of expression for test. | ||
| 285 | Each element will be executed by interpreter and with | ||
| 286 | bytecompiled code, and their results compared.") | ||
| 263 | 287 | ||
| 264 | (defun bytecomp-check-1 (pat) | 288 | (defun bytecomp-check-1 (pat) |
| 265 | "Return non-nil if PAT is the same whether directly evalled or compiled." | 289 | "Return non-nil if PAT is the same whether directly evalled or compiled." |
| @@ -290,11 +314,6 @@ bytecompiled code, and their results compared.") | |||
| 290 | (dolist (pat byte-opt-testsuite-arith-data) | 314 | (dolist (pat byte-opt-testsuite-arith-data) |
| 291 | (should (bytecomp-check-1 pat)))) | 315 | (should (bytecomp-check-1 pat)))) |
| 292 | 316 | ||
| 293 | (ert-deftest bytecomp-cond () | ||
| 294 | "Test the Emacs byte compiler." | ||
| 295 | (dolist (pat byte-opt-testsuite-cond-data) | ||
| 296 | (should (bytecomp-check-1 pat)))) | ||
| 297 | |||
| 298 | (defun test-byte-opt-arithmetic (&optional arg) | 317 | (defun test-byte-opt-arithmetic (&optional arg) |
| 299 | "Unit test for byte-opt arithmetic operations. | 318 | "Unit test for byte-opt arithmetic operations. |
| 300 | Subtests signal errors if something goes wrong." | 319 | Subtests signal errors if something goes wrong." |