hy/tests/native_tests/math.hy

35 lines
532 B
Hy
Raw Normal View History

2013-03-06 00:39:34 +01:00
; copyright ..
2013-03-06 04:15:45 +01:00
(def square (fn [x]
(* x x)))
2013-03-06 02:28:09 +01:00
(def 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
(def test_mult (fn []
"NATIVE: Test multiplication."
(assert (= 4 (square 2)))))
(def test_sub (fn []
"NATIVE: Test subtraction"
(assert (= 4 (- 8 4)))))
(def test_add (fn []
"NATIVE: Test addition"
(assert (= 4 (+ 1 1 1 1)))))
(def test_div (fn []
"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)))