From 87accff420dcf4cbe3cabe8f902c3560877fbdb1 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sun, 24 Nov 2019 13:35:34 +0100 Subject: [PATCH] Move assert to sci (#129) --- sci | 2 +- src/babashka/impl/clojure/core.clj | 17 ++--------------- test/babashka/main_test.clj | 2 +- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/sci b/sci index 4ccc3f37..4b4b8f49 160000 --- a/sci +++ b/sci @@ -1 +1 @@ -Subproject commit 4ccc3f37de02c2bc4507f5bfc8da37c946169905 +Subproject commit 4b4b8f49b51c5c471591fe484bdc80a58dc5f8ea diff --git a/src/babashka/impl/clojure/core.clj b/src/babashka/impl/clojure/core.clj index d9f79921..b998ca02 100644 --- a/src/babashka/impl/clojure/core.clj +++ b/src/babashka/impl/clojure/core.clj @@ -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})}) diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 0ec8a670..ed5f8367 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -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)"))))