aboutsummaryrefslogtreecommitdiffstats
path: root/csc/loop-test.csc
diff options
context:
space:
mode:
Diffstat (limited to 'csc/loop-test.csc')
-rw-r--r--csc/loop-test.csc30
1 files changed, 30 insertions, 0 deletions
diff --git a/csc/loop-test.csc b/csc/loop-test.csc
index eb9345b..e7341c6 100644
--- a/csc/loop-test.csc
+++ b/csc/loop-test.csc
@@ -20,6 +20,13 @@
collect (+ 1 x))))
+(test loop-collect-nothing
+ (assert-equal
+ '()
+ (loop for x in '()
+ collect x)))
+
+
(test loop-for-arithmetic
(assert-equal
'(1 2 3 4 5)
@@ -207,6 +214,13 @@
maximize x)))
+(test loop-maximize-none
+ (assert-equal
+ 0
+ (loop for x in '()
+ maximize x)))
+
+
(test loop-minimize
(assert-equal
1
@@ -214,6 +228,13 @@
minimize x)))
+(test loop-minimize-none
+ (assert-equal
+ 0
+ (loop for x in '()
+ minimize x)))
+
+
(test loop-if
(assert-equal
5
@@ -251,3 +272,12 @@
5
(loop for x from 0
if (>= x 5) return x end)))
+
+
+(test loop-collect-advanced
+ (assert-equal
+ '(fred bob ken sue alice joe kris sunshine june)
+ (loop for name in '(fred sue alice joe june)
+ for kids in '((bob ken) () () (kris sunshine) ())
+ collect name
+ append kids)))