mirror of
https://github.com/carp-lang/Carp.git
synced 2024-11-04 01:25:04 +03:00
cfb61847cb
fixes #335 - add new Int.positive-mod function - use it for Map and Set operations - add tests
71 lines
1.8 KiB
Plaintext
71 lines
1.8 KiB
Plaintext
(load "Test.carp")
|
|
|
|
(use-all Int Test)
|
|
|
|
(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)
|
|
"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")
|
|
)
|