aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Corallo2020-07-05 10:23:46 +0100
committerAndrea Corallo2020-07-08 17:29:24 +0100
commitb31b0ebefef3c9ea378342f624ce18a0eb6d30ae (patch)
tree2c6ee1e7435f648256ce9c959725f997e67ae149
parent0b81044e7e7500fcee3f984c1abeaa544118c5ee (diff)
downloademacs-b31b0ebefef3c9ea378342f624ce18a0eb6d30ae.tar.gz
emacs-b31b0ebefef3c9ea378342f624ce18a0eb6d30ae.zip
* Rework some test logic for generality
* test/src/comp-tests.el (comp-tests-make-insn-checker): New function splitting logic from `comp-tests-tco-checker' to have it more general. (comp-tests-tco-checker): Make use of `comp-tests-make-insn-checker'.
-rw-r--r--test/src/comp-tests.el23
1 files changed, 16 insertions, 7 deletions
diff --git a/test/src/comp-tests.el b/test/src/comp-tests.el
index fd1c513d13a..aefb2f0601a 100644
--- a/test/src/comp-tests.el
+++ b/test/src/comp-tests.el
@@ -603,19 +603,28 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
603 'comment) 603 'comment)
604 (comp-tests-mentioned-p-1 x insn))) 604 (comp-tests-mentioned-p-1 x insn)))
605 605
606(defun comp-tests-tco-checker (_) 606(defun comp-tests-make-insn-checker (func-name checker)
607 "Check that inside `comp-tests-tco-f' we have no recursion." 607 "Apply CHECKER to each insn in FUNC-NAME.
608CHECKER should always return nil to have a pass."
608 (should-not 609 (should-not
609 (cl-loop 610 (cl-loop
610 named checker-loop 611 named checker-loop
611 with func-name = (comp-c-func-name 'comp-tests-tco-f "F" t) 612 with func-c-name = (comp-c-func-name func-name "F" t)
612 with f = (gethash func-name (comp-ctxt-funcs-h comp-ctxt)) 613 with f = (gethash func-c-name (comp-ctxt-funcs-h comp-ctxt))
613 for bb being each hash-value of (comp-func-blocks f) 614 for bb being each hash-value of (comp-func-blocks f)
614 do (cl-loop 615 do (cl-loop
615 for insn in (comp-block-insns bb) 616 for insn in (comp-block-insns bb)
616 when (or (comp-tests-mentioned-p 'comp-tests-tco-f insn) 617 when (funcall checker insn)
617 (comp-tests-mentioned-p func-name insn)) 618 do (cl-return-from checker-loop 'mentioned)))))
618 do (cl-return-from checker-loop 'mentioned))))) 619
620(defun comp-tests-tco-checker (_)
621 "Check that inside `comp-tests-tco-f' we have no recursion."
622 (comp-tests-make-insn-checker
623 'comp-tests-tco-f
624 (lambda (insn)
625 (or (comp-tests-mentioned-p 'comp-tests-tco-f insn)
626 (comp-tests-mentioned-p (comp-c-func-name 'comp-tests-tco-f "F" t)
627 insn)))))
619 628
620(ert-deftest comp-tests-tco () 629(ert-deftest comp-tests-tco ()
621 "Check for tail recursion elimination." 630 "Check for tail recursion elimination."