]> git.eshelyaron.com Git - emacs.git/commitdiff
* Add a test targeting forward propagation
authorAndrea Corallo <akrl@sdf.org>
Sun, 5 Jul 2020 10:11:11 +0000 (11:11 +0100)
committerAndrea Corallo <akrl@sdf.org>
Thu, 9 Jul 2020 15:22:37 +0000 (16:22 +0100)
* test/src/comp-tests.el (comp-tests-fw-prop-checker-1): New
function.
(comp-tests-fw-prop): New test.

test/src/comp-tests.el

index aefb2f0601a6fa2f0be1e870f0060f4763b9c995..332facb4cf9ae25830d2aab82462be27d96b0c53 100644 (file)
@@ -640,4 +640,26 @@ CHECKER should always return nil to have a pass."
     (should (subr-native-elisp-p (symbol-function #'comp-tests-tco-f)))
     (should (= (comp-tests-tco-f 1 0 10) 55))))
 
+(defun comp-tests-fw-prop-checker-1 (_)
+  "Check that inside `comp-tests-fw-prop-f' `concat' and `length' are folded."
+  (comp-tests-make-insn-checker
+   'comp-tests-fw-prop-1-f
+   (lambda (insn)
+     (or (comp-tests-mentioned-p 'concat insn)
+         (comp-tests-mentioned-p 'length insn)))))
+
+(ert-deftest comp-tests-fw-prop ()
+  "Some tests for forward propagation."
+  (let ((comp-speed 2)
+        (comp-post-pass-hooks '((comp-final comp-tests-fw-prop-checker-1))))
+    (eval '(defun comp-tests-fw-prop-1-f ()
+             (let* ((a "xxx")
+                   (b "yyy")
+                   (c (concat a b))) ; <= has to optimize
+               (length c))) ; <= has to optimize
+          t)
+    (load (native-compile #'comp-tests-fw-prop-1-f))
+    (should (subr-native-elisp-p (symbol-function #'comp-tests-fw-prop-1-f)))
+    (should (= (comp-tests-fw-prop-1-f) 6))))
+
 ;;; comp-tests.el ends here