Skip to content

Commit

Permalink
[Issue #82] updated backlog; organized t-formula
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBaranosky committed Mar 2, 2012
1 parent ba89d85 commit 9980189
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
27 changes: 11 additions & 16 deletions FORMULAS-BACKLOG-AND-FEATURE-IDEAS.md
Expand Up @@ -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
20 changes: 10 additions & 10 deletions test/midje/ideas/t_formulas.clj
Expand Up @@ -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)))))))


Expand All @@ -57,25 +57,24 @@

;;;; 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"]
a => :foo))
(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))

Expand All @@ -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))
Expand Down

0 comments on commit 9980189

Please sign in to comment.