This repository has been archived by the owner on Jan 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
048control.test
74 lines (62 loc) · 1.7 KB
/
048control.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
(test "iflet works with :satisfies"
:valueof (iflet x (+ 2 3) :satisfies odd?
x+1)
:should be 6)
(test "iflet works with multiple branches"
:valueof (iflet x nil
x
(+ 2 3) :satisfies odd?
x+1)
:should be 6)
(test "iflet works with multiple :satisfies"
:valueof (iflet x nil :satisfies id
x
(+ 2 3) :satisfies odd?
x+1)
:should be 6)
(test "aand works"
:valueof (let x list.3
(aand x (car.it < 4)))
:should be_true)
(test "while works"
:valueof (ret ans nil
(let x 0
(while (x < 3)
(ans <- (cons x ans))
(x <- x+1))))
:should be '(2 1 0))
(test "whilet works"
:valueof (ret ans nil
(let x '(1 2 3)
(whilet y (zap! cdr x)
(ans <- car.y))))
:should be 3)
(test "whilet destructures like let"
:valueof (ret ans nil
(let x '(1 2 3)
(whilet (y ... _) (zap! cdr x)
(ans <- y))))
:should be 3)
(test "for works"
:valueof (ret ans nil
(for x 0 (x < 3) (x <- x+1)
(ans <- (cons x ans))))
:should be '(2 1 0))
mac (fooset x)
`(,x <- 4)
(test "& works with macros"
:valueof (ret x 3
(fooset&fooset x))
:should be 4)
(test "pipe operator works"
:valueof (3 -> (fn(_) (_ * 2)))
:should be 6)
(test "pipe operator chains"
:valueof (list.1 -> cons? -> car)
:should be 1)
(test "pipe turns exprs containing _ into fns"
:valueof (3 -> _+1)
:should be 4)
(test "transform is varargs pipe"
:valueof (transform list.1 :thru cons? car)
:should be 1)