X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=tests%2Fautomated%2Fbyte-compiler-tests.el;h=e4b2520a1a95bcbc3603144b75fab5b9ef94a9fb;hb=104686cdc71bcd70fe8f909023386cd3fce6a62f;hp=87612aef72f0af40251dc5dec62a0b99e2953195;hpb=976b002b16336930724ae22476014583ad022e7d;p=chise%2Fxemacs-chise.git.1 diff --git a/tests/automated/byte-compiler-tests.el b/tests/automated/byte-compiler-tests.el index 87612ae..e4b2520 100644 --- a/tests/automated/byte-compiler-tests.el +++ b/tests/automated/byte-compiler-tests.el @@ -91,3 +91,131 @@ 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)) + +(before-and-after-compile-equal (let ((z 1)) (or (setq z 42)) z)) + +;; byte-after-unbind-ops + +;; byte-constant +;; byte-dup + +;; byte-symbolp +(before-and-after-compile-equal + (let ((x 's)) + (unwind-protect + (symbolp x) + (setq x 1)))) + +;; byte-consp +(before-and-after-compile-equal + (let ((x '(a b))) + (unwind-protect + (consp x) + (setq x 1)))) + +;; byte-stringp +(before-and-after-compile-equal + (let ((x "a")) + (unwind-protect + (stringp x) + (setq x 1)))) + +;; byte-listp +(before-and-after-compile-equal + (let ((x '(a b c))) + (unwind-protect + (listp x) + (setq x 1)))) + +;; byte-numberp +(before-and-after-compile-equal + (let ((x 1)) + (unwind-protect + (numberp x) + (setq x nil)))) + +;; byte-integerp +(before-and-after-compile-equal + (let ((x 1)) + (unwind-protect + (integerp x) + (setq x nil)))) + +;; byte-equal +(before-and-after-compile-equal + (let ((x 'a) + (y 'a)) + (unwind-protect + (eq x y) + (setq x 'c)))) + +;; byte-not +(before-and-after-compile-equal + (let (x) + (unwind-protect + (not x) + (setq x t)))) + +;; byte-cons +(before-and-after-compile-equal + (equal '(1 . 2) + (let ((x 1) + (y 2)) + (unwind-protect + (cons x y) + (setq x t))))) + +;; byte-list1 +(before-and-after-compile-equal + (equal '(1) + (let ((x 1)) + (unwind-protect + (list x) + (setq x t))))) + +;; byte-list2 +(before-and-after-compile-equal + (equal '(1 . 2) + (let ((x 1) + (y 2)) + (unwind-protect + (list x y) + (setq x t))))) + +;; byte-interactive-p + +;; byte-equal +(before-and-after-compile-equal + (let (x y) + (setq x '(1 . 2)) + (setq y '(1 . 2)) + (unwind-protect + (equal x y) + (setq y '(1 . 3)))))