diff options
| author | Andrea Corallo | 2024-07-10 23:50:18 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2024-07-11 16:26:49 +0200 |
| commit | dc8cde2b6f3e7c55a85439c771284df2b4fa0e37 (patch) | |
| tree | 49454c034513a224d6bc2758160dcd2c3d055fa9 /test/src/comp-tests.el | |
| parent | ffaf1cb235c8b399cd9fb704f9b5879db2f5d6a6 (diff) | |
| download | emacs-dc8cde2b6f3e7c55a85439c771284df2b4fa0e37.tar.gz emacs-dc8cde2b6f3e7c55a85439c771284df2b4fa0e37.zip | |
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.
Diffstat (limited to 'test/src/comp-tests.el')
| -rw-r--r-- | test/src/comp-tests.el | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el index bab5a358290..dfeeaff05d8 100644 --- a/test/src/comp-tests.el +++ b/test/src/comp-tests.el | |||
| @@ -1570,4 +1570,28 @@ folded." | |||
| 1570 | (comp-deftest comp-tests-result-lambda () | 1570 | (comp-deftest comp-tests-result-lambda () |
| 1571 | (native-compile 'comp-tests-result-lambda) | 1571 | (native-compile 'comp-tests-result-lambda) |
| 1572 | (should (eq (funcall (comp-tests-result-lambda) '(a . b)) 'a))) | 1572 | (should (eq (funcall (comp-tests-result-lambda) '(a . b)) 'a))) |
| 1573 | |||
| 1574 | (defun comp-tests-type-branch-optim-checker (_) | ||
| 1575 | "Check there's only a single call to `type-of'." | ||
| 1576 | (should (= (cl-count t (comp-tests-map-checker | ||
| 1577 | #'comp-tests-type-branch-optim-1-f | ||
| 1578 | (lambda (insn) | ||
| 1579 | (pcase insn | ||
| 1580 | (`(set ,_mvar-1 (call type-of ,_mvar-2)) | ||
| 1581 | t))))) | ||
| 1582 | 1))) | ||
| 1583 | |||
| 1584 | (declare-function comp-tests-type-branch-optim-1-f nil) | ||
| 1585 | |||
| 1586 | (comp-deftest comp-tests-type-branch-optim () | ||
| 1587 | (let ((native-comp-speed 2) | ||
| 1588 | (comp-post-pass-hooks '((comp--final comp-tests-type-branch-optim-checker)))) | ||
| 1589 | (eval '(progn | ||
| 1590 | (cl-defstruct type-branch-optim-struct a b c) | ||
| 1591 | (defun comp-tests-type-branch-optim-1-f (x) | ||
| 1592 | (setf (type-branch-optim-struct-a x) 3) | ||
| 1593 | (+ (type-branch-optim-struct-b x) (type-branch-optim-struct-c x)))) | ||
| 1594 | t) | ||
| 1595 | (native-compile #'comp-tests-type-branch-optim-1-f))) | ||
| 1596 | |||
| 1573 | ;;; comp-tests.el ends here | 1597 | ;;; comp-tests.el ends here |