Implemented unless, when and dotimes using built-in macros.
[bpt/guile.git] / test-suite / tests / elisp-compiler.test
index b77cbd3..d36f47c 100644 (file)
 
   (pass-if-equal "succeeding if" 1
     (if t 1 2))
-  (pass-if-equal "failing if" 3
-    (if nil
-      1
-      (setq a 2)
-      (setq a (1+ a))
-      a))
+  (pass-if "failing if"
+    (and (= (if nil
+              1
+              (setq a 2) (setq a (1+ a)) a)
+            3)
+         (equal (if nil 1) nil)))
+
+  (pass-if-equal "failing when" nil-value
+    (when nil 1 2 3))
+  (pass-if-equal "succeeding when" 42
+    (progn (setq a 0)
+           (when t (setq a 42) a)))
+
+  (pass-if-equal "failing unless" nil-value
+    (unless t 1 2 3))
+  (pass-if-equal "succeeding unless" 42
+    (progn (setq a 0)
+           (unless nil (setq a 42) a)))
 
   (pass-if-equal "empty cond" nil-value
     (cond))
            (while (<= i 5)
              (setq prod (* i prod))
              (setq i (1+ i)))
-           prod)))
+           prod))
+
+  (pass-if "dotimes"
+    (progn (setq a 0)
+           (setq count 100)
+           (setq b (dotimes (i count)
+                     (setq j (1+ i))
+                     (setq a (+ a j))))
+           (setq c (dotimes (i 10 42) nil))
+           (and (= a 5050) (equal b nil) (= c 42)))))
 
 
 ; Test handling of variables.
   ; TODO: Check for variable-void error
 
   (pass-if-equal "setq and reference" 6
-    (progn (setq a 1
-                 b 2
-                 c 3)
-           (+ a b c))))
+    (progn (setq a 1 b 2 c 3)
+           (+ a b c)))
+
+  (pass-if-equal "setq value" 2
+    (progn (setq a 1 b 2))))
 
 (with-test-prefix/compile "Let and Let*"