mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 02:20:21 -08:00
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.
This commit is contained in:
parent
1b685e7a0b
commit
96e18ebb99
1 changed files with 33 additions and 14 deletions
|
|
@ -26,6 +26,7 @@
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
(require 'ert)
|
(require 'ert)
|
||||||
|
(require 'cl-lib)
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(defconst byte-opt-testsuite-arith-data
|
(defconst byte-opt-testsuite-arith-data
|
||||||
|
|
@ -242,13 +243,8 @@
|
||||||
(let ((a 3) (b 2) (c 1.0)) (/ 1 a b c))
|
(let ((a 3) (b 2) (c 1.0)) (/ 1 a b c))
|
||||||
(let ((a 3) (b 2) (c 1.0)) (/ a b c 0))
|
(let ((a 3) (b 2) (c 1.0)) (/ a b c 0))
|
||||||
(let ((a 3) (b 2) (c 1.0)) (/ a b c 1))
|
(let ((a 3) (b 2) (c 1.0)) (/ a b c 1))
|
||||||
(let ((a 3) (b 2) (c 1.0)) (/ a b c -1)))
|
(let ((a 3) (b 2) (c 1.0)) (/ a b c -1))
|
||||||
"List of expression for test.
|
;; Test switch bytecode
|
||||||
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 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)
|
(let ((a 'three)) (cond ((eq a 'one) 1) ((eq a 2) 'two) ((eq a 'three) 3)
|
||||||
(t t)))
|
(t t)))
|
||||||
|
|
@ -258,8 +254,36 @@ bytecompiled code, and their results compared.")
|
||||||
(let ((a "foobar")) (cond ((equal "notfoobar" a) 'incorrect)
|
(let ((a "foobar")) (cond ((equal "notfoobar" a) 'incorrect)
|
||||||
((equal 1 a) 'incorrect)
|
((equal 1 a) 'incorrect)
|
||||||
((equal a "foobar") 'correct)
|
((equal a "foobar") 'correct)
|
||||||
|
(t 'incorrect)))
|
||||||
|
(let ((a "foobar") (l t)) (pcase a
|
||||||
|
("bar" 'incorrect)
|
||||||
|
("foobar" (while l
|
||||||
|
a (setq l nil))
|
||||||
|
'correct)))
|
||||||
|
(let ((a 'foobar) (l t)) (cl-case a
|
||||||
|
('foo 'incorrect)
|
||||||
|
('bar 'incorrect)
|
||||||
|
('foobar (while l
|
||||||
|
a (setq l nil))
|
||||||
|
'correct)))
|
||||||
|
(let ((a 'foobar) (l t)) (cond
|
||||||
|
((eq a 'bar) 'incorrect)
|
||||||
|
((eq a 'foo) 'incorrect)
|
||||||
|
((eq a 'bar) 'incorrect)
|
||||||
|
(t (while l
|
||||||
|
a (setq l nil))
|
||||||
|
'correct)))
|
||||||
|
(let ((a 'foobar) (l t)) (cond
|
||||||
|
((eq a 'bar) 'incorrect)
|
||||||
|
((eq a 'foo) 'incorrect)
|
||||||
|
((eq a 'foobar)
|
||||||
|
(while l
|
||||||
|
a (setq l nil))
|
||||||
|
'correct)
|
||||||
(t 'incorrect))))
|
(t 'incorrect))))
|
||||||
"List of expressions for testing byte-switch.")
|
"List of expression for test.
|
||||||
|
Each element will be executed by interpreter and with
|
||||||
|
bytecompiled code, and their results compared.")
|
||||||
|
|
||||||
(defun bytecomp-check-1 (pat)
|
(defun bytecomp-check-1 (pat)
|
||||||
"Return non-nil if PAT is the same whether directly evalled or compiled."
|
"Return non-nil if PAT is the same whether directly evalled or compiled."
|
||||||
|
|
@ -290,11 +314,6 @@ bytecompiled code, and their results compared.")
|
||||||
(dolist (pat byte-opt-testsuite-arith-data)
|
(dolist (pat byte-opt-testsuite-arith-data)
|
||||||
(should (bytecomp-check-1 pat))))
|
(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)
|
(defun test-byte-opt-arithmetic (&optional arg)
|
||||||
"Unit test for byte-opt arithmetic operations.
|
"Unit test for byte-opt arithmetic operations.
|
||||||
Subtests signal errors if something goes wrong."
|
Subtests signal errors if something goes wrong."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue