forked from carp-lang/Carp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tuples.carp
37 lines (35 loc) · 1.3 KB
/
tuples.carp
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
(load "core/Tuples.carp") ;; specified path to avoid loading itself on case insensitive file systems
(load "Test.carp")
(use Test)
(deftest test
(assert-true test
(< (Pair.init 1 2) (Pair.init 2 2))
"comparison works I")
(assert-true test
(< (Pair.init 2 1) (Pair.init 2 2))
"comparison works II")
(assert-true test
(< (Pair.init 1 100) (Pair.init 2 2))
"comparison works III")
(assert-false test
(< (Pair.init 1 100) (Pair.init 1 100))
"comparison works IV")
(assert-true test
(< &(Pair.init @"a" 2) &(Pair.init @"b" 1))
"comparison works with (Ref (Pair String Int)) I")
(assert-false test
(< &(Pair.init @"a" 2) &(Pair.init @"a" 1))
"comparison works with (Ref (Pair String Int)) II")
(assert-ref-equal test
(Pair.init 2 @"a")
(Pair.reverse &(Pair.init @"a" 2))
"reverse works")
(assert-ref-equal test
(Pair.init 0 @"")
(Pair.zero)
"zero works")
(assert-ref-equal test
(Pair.init @"" [1])
(Pair.init-from-refs "" &[1])
"init-from-refs works")
)