Permalink
Browse files

Removes support for singleton fixtures.

They did not provide an opportunity to clean up, and it would be better
to have some kind of once-for-the-test-run fixture that did allow for
cleanup.
  • Loading branch information...
1 parent 74db8b1 commit bc1a2883ca54995796137e4971850bb1c11e9396 @pjstadig committed Mar 7, 2013
Showing with 4 additions and 30 deletions.
  1. +3 −0 CHANGELOG.org
  2. +1 −1 README.org
  3. +0 −15 src/name/stadig/conjecture.clj
  4. +0 −14 test/name/stadig/test/conjecture.clj
View
@@ -5,3 +5,6 @@
- Adds support for creating idempotent and singleton fixtures.
** 0.2.0
- Runs fixtures when you call a function as a test (e.g. at a REPL)
+ - Removes support for singleton fixtures. They did not provide an
+ opportunity to clean up, and it would be better to have some kind of
+ once-for-the-test-run fixture that did allow for cleanup.
View
@@ -40,7 +40,7 @@
since the namespace is different for conjecture (for example,
clojure-test-mode will run the tests, but report incorrectly).
** Differences from clojure.test
- - Adds support for creating idempotent and singleton fixtures.
+ - Adds support for creating idempotent fixtures.
- Runs fixtures when you call a function as a test (e.g. at a REPL)
See CHANGELOG.org for more details.
@@ -832,18 +832,3 @@
[generator]
(fn [& args]
(idempotent-fixture (apply generator args))))
-
-(defonce singleton-has-run? (atom #{}))
-
-(defn singleton-fixture
- "Takes a fixture and makes it into a singleton fixture. A singleton fixture
- is run only once per JVM process."
- {:added "0.1.0"}
- [fx]
- (fn [f]
- (let [run? (not (@singleton-has-run? fx))]
- (try
- (if run?
- (do (swap! singleton-has-run? conj fx)
- (fx f))
- (f))))))
@@ -146,20 +146,6 @@
(is (= ["hello" "goodbye"] @order) "Should pass")
(is @called? "Should pass")))
-(def sfx-count (atom 0))
-(def fx (fn [f] (swap! sfx-count inc) (f)))
-(def sfx (singleton-fixture fx))
-
-(deftest test-singleton-fixture
- (reset! sfx-count 0)
- (swap! singleton-has-run? disj sfx)
- (sfx #(constantly nil))
- (is (= 1 @sfx-count) "Should pass")
- (is (@singleton-has-run? fx) "Should pass")
- (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))

0 comments on commit bc1a288

Please sign in to comment.