Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
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...
commit bc1a2883ca54995796137e4971850bb1c11e9396 1 parent 74db8b1
@pjstadig authored
View
3  CHANGELOG.org
@@ -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
2  README.org
@@ -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.
View
15 src/name/stadig/conjecture.clj
@@ -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))))))
View
14 test/name/stadig/test/conjecture.clj
@@ -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))
Please sign in to comment.
Something went wrong with that request. Please try again.