From 325eecf0c9251f26d943821255a4a39c65950ed2 Mon Sep 17 00:00:00 2001 From: anatoly Date: Mon, 30 Nov 2015 21:13:30 -0500 Subject: [PATCH] [#21]: test for lifecycle private fn with args --- test/check/fun_with_values_test.clj | 9 +++++++++ test/check/private_fun_test.clj | 14 ++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 test/check/private_fun_test.clj diff --git a/test/check/fun_with_values_test.clj b/test/check/fun_with_values_test.clj index 80a8e64..96eecf1 100644 --- a/test/check/fun_with_values_test.clj +++ b/test/check/fun_with_values_test.clj @@ -9,12 +9,17 @@ (defn g [a b] (+ a b)) +(defn- pf [n] + (+ 41 n)) + (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-args :start g) (defstate f-value :start (g 41 1)) +(defstate private-f :start pf) (defn with-fun-and-values [f] (mount/start #'check.fun-with-values-test/scalar @@ -22,6 +27,8 @@ #'check.fun-with-values-test/with-fun #'check.fun-with-values-test/with-partial #'check.fun-with-values-test/f-in-f + #'check.fun-with-values-test/f-args + #'check.fun-with-values-test/private-f #'check.fun-with-values-test/f-value) (f) (mount/stop)) @@ -34,4 +41,6 @@ (is (= with-fun 42)) (is (= (with-partial 1) 42)) (is (= (f-in-f 1) 42)) + (is (= (f-args 41 1) 42)) + (is (= (private-f 1) 42)) (is (= f-value 42))) diff --git a/test/check/private_fun_test.clj b/test/check/private_fun_test.clj new file mode 100644 index 0000000..2f2c413 --- /dev/null +++ b/test/check/private_fun_test.clj @@ -0,0 +1,14 @@ +(ns check.private-fun-test + (:require [mount.core :as mount :refer [defstate]] + [check.fun-with-values-test :refer [private-f]] + [clojure.test :refer :all])) + +(defn with-fun-and-values [f] + (mount/start #'check.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)))