Move assert to sci (#129)
This commit is contained in:
parent
717c36bba9
commit
87accff420
3 changed files with 4 additions and 17 deletions
2
sci
2
sci
|
|
@ -1 +1 @@
|
|||
Subproject commit 4ccc3f37de02c2bc4507f5bfc8da37c946169905
|
||||
Subproject commit 4b4b8f49b51c5c471591fe484bdc80a58dc5f8ea
|
||||
|
|
@ -21,17 +21,6 @@
|
|||
:else (throw (IllegalArgumentException.
|
||||
"with-open only allows Symbols in bindings"))))
|
||||
|
||||
(defn __assertion-error__ [^String m]
|
||||
(AssertionError. m))
|
||||
|
||||
(defn assert*
|
||||
([_ _ x]
|
||||
`(when-not ~x
|
||||
(throw (~'__assertion-error__ (str "Assert failed: " (pr-str '~x))))))
|
||||
([_ _ x message]
|
||||
`(when-not ~x
|
||||
(throw (~'__assertion-error__ (str "Assert failed: " ~message "\n" (pr-str '~x)))))))
|
||||
|
||||
(defn binding*
|
||||
"This macro only works with symbols that evaluate to vars themselves. See `*in*` and `*out*` below."
|
||||
[_ _ bindings & body]
|
||||
|
|
@ -91,8 +80,6 @@
|
|||
'flush flush
|
||||
'read-line read-line
|
||||
'__close!__ __close!__
|
||||
'with-open (with-meta with-open* {:sci/macro true})
|
||||
'with-open (with-meta with-open* {:sci/macro true})
|
||||
'with-out-str (with-meta with-out-str* {:sci/macro true})
|
||||
'with-in-str (with-meta with-in-str* {:sci/macro true})
|
||||
'__assertion-error__ __assertion-error__
|
||||
'assert (with-meta assert* {:sci/macro true})})
|
||||
'with-in-str (with-meta with-in-str* {:sci/macro true})})
|
||||
|
|
|
|||
|
|
@ -238,7 +238,7 @@
|
|||
["Infant" "15238"] ["Newborn" "10050"] ["In Utero" "1198"])
|
||||
(bb nil (.getPath (io/file "test" "babashka" "scripts" "csv.bb"))))))
|
||||
|
||||
(deftest assert-test
|
||||
(deftest assert-test ;; assert was first implemented in bb but moved to sci later
|
||||
(is (thrown-with-msg? Exception #"should-be-true"
|
||||
(bb nil "(def should-be-true false) (assert should-be-true)"))))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue