2017-11-21 14:01:31 +03:00
|
|
|
(load "Test.carp")
|
|
|
|
|
2017-12-12 17:08:33 +03:00
|
|
|
(use-all Int Test)
|
2017-11-17 14:26:01 +03:00
|
|
|
|
2018-11-07 18:11:38 +03:00
|
|
|
(deftest test
|
|
|
|
(assert-equal test
|
|
|
|
1
|
|
|
|
(min 1 2)
|
|
|
|
"min works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
2
|
|
|
|
(max 1 2)
|
|
|
|
"max works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
1
|
|
|
|
(abs -1)
|
|
|
|
"abs works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
false
|
|
|
|
(even? 3)
|
|
|
|
"even? works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
true
|
|
|
|
(odd? 3)
|
|
|
|
"odd? works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
1
|
|
|
|
(bit-and 3 5)
|
|
|
|
"bit-and works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
5
|
|
|
|
(bit-or 1 4)
|
|
|
|
"bit-or works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
4
|
|
|
|
(bit-xor 1 5)
|
|
|
|
"bit-xor works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
-2
|
|
|
|
(bit-not 1)
|
|
|
|
"bit-not works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
8
|
|
|
|
(bit-shift-left 2 2)
|
|
|
|
"bit-shift-left works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
2
|
|
|
|
(bit-shift-right 16 3)
|
|
|
|
"bit-shift-right works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
-2
|
|
|
|
(neg 2)
|
|
|
|
"neg works as expected")
|
|
|
|
(assert-equal test
|
|
|
|
2
|
|
|
|
(neg -2)
|
|
|
|
"neg works as expected II")
|
|
|
|
(assert-equal test
|
|
|
|
1
|
|
|
|
(/ 3 2)
|
2018-12-01 12:05:11 +03:00
|
|
|
"integer division truncates as expected")
|
|
|
|
(assert-equal test
|
|
|
|
3
|
|
|
|
(positive-mod -7 5)
|
|
|
|
"positive-mod works on negative inputs")
|
|
|
|
(assert-equal test
|
|
|
|
0
|
|
|
|
(positive-mod 0 7)
|
|
|
|
"positive-mod works on zero")
|
|
|
|
)
|