hy/tests/native_tests/math.hy

35 lines
538 B
Hy
Raw Normal View History

2013-03-06 00:39:34 +01:00
; copyright ..
(setv square (fn [x]
2013-03-06 04:15:45 +01:00
(* x x)))
(setv test_basic_math (fn []
2013-03-06 04:15:45 +01:00
"NATIVE: Test basic math."
2013-03-06 03:42:54 +01:00
(assert (= (+ 2 2) 4))))
2013-03-06 04:15:45 +01:00
(setv test_mult (fn []
2013-03-06 04:15:45 +01:00
"NATIVE: Test multiplication."
(assert (= 4 (square 2)))))
(setv test_sub (fn []
2013-03-06 04:15:45 +01:00
"NATIVE: Test subtraction"
(assert (= 4 (- 8 4)))))
(setv test_add (fn []
2013-03-06 04:15:45 +01:00
"NATIVE: Test addition"
(assert (= 4 (+ 1 1 1 1)))))
(setv test_div (fn []
2013-03-06 04:15:45 +01:00
"NATIVE: Test division"
(assert (= 25 (/ 100 2 2)))))
2013-03-19 02:46:58 +01:00
(defn test-modulo []
"NATIVE: test mod"
(assert (= (% 10 2) 0)))