mirror of
https://github.com/janet-lang/janet
synced 2024-12-26 00:10:27 +00:00
Fix = should have been ==. Add some tests for vm type asserts.
This commit is contained in:
parent
d5bab72620
commit
67f26b7d72
@ -503,7 +503,7 @@ JanetBuffer *janet_pretty(JanetBuffer *buffer, int depth, Janet x) {
|
||||
|
||||
static const char *typestr(Janet x) {
|
||||
JanetType t = janet_type(x);
|
||||
return (t = JANET_ABSTRACT)
|
||||
return (t == JANET_ABSTRACT)
|
||||
? janet_abstract_type(janet_unwrap_abstract(x))->name
|
||||
: janet_type_names[t];
|
||||
}
|
||||
|
@ -21,6 +21,11 @@
|
||||
(print e)))
|
||||
x)
|
||||
|
||||
(defmacro assert-error
|
||||
[msg & forms]
|
||||
(def errsym (keyword (gensym)))
|
||||
~(assert (= ,errsym (try (do ,;forms) ([_] ,errsym))) ,msg))
|
||||
|
||||
(defn start-suite [x]
|
||||
(set suite-num x)
|
||||
(print "\nRunning test suite " x " tests...\n "))
|
||||
|
@ -122,4 +122,11 @@
|
||||
(def spot (make-dog "spot"))
|
||||
(assert (= "spot says hi!" (:bark spot "hi")) "oo 2")
|
||||
|
||||
# Negative tests
|
||||
|
||||
(assert-error "+ check types" (+ 1 ()))
|
||||
(assert-error "- check types" (- 1 ()))
|
||||
(assert-error "* check types" (* 1 ()))
|
||||
(assert-error "/ check types" (/ 1 ()))
|
||||
|
||||
(end-suite)
|
||||
|
Loading…
Reference in New Issue
Block a user