1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-30 07:03:02 +00:00

Fix bug in compiler

This commit is contained in:
Calvin Rose
2017-06-25 19:17:54 -04:00
parent 1f8b671488
commit d6967a564d
2 changed files with 18 additions and 15 deletions

View File

@@ -1,8 +1,19 @@
(do
(: assert (fn [x e] (if x x (do (print e) (exit 1)))))
(print "Running basic tests...")
(def assert (fn [x e] (if x (do (write stdout ".") x) (do (print e) (exit 1)))))
(assert (= 10 (+ 1 2 3 4)) "addition")
(assert (= -8 (- 1 2 3 4)) "subtraction")
(assert (= 24 (* 1 2 3 4)) "multiplication")
(assert (= 0.1 (/ 1.0 10)) "division")
(exit 0)
)
(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")
(print)
(exit 0)