1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-17 14:14:49 +00:00

Improve assert-no-error test helper.

This commit is contained in:
Calvin Rose 2023-10-08 17:34:50 -05:00
parent 990f6352e0
commit a775a89e01

View File

@ -34,8 +34,11 @@
(defmacro assert-no-error
[msg & forms]
(def errsym (keyword (gensym)))
~(assert (not= ,errsym (try (do ,;forms) ([_] ,errsym))) ,msg))
(def e (gensym))
(def f (gensym))
(if is-verbose
~(try (do ,;forms (,assert true ,msg)) ([,e ,f] (,assert false ,msg) (,debug/stacktrace ,f ,e "\e[31m✘\e[0m ")))
~(try (do ,;forms (,assert true ,msg)) ([_] (,assert false ,msg)))))
(defn start-suite [&opt x]
(default x (dyn :current-file))