diff --git a/.gitignore b/.gitignore index 45cf3f2..4e92365 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ pom.xml pom.xml.asc .repl* -dev-resources/public/js/* +dev/resources/public/js/* figwheel_server.log *.jar *.class diff --git a/project.clj b/project.clj index 898a5ba..f68866f 100644 --- a/project.clj +++ b/project.clj @@ -9,7 +9,7 @@ :dependencies [[org.clojure/clojure "1.7.0"] [org.clojure/clojurescript "1.7.170"]] - :profiles {:dev {:source-paths ["dev" "dev/clj" "test/clj"] + :profiles {:dev {:source-paths ["dev" "dev/clj" "test"] :dependencies [[datascript "0.13.3"] [hiccups "0.3.0"] [com.andrewmcveigh/cljs-time "0.3.14"] @@ -21,6 +21,7 @@ [com.datomic/datomic-free "0.9.5327" :exclusions [joda-time]]] :plugins [[lein-cljsbuild "1.1.1"] + [lein-doo "0.1.6"] [lein-figwheel "0.5.0-2"]] :clean-targets ^{:protect false} [:target-path @@ -28,7 +29,7 @@ [:cljsbuild :builds :prod :compiler :output-to]] :cljsbuild { :builds {:dev - {:source-paths ["dev/cljs" "test/cljs"] + {:source-paths ["src" "dev/cljs"] :figwheel true :compiler {:main app.example @@ -38,6 +39,15 @@ :optimizations :none :source-map true :source-map-timestamp true}} + :test + {:source-paths ["src" "dev/cljs" "test"] + :compiler {:main mount.test + ;; :asset-path "js/compiled/out" + :output-to "dev/resources/public/js/compiled/mount.js" + :output-dir "dev/resources/public/js/compiled/test" + :optimizations :none + :source-map true + :source-map-timestamp true}} :prod {:source-paths ["src" "test"] :compiler {:output-to "dev/resources/public/js/compiled/mount.js" diff --git a/test/clj/mount/cleanup_dirty_states_test.clj b/test/clj/mount/cleanup_dirty_states_test.clj deleted file mode 100644 index 2d62575..0000000 --- a/test/clj/mount/cleanup_dirty_states_test.clj +++ /dev/null @@ -1,13 +0,0 @@ -(ns mount.cleanup_dirty_states_test - (:require [mount.core :as mount] - [app.example] - [clojure.test :refer :all])) - -(deftest cleanup-dirty-states - (let [_ (mount/start)] - (is (not (.isClosed (:server-socket app.example/nrepl)))) - (require 'app.example :reload) - (mount/start) ;; should not result in "BindException Address already in use" since the clean up will stop the previous instance - (is (not (.isClosed (:server-socket app.example/nrepl)))) - (mount/stop) - (is (instance? mount.core.NotStartedState app.example/nrepl)))) diff --git a/test/clj/mount/deref/fun_with_values_test.clj b/test/clj/mount/deref/fun_with_values_test.clj deleted file mode 100644 index eeb3883..0000000 --- a/test/clj/mount/deref/fun_with_values_test.clj +++ /dev/null @@ -1,58 +0,0 @@ -(ns mount.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 'mount.deref.fun-with-values-test) - (mount/start #'mount.deref.fun-with-values-test/scalar - #'mount.deref.fun-with-values-test/fun - #'mount.deref.fun-with-values-test/with-fun - #'mount.deref.fun-with-values-test/with-partial - #'mount.deref.fun-with-values-test/f-in-f - #'mount.deref.fun-with-values-test/f-args - #'mount.deref.fun-with-values-test/f-no-args-value - #'mount.deref.fun-with-values-test/f-no-args - #'mount.deref.fun-with-values-test/private-f - #'mount.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))) diff --git a/test/clj/mount/deref/private_fun_test.clj b/test/clj/mount/deref/private_fun_test.clj deleted file mode 100644 index 38f1dbe..0000000 --- a/test/clj/mount/deref/private_fun_test.clj +++ /dev/null @@ -1,16 +0,0 @@ -(ns mount.deref.private-fun-test - (:require [mount.core :as mount :refer [defstate]] - [mount.deref.fun-with-values-test :refer [private-f]] - [clojure.test :refer :all])) - -(defn with-fun-and-values [f] - (mount/in-cljc-mode) - (mount/start #'mount.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))) diff --git a/test/clj/mount/fun_with_values_test.clj b/test/clj/mount/fun_with_values_test.clj deleted file mode 100644 index 22693ad..0000000 --- a/test/clj/mount/fun_with_values_test.clj +++ /dev/null @@ -1,55 +0,0 @@ -(ns mount.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/start #'mount.fun-with-values-test/scalar - #'mount.fun-with-values-test/fun - #'mount.fun-with-values-test/with-fun - #'mount.fun-with-values-test/with-partial - #'mount.fun-with-values-test/f-in-f - #'mount.fun-with-values-test/f-args - #'mount.fun-with-values-test/f-no-args-value - #'mount.fun-with-values-test/f-no-args - #'mount.fun-with-values-test/private-f - #'mount.fun-with-values-test/f-value) - (f) - (mount/stop)) - -(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))) diff --git a/test/clj/mount/parts_test.clj b/test/clj/mount/parts_test.clj deleted file mode 100644 index c387ce3..0000000 --- a/test/clj/mount/parts_test.clj +++ /dev/null @@ -1,17 +0,0 @@ -(ns mount.parts-test - (:require [mount.core :as mount :refer [defstate] :as m] - [app.nyse :refer [conn]] - [clojure.test :refer :all])) - -(defstate should-not-start :start #(constantly 42)) - -(defn with-parts [f] - (m/start #'app.conf/config #'app.nyse/conn) - (f) - (m/stop)) - -(use-fixtures :each with-parts) - -(deftest start-only-parts - (is (instance? datomic.peer.LocalConnection conn)) - (is (instance? mount.core.NotStartedState should-not-start))) diff --git a/test/clj/mount/private_fun_test.clj b/test/clj/mount/private_fun_test.clj deleted file mode 100644 index 85cc31c..0000000 --- a/test/clj/mount/private_fun_test.clj +++ /dev/null @@ -1,14 +0,0 @@ -(ns mount.private-fun-test - (:require [mount.core :as mount :refer [defstate]] - [mount.fun-with-values-test :refer [private-f]] - [clojure.test :refer :all])) - -(defn with-fun-and-values [f] - (mount/start #'mount.fun-with-values-test/private-f) - (f) - (mount/stop)) - -(use-fixtures :each with-fun-and-values) - -(deftest fun-with-valuesj - (is (= (private-f 1) 42))) diff --git a/test/clj/mount/start_with_test.clj b/test/clj/mount/start_with_test.clj deleted file mode 100644 index 59b0b98..0000000 --- a/test/clj/mount/start_with_test.clj +++ /dev/null @@ -1,47 +0,0 @@ -(ns mount.start-with-test - (:require [mount.core :as mount :refer [defstate]] - [app.conf :refer [config]] - [app.nyse :refer [conn]] - [app.example :refer [nrepl]] - [clojure.test :refer :all])) - -(defstate test-conn :start 42 - :stop #(constantly 0)) - -(defstate test-nrepl :start []) - -(deftest start-with - - (testing "should start with substitutes" - (let [_ (mount/start-with {#'app.nyse/conn #'mount.start-with-test/test-conn - #'app.example/nrepl #'mount.start-with-test/test-nrepl})] - (is (map? config)) - (is (vector? nrepl)) - (is (= conn 42)) - (mount/stop))) - - (testing "should not start the substitute itself" - (let [_ (mount/start-with {#'app.nyse/conn #'mount.start-with-test/test-conn})] - (is (instance? mount.core.NotStartedState test-conn)) - (is (= conn 42)) - (mount/stop))) - - (testing "should start normally after start-with" - (let [_ (mount/start)] - (is (map? config)) - (is (instance? clojure.tools.nrepl.server.Server nrepl)) - (is (instance? datomic.peer.LocalConnection conn)) - (is (= test-conn 42)) - (is (vector? test-nrepl)) - (mount/stop))) - - (testing "should start-without normally after start-with" - (let [_ (mount/start-without #'mount.start-with-test/test-conn - #'mount.start-with-test/test-nrepl)] - (is (map? config)) - (is (instance? clojure.tools.nrepl.server.Server nrepl)) - (is (instance? datomic.peer.LocalConnection conn)) - (is (instance? mount.core.NotStartedState test-conn)) - (is (instance? mount.core.NotStartedState test-nrepl)) - (mount/stop)))) - diff --git a/test/clj/mount/start_without_test.clj b/test/clj/mount/start_without_test.clj deleted file mode 100644 index 5d9ac77..0000000 --- a/test/clj/mount/start_without_test.clj +++ /dev/null @@ -1,18 +0,0 @@ -(ns mount.start-without-test - (:require [mount.core :as m] - [app.conf :refer [config]] - [app.nyse :refer [conn]] - [app.example :refer [nrepl]] - [clojure.test :refer :all])) - -(defn without [f] - (m/start-without #'app.nyse/conn #'app.example/nrepl) - (f) - (m/stop)) - -(use-fixtures :each without) - -(deftest start-without-states - (is (map? config)) - (is (instance? mount.core.NotStartedState nrepl)) - (is (instance? mount.core.NotStartedState conn))) diff --git a/test/clj/mount/stop_except_test.clj b/test/clj/mount/stop_except_test.clj deleted file mode 100644 index bc2c452..0000000 --- a/test/clj/mount/stop_except_test.clj +++ /dev/null @@ -1,31 +0,0 @@ -(ns mount.stop-except-test - (:require [mount.core :as mount :refer [defstate]] - [app.conf :refer [config]] - [app.nyse :refer [conn]] - [app.example :refer [nrepl]] - [clojure.test :refer :all])) - -(deftest stop-except - - (testing "should stop all except nrepl" - (let [_ (mount/start) - _ (mount/stop-except #'app.nyse/conn #'app.conf/config)] - (is (map? config)) - (is (instance? datomic.peer.LocalConnection conn)) - (is (instance? mount.core.NotStartedState nrepl)) - (mount/stop))) - - (testing "should start normally after stop-except" - (let [_ (mount/start)] - (is (map? config)) - (is (instance? clojure.tools.nrepl.server.Server nrepl)) - (is (instance? datomic.peer.LocalConnection conn)) - (mount/stop))) - - (testing "should stop all normally after stop-except" - (let [_ (mount/start) - _ (mount/stop-except #'app.nyse/conn #'app.conf/config) - _ (mount/stop)] - (is (instance? mount.core.NotStartedState config)) - (is (instance? mount.core.NotStartedState conn)) - (is (instance? mount.core.NotStartedState nrepl))))) diff --git a/test/clj/mount/suspend_resume_test.clj b/test/clj/mount/suspend_resume_test.clj deleted file mode 100644 index d96d389..0000000 --- a/test/clj/mount/suspend_resume_test.clj +++ /dev/null @@ -1,142 +0,0 @@ -(ns mount.suspend-resume-test - (:require [mount.core :as mount :refer [defstate]] - [app.conf :refer [config]] - [app.nyse :refer [conn]] - [app.example :refer [nrepl]] - [clojure.test :refer :all])) - -(defn koncat [k s] - (-> (name k) - (str "-" (name s)) - keyword)) - -(defn start [s] (koncat s :started)) -(defn stop [s] (koncat s :stopped)) -(defn suspend [s] (koncat s :suspended)) -(defn resume [s] (koncat s :resumed)) - -(defstate web-server :start (start :w) - :stop (stop :w) - :suspend (suspend :w) - :resume (resume :w)) - -(defstate q-listener :start (start :q) - :stop (stop :q) - :suspend (suspend :q) - :resume (resume :q)) - -(defstate randomizer :start (rand-int 42)) - -(deftest suspendable-lifecycle - - (testing "should suspend _only suspendable_ states that are currently started" - (let [_ (mount/start) - _ (mount/suspend)] - (is (map? config)) - (is (instance? clojure.tools.nrepl.server.Server nrepl)) - (is (instance? datomic.peer.LocalConnection conn)) - (is (= web-server :w-suspended)) - (mount/stop))) - - (testing "should resume _only suspendable_ states that are currently suspended" - (let [_ (mount/start) - _ (mount/stop #'app.example/nrepl) - _ (mount/suspend) - _ (mount/resume)] - (is (map? config)) - (is (instance? mount.core.NotStartedState nrepl)) - (is (instance? datomic.peer.LocalConnection conn)) - (is (= web-server :w-resumed)) - (mount/stop))) - - (testing "should start all the states, except the ones that are currently suspended, should resume them instead" - (let [_ (mount/start) - _ (mount/suspend) - _ (mount/start)] - (is (map? config)) - (is (instance? clojure.tools.nrepl.server.Server nrepl)) - (is (instance? datomic.peer.LocalConnection conn)) - (is (= web-server :w-resumed)) - (mount/stop))) - - (testing "should stop all: started and suspended" - (let [_ (mount/start) - _ (mount/suspend) - _ (mount/stop)] - (is (instance? mount.core.NotStartedState config)) - (is (instance? mount.core.NotStartedState nrepl)) - (is (instance? mount.core.NotStartedState conn)) - (is (instance? mount.core.NotStartedState web-server))))) - - -(deftest suspendable-start-with - - (testing "when replacing a non suspendable state with a suspendable one, - the later should be able to suspend/resume, - the original should not be suspendable after resume and preserve its lifecycle fns after rollback/stop" - (let [_ (mount/start-with {#'app.example/nrepl #'mount.suspend-resume-test/web-server}) - _ (mount/suspend)] - (is (= nrepl :w-suspended)) - (is (instance? mount.core.NotStartedState web-server)) - (mount/stop) - (mount/start) - (mount/suspend) - (is (instance? clojure.tools.nrepl.server.Server nrepl)) - (is (= web-server :w-suspended)) - (mount/stop))) - - ;; this is a messy use case, but can still happen especially at REPL time - ;; it also messy, because usually :stop function refers the _original_ state by name (i.e. #(disconnect conn)) - ;; (unchanged/not substituted in its lexical scope), and original state won't be started - (testing "when replacing a suspendable state with a non suspendable one, - the later should not be suspendable, - the original should still be suspendable and preserve its lifecycle fns after the rollback/stop" - (let [_ (mount/start-with {#'mount.suspend-resume-test/web-server #'mount.suspend-resume-test/randomizer}) - _ (mount/suspend)] - (is (integer? web-server)) - (is (instance? mount.core.NotStartedState randomizer)) - (mount/stop) - (mount/start) - (mount/suspend) - (is (integer? randomizer)) - (is (= web-server :w-suspended)) - (mount/stop))) - - ;; this is a messy use case, but can still happen especially at REPL time - (testing "when replacing a suspended state with a non suspendable started one, - the later should not be suspendable, - the original should still be suspended and preserve its lifecycle fns after the rollback/stop" - (let [_ (mount/start) - _ (mount/suspend) - _ (mount/start-with {#'mount.suspend-resume-test/web-server #'app.nyse/conn}) ;; TODO: good to WARN on started states during "start-with" - _ (mount/suspend)] - (is (instance? datomic.peer.LocalConnection conn)) - (is (= web-server :w-suspended)) ;; since the "conn" does not have a resume method, so web-server was not started - (mount/stop) - (mount/start) - (mount/suspend) - (is (instance? datomic.peer.LocalConnection conn)) - (is (= web-server :w-suspended)) - (mount/stop))) - - ;; this is a messy use case, but can still happen especially at REPL time - (testing "when replacing a suspended state with a suspendable one, - the later should be suspendable, - the original should still be suspended and preserve its lifecycle fns after the rollback/stop" - (let [_ (mount/start) - _ (mount/suspend) - _ (mount/start-with {#'mount.suspend-resume-test/web-server - #'mount.suspend-resume-test/q-listener})] ;; TODO: good to WARN on started states during "start-with" - (is (= q-listener :q-suspended)) - (is (= web-server :q-resumed)) - (mount/suspend) - (is (= q-listener :q-suspended)) - (is (= web-server :q-suspended)) - (mount/stop) - (is (instance? mount.core.NotStartedState web-server)) - (is (instance? mount.core.NotStartedState q-listener)) - (mount/start) - (mount/suspend) - (is (= q-listener :q-suspended)) - (is (= web-server :w-suspended)) - (mount/stop)))) diff --git a/test/cljs/mount/waiting.for.cljs.tests b/test/cljs/mount/waiting.for.cljs.tests deleted file mode 100644 index a511b1f..0000000 --- a/test/cljs/mount/waiting.for.cljs.tests +++ /dev/null @@ -1 +0,0 @@ -обещали подвезти diff --git a/test/mount/test.cljc b/test/mount/test.cljc new file mode 100644 index 0000000..96a136d --- /dev/null +++ b/test/mount/test.cljc @@ -0,0 +1,18 @@ +(ns mount.test + (:require + #?@(:cljs [[cljs.test :as t] + [doo.runner :refer-macros [doo-tests]]] + :clj [clojure.test :as t]) + [mount.core :as mount] + + mount.test.fun-with-values + mount.test.private-fun)) + +(mount/in-cljc-mode) + +(doo.runner/doo-tests 'mount.test.fun-with-values + 'mount.test.private-fun) +;; (doo.runner/do-all-tests) + +(defn run-tests [] + (t/run-all-tests #"mount.test.*")) diff --git a/test/mount/test/fun_with_values.cljc b/test/mount/test/fun_with_values.cljc new file mode 100644 index 0000000..61cf200 --- /dev/null +++ b/test/mount/test/fun_with_values.cljc @@ -0,0 +1,59 @@ +(ns mount.test.fun-with-values + (:require + #?@(:cljs [[cljs.test :as t :refer-macros [is are deftest testing use-fixtures]] + [mount.core :as mount :refer-macros [defstate]]] + :clj [[clojure.test :as t :refer [is are deftest testing use-fixtures]] + [mount.core :as mount :refer [defstate]]]))) + +(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 start-states [] + (mount/start #'mount.test.fun-with-values/scalar + #'mount.test.fun-with-values/fun + #'mount.test.fun-with-values/with-fun + #'mount.test.fun-with-values/with-partial + #'mount.test.fun-with-values/f-in-f + #'mount.test.fun-with-values/f-args + #'mount.test.fun-with-values/f-no-args-value + #'mount.test.fun-with-values/f-no-args + #'mount.test.fun-with-values/private-f + #'mount.test.fun-with-values/f-value)) + +(use-fixtures :once + #?(:cljs {:before start-states + :after mount/stop} + :clj #((start-states) (%) (mount/stop)))) + +(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))) diff --git a/test/mount/test/private_fun.cljc b/test/mount/test/private_fun.cljc new file mode 100644 index 0000000..47ef9a4 --- /dev/null +++ b/test/mount/test/private_fun.cljc @@ -0,0 +1,18 @@ +(ns mount.test.private-fun + (:require + #?@(:cljs [[cljs.test :as t :refer-macros [is are deftest testing use-fixtures]] + [mount.core :as mount :refer-macros [defstate]]] + :clj [[clojure.test :as t :refer [is are deftest testing use-fixtures]] + [mount.core :as mount :refer [defstate]]]) + + [mount.test.fun-with-values :refer [private-f]])) + +(use-fixtures :once + #?(:cljs {:before #(mount/start #'mount.test.fun-with-values/private-f) + :after mount/stop} + :clj #((mount/start #'mount.test.fun-with-values/private-f) + (%) + (mount/stop)))) + +(deftest fun-with-values + (is (= (@private-f 1) 42))) diff --git a/test/mount/test/var/fun_with_values.clj b/test/mount/test/var/fun_with_values.clj new file mode 100644 index 0000000..f6a09a1 --- /dev/null +++ b/test/mount/test/var/fun_with_values.clj @@ -0,0 +1,59 @@ +(ns mount.test.var.fun-with-values + (:require [clojure.test :as t :refer [is are deftest testing use-fixtures]] + [mount.core :as mount :refer [defstate]])) + +(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 start-states [] + (mount/in-clj-mode) + (require :reload 'mount.test.var.fun-with-values) + (mount/start #'mount.test.var.fun-with-values/scalar + #'mount.test.var.fun-with-values/fun + #'mount.test.var.fun-with-values/with-fun + #'mount.test.var.fun-with-values/with-partial + #'mount.test.var.fun-with-values/f-in-f + #'mount.test.var.fun-with-values/f-args + #'mount.test.var.fun-with-values/f-no-args-value + #'mount.test.var.fun-with-values/f-no-args + #'mount.test.var.fun-with-values/private-f + #'mount.test.var.fun-with-values/f-value)) + +(defn stop-states [] + (mount/stop) + (mount/in-cljc-mode)) + +(use-fixtures :once #((start-states) (%) (stop-states))) + +(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))) diff --git a/test/mount/test/var/private_fun.clj b/test/mount/test/var/private_fun.clj new file mode 100644 index 0000000..f00a37d --- /dev/null +++ b/test/mount/test/var/private_fun.clj @@ -0,0 +1,17 @@ +(ns mount.test.var.private-fun + (:require [clojure.test :refer [is are deftest testing use-fixtures]] + [mount.core :as mount :refer [defstate]] + [mount.test.var.fun-with-values :refer [private-f]])) + +(defn in-clj-mode [f] + (mount/in-clj-mode) + (require :reload 'mount.test.var.fun-with-values 'mount.test.var.private-fun) + (mount/start #'mount.test.var.fun-with-values/private-f) + (f) + (mount/stop) + (mount/in-cljc-mode)) + +(use-fixtures :once in-clj-mode) + +(deftest fun-with-values + (is (= (private-f 1) 42)))