Move assert to sci (#129)

This commit is contained in:
Michiel Borkent 2019-11-24 13:35:34 +01:00 committed by GitHub
parent 717c36bba9
commit 87accff420
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 17 deletions

2
sci

@ -1 +1 @@
Subproject commit 4ccc3f37de02c2bc4507f5bfc8da37c946169905
Subproject commit 4b4b8f49b51c5c471591fe484bdc80a58dc5f8ea

View file

@ -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})})

View file

@ -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)"))))