Permalink
Browse files

Macroexpand for-all forms that appear inside facts (marick#419)

* expand for-all inside of facts

* unify indentation

* bump version
  • Loading branch information...
phillipm committed Nov 14, 2017
1 parent 2ae36b2 commit b3a5fcf549070bc0058d492f695cb82e7419d505
View
@@ -2,6 +2,9 @@
This project adheres to [Semantic Versioning](http://semver.org/).
See [here](http://keepachangelog.com/) for the change log format.
## [1.9.0-alpha12] - 2017-11-14
- allow `for-all` to appear inside of `fact` forms
## [1.9.0-alpha11] - 2017-11-09
- [`for-all`](https://github.com/marick/Midje/wiki/Generative-testing-with-for-all) construct for quick-check style testing, powered by `clojure.test.check`
- show more info in load-time exception
View
@@ -1,4 +1,4 @@
(defproject midje "1.9.0-alpha11"
(defproject midje "1.9.0-alpha12"
:description "A TDD library for Clojure that supports top-down ('mockish') TDD, encourages readable tests, provides a smooth migration path from clojure.test, balances abstraction and concreteness, and strives for graciousness."
:url "https://github.com/marick/Midje"
:pedantic? :warn
@@ -105,19 +105,22 @@
(first-named? form "with-state-changes")))
(defn midjcoexpand
"Descend form, macroexpanding *only* midje forms and placing background wrappers where appropriate."
"Descend form, macroexpanding *only* midje forms and placing background
wrappers where appropriate."
[form]
(branch-on form
wrapping/already-wrapped? form
quoted? form
wrapping/already-wrapped? form
quoted? form
recognize/future-fact? (macroexpand form)
;; The `prerequisites` form is not supposed to be used in wrapping style.
wrapping-background-changer? (expand-wrapping-background-changer form)
recognize/expect? (wrapping/multiwrap form (wrapping/forms-to-wrap-around :checks))
recognize/fact? (macroexpand form)
recognize/tabular? (macroexpand form)
sequential? (preserve-type form (eagerly (map midjcoexpand form)))
:else form))
recognize/expect? (wrapping/multiwrap
form (wrapping/forms-to-wrap-around :checks))
recognize/fact? (macroexpand form)
recognize/tabular? (macroexpand form)
recognize/for-all? (macroexpand form)
sequential? (preserve-type form (eagerly (map midjcoexpand form)))
:else form))
(defn parse-expects [form]
(pzip/translate-zipper form
@@ -75,6 +75,9 @@
(defn tabular? [form]
(first-named? form "tabular"))
(defn for-all? [form]
(first-named? form "for-all"))
(defn provided? [loc]
(boolean (and (symbol? (zip/node loc))
(= "provided" (name (zip/node loc))))))
@@ -159,3 +159,8 @@
(after :facts (reset! setup-state 0))]
(fact @setup-state => strictly-pos)))
(fact @setup-state => 0)
(fact "you can put for-all inside of a fact"
(for-all
[x gen/int]
x => integer?))

0 comments on commit b3a5fcf

Please sign in to comment.