Files
rust-mal/tests/arithmetic.mal
teo3300 92e442b93d Redefining most of the arithmetic symbols using lisp
Pfft, I don't need math, I only need -, < and =

Signed-off-by: teo3300 <matteo.rogora@live.it>
2024-01-18 18:37:49 +09:00

43 lines
641 B
Plaintext

; +
(assert (= (+ 1 -4) -3))
(assert (= (+ 1 1) 2))
; -
(assert (= (- 2 1) 1))
(assert (= (- 1 2) -1))
; *
(assert (= (* 2 3) 6))
(assert (= (* -2 3) -6))
(assert (= (* -2 -3) 6))
; /
(assert (= (/ 3 2) 1))
(assert (= (/ 2 3) 0))
(assert (= (/ -10 2) -5))
(assert (= (/ -10 -2) 5))
(assert (not (ok? (/ 12 0))))
; mod
(assert (= (mod 10 4) 2))
(assert (= (mod 4 10) 4))
; >
(assert (> 3 2))
(assert (not (> 1 2)))
(assert (not (> 1 1)))
; <
(assert (< 1 3))
(assert (not (< 3 2)))
(assert (not (< 1 1)))
; >=
(assert (>= 3 1))
(assert (not (>= 1 2)))
(assert (>= 1 1))
; <=
(assert (<= 1 3))
(assert (not (<= 3 2)))
(assert (<= 1 1))