Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[Issue #82] updated backlog; organized t-formula

  • Loading branch information...
commit 9980189dfd11c8099bee9e2b91b997419c86d15f 1 parent ba89d85
@AlexBaranosky AlexBaranosky authored
Showing with 21 additions and 26 deletions.
  1. +11 −16 FORMULAS-BACKLOG-AND-FEATURE-IDEAS.md
  2. +10 −10 test/midje/ideas/t_formulas.clj
View
27 FORMULAS-BACKLOG-AND-FEATURE-IDEAS.md
@@ -9,26 +9,21 @@
* [x] figure out how to make syntax validation errors show something more sensible than the
error message you'd see for a problem with a fact validation problem
-* [ ] don't run more tests than need be if there is already failure in this formula's batch.
-
-* [ ] make line numbers report correctly
+* [x] don't run more tests than need be if there is already failure in this formula's batch.
* [ ] implement shrinking. Report only the first fully shrunken failure
- [ ] to do correctly, 'shrink' depends on 'generate'
-
-* [ ] consider implementing with @marick's metaconstant syntax
+ [ ] to do correctly, 'shrink' depends on 'generate'
* [ ] shrink function overrides
a. [ ] no shrink
-
-* [ ] if we do metaconstant style, implement generator overriding
-
- --- getting there with the new validate method for "formula"
- a. [] fix: however, there's an interesting form of failure if you run (formula [a 1] 1 =>)
- ... since the formula macro splices in :formula :formula-in-progress
-
- will the below note help this?
+
+* [ ] fix strange error if you run (formula [a 1] 1 =>)
+ ... since the formula macro splices in :formula :formula-in-progress
+ possibly solution is to not using fact macro inside of formula,
+ but instead do something like tabular
-NOTES:
+
+* [ ] if line numbers shift, then ensure that they always report correctly -- so far I don't know if this even needs to change, since it seems to work fine. Think about it and decide if tests to prevent regressions are useful here.
-* possibly don't use fact macro inside of formula, but instead do something like tabular
+* [ ] consider implementing with @marick's metaconstant syntax
+ a. [ ] if we do metaconstant style, implement generator overriding
View
20 test/midje/ideas/t_formulas.clj
@@ -36,7 +36,7 @@
"Uniform distribution from lo (inclusive) to high (exclusive).
Defaults to range of Java long."
(^long [] (.nextLong *rnd*))
- (^long[lo hi] {:pre [(< lo hi)]}
+ (^long [lo hi] {:pre [(< lo hi)]}
(clojure.core/long (Math/floor (+ lo (* (.nextDouble *rnd*) (- hi lo)))))))
@@ -57,6 +57,14 @@
;;;; Formulas
+;; the first formula use ever!
+(defn make-string []
+ (rand-nth ["a" "b" "c" "d" "e" "f" "g" "i"]))
+(formula "can now use simple generative-style formulas"
+ [a (make-string) b (make-string)]
+ (str a b) => (has-prefix a))
+
+
;; failed formulas report once per formula regardless how many generations were run
(after-silently
(formula "some description" [a "y"]
@@ -64,18 +72,9 @@
(fact @reported => (one-of (contains {:type :mock-expected-result-failure
:description "some description"})))
-(defn make-string []
- (rand-nth ["a" "b" "c" "d" "e" "f" "g" "i"]))
-
-(formula
- "can now use simple generative-style formulas"
- [a (make-string) b (make-string)]
- (str a b) => (has-prefix a))
-
;; passing formulas run the generator many times, and evaluate
;; their body many times - number of generations is rebindable
-
(defn-verifiable y-maker [] "y")
(defn-verifiable my-str [s] (str s))
@@ -85,6 +84,7 @@
(fact @y-maker-count => 77)
(fact @my-str-count => 77)
+
;; runs only as few times as needed to see a failure
(defn-verifiable z-maker [] "z")
(defn-verifiable my-identity [x] (identity x))
Please sign in to comment.
Something went wrong with that request. Please try again.