reloading between tests in clj/c modes
also "defstate"'s "defonce" is now "def"
This commit is contained in:
parent
2697494268
commit
b07b29f028
4 changed files with 75 additions and 15 deletions
|
|
@ -133,7 +133,7 @@
|
||||||
suspend (assoc :suspend `(fn [] ~suspend))
|
suspend (assoc :suspend `(fn [] ~suspend))
|
||||||
resume (assoc :resume `(fn [] ~resume)))]
|
resume (assoc :resume `(fn [] ~resume)))]
|
||||||
`(do
|
`(do
|
||||||
(defonce ~state (DerefableState. ~state-name))
|
(def ~state (DerefableState. ~state-name))
|
||||||
(update-meta! [~state-name] (assoc ~s-meta :inst (atom (NotStartedState. ~state-name))
|
(update-meta! [~state-name] (assoc ~s-meta :inst (atom (NotStartedState. ~state-name))
|
||||||
:var (var ~state)))
|
:var (var ~state)))
|
||||||
(var ~state)))))
|
(var ~state)))))
|
||||||
|
|
|
||||||
58
test/check/deref/fun_with_values_test.clj
Normal file
58
test/check/deref/fun_with_values_test.clj
Normal file
|
|
@ -0,0 +1,58 @@
|
||||||
|
(ns check.deref.fun-with-values-test
|
||||||
|
(:require [mount.core :as mount :refer [defstate]]
|
||||||
|
[clojure.test :refer :all]))
|
||||||
|
|
||||||
|
(defn f [n]
|
||||||
|
(fn [m]
|
||||||
|
(+ n m)))
|
||||||
|
|
||||||
|
(defn g [a b]
|
||||||
|
(+ a b))
|
||||||
|
|
||||||
|
(defn- pf [n]
|
||||||
|
(+ 41 n))
|
||||||
|
|
||||||
|
(defn fna []
|
||||||
|
42)
|
||||||
|
|
||||||
|
(defstate scalar :start 42)
|
||||||
|
(defstate fun :start #(inc 41))
|
||||||
|
(defstate with-fun :start (inc 41))
|
||||||
|
(defstate with-partial :start (partial g 41))
|
||||||
|
(defstate f-in-f :start (f 41))
|
||||||
|
(defstate f-no-args-value :start (fna))
|
||||||
|
(defstate f-no-args :start fna)
|
||||||
|
(defstate f-args :start g)
|
||||||
|
(defstate f-value :start (g 41 1))
|
||||||
|
(defstate private-f :start pf)
|
||||||
|
|
||||||
|
(defn with-fun-and-values [f]
|
||||||
|
(mount/in-cljc-mode)
|
||||||
|
(require :reload 'check.deref.fun-with-values-test)
|
||||||
|
(mount/start #'check.deref.fun-with-values-test/scalar
|
||||||
|
#'check.deref.fun-with-values-test/fun
|
||||||
|
#'check.deref.fun-with-values-test/with-fun
|
||||||
|
#'check.deref.fun-with-values-test/with-partial
|
||||||
|
#'check.deref.fun-with-values-test/f-in-f
|
||||||
|
#'check.deref.fun-with-values-test/f-args
|
||||||
|
#'check.deref.fun-with-values-test/f-no-args-value
|
||||||
|
#'check.deref.fun-with-values-test/f-no-args
|
||||||
|
#'check.deref.fun-with-values-test/private-f
|
||||||
|
#'check.deref.fun-with-values-test/f-value)
|
||||||
|
(f)
|
||||||
|
(mount/stop)
|
||||||
|
(mount/in-clj-mode))
|
||||||
|
|
||||||
|
(use-fixtures :each with-fun-and-values)
|
||||||
|
|
||||||
|
(deftest fun-with-values
|
||||||
|
(is (= @scalar 42))
|
||||||
|
(is (= (@fun) 42))
|
||||||
|
(is (= @with-fun 42))
|
||||||
|
(is (= (@with-partial 1) 42))
|
||||||
|
(is (= (@f-in-f 1) 42))
|
||||||
|
(is (= @f-no-args-value 42))
|
||||||
|
(is (= (@f-no-args) 42))
|
||||||
|
(is (= (@f-args 41 1) 42))
|
||||||
|
(is (= (@private-f 1) 42))
|
||||||
|
(is (= @f-value 42)))
|
||||||
16
test/check/deref/private_fun_test.clj
Normal file
16
test/check/deref/private_fun_test.clj
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
(ns check.deref.private-fun-test
|
||||||
|
(:require [mount.core :as mount :refer [defstate]]
|
||||||
|
[check.deref.fun-with-values-test :refer [private-f]]
|
||||||
|
[clojure.test :refer :all]))
|
||||||
|
|
||||||
|
(defn with-fun-and-values [f]
|
||||||
|
(mount/in-cljc-mode)
|
||||||
|
(mount/start #'check.deref.fun-with-values-test/private-f)
|
||||||
|
(f)
|
||||||
|
(mount/stop)
|
||||||
|
(mount/in-clj-mode))
|
||||||
|
|
||||||
|
(use-fixtures :each with-fun-and-values)
|
||||||
|
|
||||||
|
(deftest fun-with-valuesj
|
||||||
|
(is (= (@private-f 1) 42)))
|
||||||
|
|
@ -53,17 +53,3 @@
|
||||||
(is (= (f-args 41 1) 42))
|
(is (= (f-args 41 1) 42))
|
||||||
(is (= (private-f 1) 42))
|
(is (= (private-f 1) 42))
|
||||||
(is (= f-value 42)))
|
(is (= f-value 42)))
|
||||||
|
|
||||||
(deftest deref-fun-with-values
|
|
||||||
(mount/in-cljc-mode)
|
|
||||||
(is (= @scalar 42))
|
|
||||||
(is (= (@fun) 42))
|
|
||||||
(is (= @with-fun 42))
|
|
||||||
(is (= (@with-partial 1) 42))
|
|
||||||
(is (= (@f-in-f 1) 42))
|
|
||||||
(is (= @f-no-args-value 42))
|
|
||||||
(is (= (@f-no-args) 42))
|
|
||||||
(is (= (@f-args 41 1) 42))
|
|
||||||
(is (= (@private-f 1) 42))
|
|
||||||
(is (= @f-value 42))
|
|
||||||
(mount/in-clj-mode))
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue