X-Git-Url: http://git.chise.org/gitweb/?p=chise%2Fxemacs-chise.git.1;a=blobdiff_plain;f=tests%2Fautomated%2Fbyte-compiler-tests.el;h=21c110f8eac20667abf48a6afc3bc0a7320e6235;hp=87612aef72f0af40251dc5dec62a0b99e2953195;hb=46f51e794ddb493a8a76ec2f3be00b41e3b0be22;hpb=976b002b16336930724ae22476014583ad022e7d diff --git a/tests/automated/byte-compiler-tests.el b/tests/automated/byte-compiler-tests.el index 87612ae..21c110f 100644 --- a/tests/automated/byte-compiler-tests.el +++ b/tests/automated/byte-compiler-tests.el @@ -91,3 +91,30 @@ error "`let' bindings can have only one value-form" (eval '(let* ((x 1 2)) 3))) +(defmacro before-and-after-compile-equal (&rest form) + `(Assert (equal (funcall (quote (lambda () ,@form))) + (funcall (byte-compile (quote (lambda () ,@form))))))) + +(defvar simplyamarker (point-min-marker)) + +;; The byte optimizer must be careful with +/- with a single argument. + +(before-and-after-compile-equal (+)) +(before-and-after-compile-equal (+ 2 2)) +(before-and-after-compile-equal (+ 2 1)) +(before-and-after-compile-equal (+ 1 2)) +;; (+ 1) is OK. but (+1) signals an error. +(before-and-after-compile-equal (+ 1)) +(before-and-after-compile-equal (+ 3)) +(before-and-after-compile-equal (+ simplyamarker 1)) +;; The optimization (+ m) --> m is invalid when m is a marker. +;; Currently the following test fails - controversial. +;; (before-and-after-compile-equal (+ simplyamarker)) +;; Same tests for minus. +(before-and-after-compile-equal (- 2 2)) +(before-and-after-compile-equal (- 2 1)) +(before-and-after-compile-equal (- 1 2)) +(before-and-after-compile-equal (- 1)) +(before-and-after-compile-equal (- 3)) +(before-and-after-compile-equal (- simplyamarker 1)) +(before-and-after-compile-equal (- simplyamarker))