2013-03-06 00:39:34 +01:00
|
|
|
; copyright ..
|
|
|
|
|
|
|
|
|
2013-04-01 23:51:28 +02:00
|
|
|
(setv square (fn [x]
|
2013-03-06 04:15:45 +01:00
|
|
|
(* x x)))
|
|
|
|
|
|
|
|
|
2013-04-01 23:51:28 +02:00
|
|
|
(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
|
|
|
|
|
|
|
|
2013-04-01 23:51:28 +02:00
|
|
|
(setv test_mult (fn []
|
2013-03-06 04:15:45 +01:00
|
|
|
"NATIVE: Test multiplication."
|
|
|
|
(assert (= 4 (square 2)))))
|
|
|
|
|
|
|
|
|
2013-04-01 23:51:28 +02:00
|
|
|
(setv test_sub (fn []
|
2013-03-06 04:15:45 +01:00
|
|
|
"NATIVE: Test subtraction"
|
|
|
|
(assert (= 4 (- 8 4)))))
|
|
|
|
|
|
|
|
|
2013-04-01 23:51:28 +02:00
|
|
|
(setv test_add (fn []
|
2013-03-06 04:15:45 +01:00
|
|
|
"NATIVE: Test addition"
|
|
|
|
(assert (= 4 (+ 1 1 1 1)))))
|
|
|
|
|
|
|
|
|
2013-04-01 23:51:28 +02:00
|
|
|
(setv test_div (fn []
|
2013-03-06 04:15:45 +01:00
|
|
|
"NATIVE: Test division"
|
2013-04-12 05:23:25 +02:00
|
|
|
(assert (= 25 (/ 100 2 2)))
|
|
|
|
; Commented out until float constants get implemented
|
|
|
|
; (assert (= 0.5 (/ 1 2)))
|
|
|
|
(assert (= 1 (* 2 (/ 1 2))))))
|
2013-03-19 02:46:58 +01:00
|
|
|
|
2013-04-11 10:09:15 +02:00
|
|
|
(setv test_int_div (fn []
|
|
|
|
"NATIVE: Test integer division"
|
|
|
|
(assert (= 25 (// 101 2 2)))))
|
|
|
|
|
2013-03-19 02:46:58 +01:00
|
|
|
(defn test-modulo []
|
|
|
|
"NATIVE: test mod"
|
|
|
|
(assert (= (% 10 2) 0)))
|