Carp/test/tuples.carp
2020-05-24 11:49:27 +02:00

38 lines
1.3 KiB
Plaintext

(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")
)