- ;; Current version -- note the use of `when-valid`... it is essentially duplicating the work the
- ;; syntax-validation-m monad should be able to handle, so I've been attempting to
- ;; clean it up / refactor it to use only the monad
- (defmacro expect
- "Run the call form, check that all the mocks defined in the fakes
- (probably with 'fake') have been satisfied, and check that the actual
- results are as expected. If the expected results are a function, it
- will be called with the actual result as its single argument.
- To strip tests from production code, set either clojure.test/*load-tests*,
- midje.semi-sweet/*include-midje-checks*, or midje.sweet/*include-midje-checks* to false."
- {:arglists '([call-form arrow expected-result & fakes+overrides])}
- [& _]
- (when (user-desires-checking?)
- (domonad syntax-validate-m [[call-form arrow expected-result & fakes+overrides] (validate &form)
- [fakes overrides] (separate-by a-fake? fakes+overrides)]
- (when-valid fakes
- (expect-expansion call-form arrow expected-result fakes overrides)))))
- ;; New attempted version-- which I have no reason to believe should not work (but doesn't):
- (defmacro expect
- "Run the call form, check that all the mocks defined in the fakes
- (probably with 'fake') have been satisfied, and check that the actual
- results are as expected. If the expected results are a function, it
- will be called with the actual result as its single argument.
- To strip tests from production code, set either clojure.test/*load-tests*,
- midje.semi-sweet/*include-midje-checks*, or midje.sweet/*include-midje-checks* to false."
- {:arglists '([call-form arrow expected-result & fakes+overrides])}
- [& _]
- (when (user-desires-checking?)
- (domonad syntax-validate-m [[call-form arrow expected-result & fakes+overrides] (validate &form)
- [unvalidated-fakes overrides] (separate-by a-fake? fakes+overrides)
- fakes (validate unvalidated-fakes)]
- (expect-expansion call-form arrow expected-result fakes overrides))))
- ;; UPDATE --
- ;; looks like this works, but I'd really prefer the above version over this, but I might not fight it
- (defmacro expect
- "Run the call form, check that all the mocks defined in the fakes
- (probably with 'fake') have been satisfied, and check that the actual
- results are as expected. If the expected results are a function, it
- will be called with the actual result as its single argument.
- To strip tests from production code, set either clojure.test/*load-tests*,
- midje.semi-sweet/*include-midje-checks*, or midje.sweet/*include-midje-checks* to false."
- {:arglists '([call-form arrow expected-result & fakes+overrides])}
- [& _]
- (when (user-desires-checking?)
- (domonad syntax-validate-m [[call-form arrow expected-result & fakes+overrides] (validate &form)
- [fakes overrides] (separate-by a-fake? fakes+overrides)
- _ (validate fakes)]
- (expect-expansion call-form arrow expected-result fakes overrides))))