egison-3.9.4: test/lib/core/base.egi
;;
;; Matchers
;;
(assert "bool's value pattern"
(match [#t #f] [bool bool]
{[[,#t ,#f] #t]
[_ #f]}))
(assert "char's value pattern"
(match c#a char
{[,c#a #t]
[_ #f]}))
(assert "integer's value pattern"
(match 10 integer
{[,10 #t]
[_ #f]}))
(assert "float's value pattern"
(match 0.1 float
{[,0.1 #t]
[_ #f]}))
;;
;; Utility
;;
(assert-equal "id"
(id 1)
1)
(assert-equal "fst"
(fst [1 2])
1)
(assert-equal "snd"
(snd [1 2])
2)
(assert-equal "compose - case 1"
((compose fst snd) [[1 2] 3])
2)
(assert-equal "compose - case 2"
((compose fst snd fst) [[1 [2 3]] 4])
2)
; (assert-equal "ref"
; (ref (| 1 2 3 |) 2)
; 2)
(assert-equal "eq?/m"
(eq?/m integer 1 1)
#t)
;;
;; Booleans
;;
(assert-equal "and"
[(and #t #t) (and #t #f) (and #f #t) (and #f #f)]
[#t #f #f #f])
(assert-equal "or"
[(or #t #t) (or #t #f) (or #f #t) (or #f #f)]
[#t #t #t #f])
(assert-equal "not"
[(not #t) (not #f)]
[#f #t])