1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-17 03:21:51 -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:
Andrea Corallo 2024-07-10 23:50:18 +02:00
parent ffaf1cb235
commit dc8cde2b6f

View file

@ -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