diff options
| author | Mattias EngdegÄrd | 2019-05-22 12:36:03 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2019-06-19 11:20:59 +0200 |
| commit | 14a81524c27ab54850e0fda736e4ee0c92e447b5 (patch) | |
| tree | 07dae25c695381ab4dc7c5fe70543276b90ace82 /test | |
| parent | b8c74742c0238fe15b1cdc9a7f6ee021d038368f (diff) | |
| download | emacs-14a81524c27ab54850e0fda736e4ee0c92e447b5.tar.gz emacs-14a81524c27ab54850e0fda736e4ee0c92e447b5.zip | |
Compile cond with heterogeneous tests into switch (bug#36139)
Allow any mixture of `eq', `eql' and `equal', `memq', `memql' and
`member' in a switch-like `cond' to be compiled into a single switch.
* lisp/emacs-lisp/bytecomp.el (byte-compile--common-test): New.
(byte-compile-cond-jump-table-info): Use most specific common test.
* test/lisp/emacs-lisp/bytecomp-tests.el (byte-opt-testsuite-arith-data):
Add test cases for multi-value clause cond forms.
Diffstat (limited to 'test')
| -rw-r--r-- | test/lisp/emacs-lisp/bytecomp-tests.el | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/test/lisp/emacs-lisp/bytecomp-tests.el b/test/lisp/emacs-lisp/bytecomp-tests.el index 0c151e39169..0f18a34578d 100644 --- a/test/lisp/emacs-lisp/bytecomp-tests.el +++ b/test/lisp/emacs-lisp/bytecomp-tests.el | |||
| @@ -311,7 +311,30 @@ | |||
| 311 | (let ((x "a")) (cond ((equal x "a") 'correct) | 311 | (let ((x "a")) (cond ((equal x "a") 'correct) |
| 312 | ((equal x "b") 'incorrect) | 312 | ((equal x "b") 'incorrect) |
| 313 | ((equal x "a") 'incorrect) | 313 | ((equal x "a") 'incorrect) |
| 314 | ((equal x "c") 'incorrect)))) | 314 | ((equal x "c") 'incorrect))) |
| 315 | ;; Multi-value clauses | ||
| 316 | (mapcar (lambda (x) (cond ((eq x 'a) 11) | ||
| 317 | ((memq x '(b a c d)) 22) | ||
| 318 | ((eq x 'c) 33) | ||
| 319 | ((eq x 'e) 44) | ||
| 320 | ((memq x '(d f g)) 55) | ||
| 321 | (t 99))) | ||
| 322 | '(a b c d e f g h)) | ||
| 323 | (mapcar (lambda (x) (cond ((eql x 1) 11) | ||
| 324 | ((memq x '(a b c)) 22) | ||
| 325 | ((memql x '(2 1 4 1e-3)) 33) | ||
| 326 | ((eq x 'd) 44) | ||
| 327 | ((eql x #x10000000000000000)))) | ||
| 328 | '(1 2 4 1e-3 a b c d 1.0 #x10000000000000000)) | ||
| 329 | (mapcar (lambda (x) (cond ((eq x 'a) 11) | ||
| 330 | ((memq x '(b d)) 22) | ||
| 331 | ((equal x '(a . b)) 33) | ||
| 332 | ((member x '(b c 1.5 2.5 "X" (d))) 44) | ||
| 333 | ((eql x 3.14) 55) | ||
| 334 | ((memql x '(9 0.5 1.5 q)) 66) | ||
| 335 | (t 99))) | ||
| 336 | '(a b c d (d) (a . b) "X" 0.5 1.5 3.14 9 9.0)) | ||
| 337 | ) | ||
| 315 | "List of expression for test. | 338 | "List of expression for test. |
| 316 | Each element will be executed by interpreter and with | 339 | Each element will be executed by interpreter and with |
| 317 | bytecompiled code, and their results compared.") | 340 | bytecompiled code, and their results compared.") |