Minilisp.pm/t/math.t

33 lines
761 B
Perl
Raw Permalink Normal View History

2021-04-09 00:01:27 +02:00
(plan 16)
2021-04-04 01:53:30 +02:00
(expect "+ - 3 parameters" (= (+ 2 4 2) 8))
(expect "- - 3 parameters" (= (- 8 2 3) 3))
(expect "* - 2 parameters" (= (* 5 6) 30))
(expect "/ - 2 parameters" (= (/ 64 4) 16))
2021-04-02 19:03:37 +02:00
2021-04-04 01:53:30 +02:00
(expect "evenp - 2" (evenp 2))
(expect "evenp - 3" (not (evenp 3)))
2021-04-02 19:03:37 +02:00
2021-04-04 01:53:30 +02:00
(expect "oddp - 5" (oddp 5))
(expect "oddp - 6" (not (oddp 6)))
2021-04-02 19:03:37 +02:00
2021-04-04 01:53:30 +02:00
(expect "zerop - 0" (zerop 0))
(expect "zerop - 1" (not (zerop 1)))
2021-04-02 19:03:37 +02:00
2021-04-04 01:53:30 +02:00
(expect "max - 2 parameters" (= (max 5 30) 30))
(expect "min - 2 parameters" (= (min 5 30) 5))
2021-04-05 03:53:44 +02:00
(comment (mod -1 5))
(expect "mod - (mod -1 5) == 4"
(= (mod -1 5) 4))
(expect "mod - (mod 13 4) == 1"
(= (mod 13 4) 1))
(expect "mod - (mod 13.5 1) == 0.5"
(= (mod 13.5 1) 0.5))
(expect "mod - (mod -13.5 1) == 0.5"
(= (mod -13.5 1) 0.5))