1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-19 09:47:40 +00:00
This adds several common patterns, which are defined in
boot.janet. This essentially gives more primitive patterns
to work with out of the box.

Fix build when JANET_REDUCED_OS is defined.
This commit is contained in:
Calvin Rose
2019-12-14 20:39:14 -06:00
parent bc8ee207d5
commit f1afc5b0b4
8 changed files with 88 additions and 39 deletions

View File

@@ -4,22 +4,23 @@
(var num-tests-run 0)
(var suite-num 0)
(var numchecks 0)
(var start-time 0)
(defn assert [x e]
(++ num-tests-run)
(when x (++ num-tests-passed))
(if x
(do
(when (= numchecks 25)
(set numchecks 0)
(print))
(++ numchecks)
(file/write stdout "\e[32m✔\e[0m"))
(do
(file/write stdout "\n\e[31m✘\e[0m ")
(set numchecks 0)
(print e)))
x)
(++ num-tests-run)
(when x (++ num-tests-passed))
(if x
(do
(when (= numchecks 25)
(set numchecks 0)
(print))
(++ numchecks)
(file/write stdout "\e[32m✔\e[0m"))
(do
(file/write stdout "\n\e[31m✘\e[0m ")
(set numchecks 0)
(print e)))
x)
(defmacro assert-error
[msg & forms]
@@ -32,10 +33,12 @@
~(assert (not= ,errsym (try (do ,;forms) ([_] ,errsym))) ,msg))
(defn start-suite [x]
(set suite-num x)
(print "\nRunning test suite " x " tests...\n "))
(set suite-num x)
(set start-time (os/clock))
(print "\nRunning test suite " x " tests...\n "))
(defn end-suite []
(print "\n\nTest suite " suite-num " finished.")
(print num-tests-passed " of " num-tests-run " tests passed.\n")
(if (not= num-tests-passed num-tests-run) (os/exit 1)))
(def delta (- (os/clock) start-time))
(printf "\n\nTest suite %d finished in %.3f seconds" suite-num delta)
(print num-tests-passed " of " num-tests-run " tests passed.\n")
(if (not= num-tests-passed num-tests-run) (os/exit 1)))