update.
[chise/xemacs-chise.git.1] / tests / automated / byte-compiler-tests.el
index efd7bf5..e4b2520 100644 (file)
@@ -22,7 +22,7 @@
 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 ;; 02111-1307, USA.
 
-;;; Synched up with: not in FSF Emacs.
+;;; Synched up with: Not in FSF.
 
 ;;; Commentary:
 
  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)))))