mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-17 11:32:59 -07:00
Add a type-check--optim test
* test/src/comp-tests.el (comp-tests-type-branch-optim-checker): New function. (comp-tests-type-branch-optim): Add new test.
This commit is contained in:
parent
ffaf1cb235
commit
dc8cde2b6f
1 changed files with 24 additions and 0 deletions
|
|
@ -1570,4 +1570,28 @@ folded."
|
|||
(comp-deftest comp-tests-result-lambda ()
|
||||
(native-compile 'comp-tests-result-lambda)
|
||||
(should (eq (funcall (comp-tests-result-lambda) '(a . b)) 'a)))
|
||||
|
||||
(defun comp-tests-type-branch-optim-checker (_)
|
||||
"Check there's only a single call to `type-of'."
|
||||
(should (= (cl-count t (comp-tests-map-checker
|
||||
#'comp-tests-type-branch-optim-1-f
|
||||
(lambda (insn)
|
||||
(pcase insn
|
||||
(`(set ,_mvar-1 (call type-of ,_mvar-2))
|
||||
t)))))
|
||||
1)))
|
||||
|
||||
(declare-function comp-tests-type-branch-optim-1-f nil)
|
||||
|
||||
(comp-deftest comp-tests-type-branch-optim ()
|
||||
(let ((native-comp-speed 2)
|
||||
(comp-post-pass-hooks '((comp--final comp-tests-type-branch-optim-checker))))
|
||||
(eval '(progn
|
||||
(cl-defstruct type-branch-optim-struct a b c)
|
||||
(defun comp-tests-type-branch-optim-1-f (x)
|
||||
(setf (type-branch-optim-struct-a x) 3)
|
||||
(+ (type-branch-optim-struct-b x) (type-branch-optim-struct-c x))))
|
||||
t)
|
||||
(native-compile #'comp-tests-type-branch-optim-1-f)))
|
||||
|
||||
;;; comp-tests.el ends here
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue