Make clojure.test/test-var dynamic

This commit is contained in:
Michiel Borkent 2020-06-17 13:50:47 +02:00
parent d0939de548
commit b6a517b979
2 changed files with 6 additions and 7 deletions

View file

@ -1,7 +1,6 @@
(ns babashka.impl.test (ns babashka.impl.test
(:require [babashka.impl.clojure.test :as t] (:require [babashka.impl.clojure.test :as t]
[sci.core :as sci] [sci.core :as sci]))
#_[sci.impl.namespaces :refer [copy-var]]))
(def tns (sci/create-ns 'clojure.test nil)) (def tns (sci/create-ns 'clojure.test nil))
@ -24,8 +23,7 @@
'testing-vars-str t/testing-vars-str 'testing-vars-str t/testing-vars-str
'testing-contexts-str t/testing-contexts-str 'testing-contexts-str t/testing-contexts-str
'inc-report-counter t/inc-report-counter 'inc-report-counter t/inc-report-counter
'report (sci/new-dynamic-var 'report t/report (assoc (meta t/report) 'report (sci/copy-var t/report tns)
:ns tns))
'do-report t/do-report 'do-report t/do-report
;; assertion utilities ;; assertion utilities
'function? t/function? 'function? t/function?
@ -51,7 +49,7 @@
'compose-fixtures t/compose-fixtures 'compose-fixtures t/compose-fixtures
'join-fixtures t/join-fixtures 'join-fixtures t/join-fixtures
;; running tests: low level ;; running tests: low level
'test-var t/test-var 'test-var (sci/copy-var t/test-var tns)
'test-vars t/test-vars 'test-vars t/test-vars
'test-all-vars (with-meta t/test-all-vars {:sci.impl/op :needs-ctx}) 'test-all-vars (with-meta t/test-all-vars {:sci.impl/op :needs-ctx})
'test-ns (with-meta t/test-ns {:sci.impl/op :needs-ctx}) 'test-ns (with-meta t/test-ns {:sci.impl/op :needs-ctx})

View file

@ -70,5 +70,6 @@
(is (str/includes? (bb (.getPath (io/file "test-resources" "babashka" "assert_expr.clj"))) (is (str/includes? (bb (.getPath (io/file "test-resources" "babashka" "assert_expr.clj")))
"3.14 should be roughly 3.141592653589793"))) "3.14 should be roughly 3.141592653589793")))
(deftest rebind-report-test (deftest rebind-vars-test
(is (bb "(binding [clojure.test/report (constantly true)] nil)"))) (is (bb "(binding [clojure.test/report (constantly true)] nil)"))
(is (bb "(binding [clojure.test/test-var (constantly true)] nil)")))