Fix gaka tests
This commit is contained in:
parent
095dd0db99
commit
9220b983c5
4 changed files with 26 additions and 28 deletions
|
|
@ -15,7 +15,7 @@
|
|||
:java-source-paths ["src-java"]
|
||||
:resource-paths ["resources" "sci/resources"]
|
||||
:dependencies [[org.clojure/clojure "1.10.2-alpha2"]
|
||||
[borkdude/edamame "0.0.11-alpha.28"]
|
||||
[borkdude/edamame "0.0.11-alpha.29"]
|
||||
[borkdude/graal.locking "0.0.2"]
|
||||
[org.clojure/tools.cli "1.0.194"]
|
||||
[cheshire "5.10.0"]
|
||||
|
|
|
|||
|
|
@ -243,6 +243,7 @@
|
|||
;; Nothing is marked "private" here, so you can rebind things to plug
|
||||
;; in your own testing or reporting frameworks.
|
||||
|
||||
(def tns (sci/create-ns 'clojure.test nil))
|
||||
|
||||
;;; USER-MODIFIABLE GLOBALS
|
||||
|
||||
|
|
@ -251,28 +252,28 @@
|
|||
be created by deftest, set-test, or with-test. Use this to omit
|
||||
tests when compiling or loading production code."}
|
||||
load-tests
|
||||
(sci/new-dynamic-var '*load-tests* true))
|
||||
(sci/new-dynamic-var '*load-tests* true {:ns tns}))
|
||||
|
||||
(def
|
||||
^{:doc "The maximum depth of stack traces to print when an Exception
|
||||
is thrown during a test. Defaults to nil, which means print the
|
||||
complete stack trace."}
|
||||
stack-trace-depth
|
||||
(sci/new-dynamic-var '*stack-trace-depth* nil))
|
||||
(sci/new-dynamic-var '*stack-trace-depth* nil {:ns tns}))
|
||||
|
||||
|
||||
;;; GLOBALS USED BY THE REPORTING FUNCTIONS
|
||||
|
||||
(def report-counters (sci/new-dynamic-var '*report-counters* nil)) ; bound to a ref of a map in test-ns
|
||||
(def report-counters (sci/new-dynamic-var '*report-counters* nil {:ns tns})) ; bound to a ref of a map in test-ns
|
||||
|
||||
(def initial-report-counters ; used to initialize *report-counters*
|
||||
(sci/new-dynamic-var '*initial-report-counters* {:test 0, :pass 0, :fail 0, :error 0}))
|
||||
(sci/new-dynamic-var '*initial-report-counters* {:test 0, :pass 0, :fail 0, :error 0} {:ns tns}))
|
||||
|
||||
(def testing-vars (sci/new-dynamic-var '*testing-vars* (list))) ; bound to hierarchy of vars being tested
|
||||
(def testing-vars (sci/new-dynamic-var '*testing-vars* (list) {:ns tns})) ; bound to hierarchy of vars being tested
|
||||
|
||||
(def testing-contexts (sci/new-dynamic-var '*testing-contexts* (list))) ; bound to hierarchy of "testing" strings
|
||||
(def testing-contexts (sci/new-dynamic-var '*testing-contexts* (list) {:ns tns})) ; bound to hierarchy of "testing" strings
|
||||
|
||||
(def test-out (sci/new-dynamic-var '*test-out* sci/out)) ; PrintWriter for test reporting output
|
||||
(def test-out (sci/new-dynamic-var '*test-out* sci/out {:ns tns})) ; PrintWriter for test reporting output
|
||||
|
||||
(defmacro with-test-out-internal
|
||||
"Runs body with *out* bound to the value of *test-out*."
|
||||
|
|
@ -324,8 +325,6 @@
|
|||
:added "1.1"}
|
||||
report-impl :type)
|
||||
|
||||
(def tns (sci/create-ns 'clojure.test nil))
|
||||
|
||||
(def report (sci/copy-var report-impl tns))
|
||||
|
||||
(defn do-report
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
(ns babashka.impl.test
|
||||
(:require [babashka.impl.clojure.test :as t]
|
||||
[babashka.impl.common :refer [ctx]]))
|
||||
|
||||
(defn macrofy [v]
|
||||
(with-meta v {:sci/macro true}))
|
||||
[babashka.impl.common :refer [ctx]]
|
||||
[sci.core :as sci]))
|
||||
|
||||
(defn contextualize [f]
|
||||
(fn [& args]
|
||||
(apply f @ctx args)))
|
||||
|
||||
(def tns t/tns)
|
||||
|
||||
(def clojure-test-namespace
|
||||
{'*load-tests* t/load-tests
|
||||
{:obj tns
|
||||
'*load-tests* t/load-tests
|
||||
'*stack-trace-depth* t/stack-trace-depth
|
||||
'*report-counters* t/report-counters
|
||||
'*initial-report-counters* t/initial-report-counters
|
||||
|
|
@ -30,18 +31,16 @@
|
|||
'assert-any t/assert-any
|
||||
;; assertion methods
|
||||
'assert-expr t/assert-expr
|
||||
'try-expr (with-meta @#'t/try-expr
|
||||
{:sci/macro true})
|
||||
'try-expr (sci/copy-var t/try-expr tns)
|
||||
;; assertion macros
|
||||
'is (with-meta @#'t/is
|
||||
{:sci/macro true})
|
||||
'are (macrofy @#'t/are)
|
||||
'testing (macrofy @#'t/testing)
|
||||
'is (sci/copy-var t/is tns)
|
||||
'are (sci/copy-var t/are tns)
|
||||
'testing (sci/copy-var t/testing tns)
|
||||
;; defining tests
|
||||
'with-test (macrofy @#'t/with-test)
|
||||
'deftest (macrofy @#'t/deftest)
|
||||
'deftest- (macrofy @#'t/deftest-)
|
||||
'set-test (macrofy @#'t/set-test)
|
||||
'with-test (sci/copy-var t/with-test tns)
|
||||
'deftest (sci/copy-var t/deftest tns)
|
||||
'deftest- (sci/copy-var t/deftest- tns)
|
||||
'set-test (sci/copy-var t/set-test tns)
|
||||
;; fixtures
|
||||
'use-fixtures t/use-fixtures
|
||||
'compose-fixtures t/compose-fixtures
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
(ns gaka.core-test
|
||||
(:require [clojure.test :refer [deftest is #_are]]
|
||||
(:require [clojure.test :refer [deftest is are]]
|
||||
[gaka.core :refer [css compile* inline-css render-rule]]
|
||||
))
|
||||
|
||||
(defmacro =? [& body]
|
||||
`(clojure.test/are [x# y#] (= x# y#)
|
||||
`(are [x# y#] (= x# y#)
|
||||
~@body))
|
||||
|
||||
(deftest test-flatten
|
||||
|
|
@ -26,7 +26,7 @@
|
|||
(=? (flatten-maps [1 2 {3 4}])
|
||||
[1 2 3 4])
|
||||
|
||||
#_(=? (flatten-maps [1 {2 3 4 5} 6])
|
||||
(=? (flatten-maps [1 {2 3 4 5} 6])
|
||||
[1 2 3 4 5 6])
|
||||
|
||||
(=? (flatten-keyvals [1 '(2 {3 4} 5)])
|
||||
|
|
|
|||
Loading…
Reference in a new issue