1
0
mirror of https://github.com/janet-lang/janet synced 2024-10-01 00:10:40 +00:00
janet/gsttests/basic.gst

29 lines
626 B
Plaintext
Raw Normal View History

2017-06-25 23:17:54 +00:00
(print "Running basic tests...")
2017-06-25 23:29:38 +00:00
(var numTestsPassed 0)
(def assert (fn [x e]
(if x
(do
(print " \e[32m✔\e[0m" e)
(varset numTestsPassed (+ 1 numTestsPassed)) x)
(do
(print e)
(exit 1)))))
2017-06-25 23:17:54 +00:00
2017-06-20 03:01:34 +00:00
(assert (= 10 (+ 1 2 3 4)) "addition")
(assert (= -8 (- 1 2 3 4)) "subtraction")
(assert (= 24 (* 1 2 3 4)) "multiplication")
2017-06-25 23:17:54 +00:00
(assert (= 4 (blshift 1 2)) "left shift")
(assert (= 1 (brshift 4 2)) "right shift")
(var accum 1)
(var count 0)
(while (< count 16)
(varset accum (blshift accum 1))
(varset count (+ 1 count)))
(assert (= accum 65536) "loop")
2017-06-25 23:29:38 +00:00
(print "All" numTestsPassed "tests passed")
2017-06-25 23:17:54 +00:00
(exit 0)