Permalink
Browse files

Removes comp-fixtures and adds its features to join-fixtures.

  • Loading branch information...
1 parent ddcfdbd commit d3eec736b894620f214f77de6f6634ec71a293d6 @pjstadig committed Mar 7, 2013
Showing with 26 additions and 8 deletions.
  1. +6 −5 src/name/stadig/conjecture.clj
  2. +20 −3 test/name/stadig/test/conjecture.clj
@@ -693,8 +693,12 @@
"Composes a collection of fixtures, in order. Always returns a valid
fixture function, even if the collection is empty."
{:added "0.1.0"}
- [fixtures]
- (reduce compose-fixtures default-fixture fixtures))
+ ([fixture-or-fixtures]
+ (if-not (or (nil? fixture-or-fixtures) (coll? fixture-or-fixtures))
+ (join-fixtures [fixture-or-fixtures])
+ (reduce compose-fixtures default-fixture fixture-or-fixtures)))
+ ([fixture & fixtures]
+ (join-fixtures (cons fixture fixtures))))
@@ -843,6 +847,3 @@
(do (swap! singleton-has-run? conj fx)
(fx f))
(f))))))
-
-(defn comp-fixtures [& fixtures]
- (join-fixtures fixtures))
@@ -124,13 +124,13 @@
called? (atom false)
fx (fn [f] (swap! count inc) (f))
ifx (idempotent-fixture fx)]
- ((comp-fixtures ifx ifx ifx) #(do (is (@has-run? fx) "Should pass")
+ ((join-fixtures ifx ifx ifx) #(do (is (@has-run? fx) "Should pass")
(reset! called? true)))
(is (= 1 @count) "Should pass")
(is (not (@has-run? fx)) "Should pass")
(is @called? "Should pass")
(try
- ((comp-fixtures ifx ifx ifx) #(throw (Exception.)))
+ ((join-fixtures ifx ifx ifx) #(throw (Exception.)))
(is false "Should fail")
(catch Exception _))
(is (not (@has-run? fx)) "Should pass")))
@@ -142,7 +142,7 @@
called? (atom false)
ifx (gen "hello")
ifx2 (gen "goodbye")]
- ((comp-fixtures ifx ifx ifx2) #(reset! called? true))
+ ((join-fixtures ifx ifx ifx2) #(reset! called? true))
(is (= ["hello" "goodbye"] @order) "Should pass")
(is @called? "Should pass")))
@@ -159,3 +159,20 @@
(sfx #(constantly nil))
(is (= 1 @sfx-count) "Should pass")
(is (@singleton-has-run? fx) "Should pass"))
+
+(deftest test-join-fixtures
+ (let [fixtures (atom [])
+ fx1 (fn [f] (swap! fixtures conj :fx1) (f))
+ fx2 (fn [f] (swap! fixtures conj :fx2) (f))
+ noop (fn [])]
+ ((join-fixtures fx1) noop)
+ (is (= [:fx1] @fixtures) "Should pass")
+ (reset! fixtures [])
+ ((join-fixtures [fx1]) noop)
+ (is (= [:fx1] @fixtures) "Should pass")
+ (reset! fixtures [])
+ ((join-fixtures fx1 fx2) noop)
+ (is (= [:fx1 :fx2] @fixtures) "Should pass")
+ (reset! fixtures [])
+ ((join-fixtures [fx1 fx2]) noop)
+ (is (= [:fx1 :fx2] @fixtures) "Should pass")))

0 comments on commit d3eec73

Please sign in to comment.