Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moved expect expansion out of semi_sweet.clj

  • Loading branch information...
commit 51b25385334ddc7b7c43b1433ab908dd7e0fa872 1 parent 995c615
@marick authored
View
12 src/midje/parsing/2_to_lexical_maps/examples.clj
@@ -8,9 +8,10 @@
[midje.util.form-utils :only [first-named? translate-zipper map-difference
hash-map-duplicates-ok pred-cond
quoted-list-form? extended-fn?
- def-many-methods]]
+ def-many-methods separate-by]]
[midje.checking.extended-equality :only [extended-= extended-list-=]]
[midje.parsing.util.file-position :only [user-file-position]]
+ [midje.util.namespace :only [semi-sweet-keyword?]]
[midje.util.thread-safe-var-nesting :only [namespace-values-inside-out
with-pushed-namespace-values
with-altered-roots]]
@@ -53,3 +54,12 @@
(emit/future-fact (nested-facts/descriptions ~(str "on `" call-form "`"))
(:position check#))))
+(defn- ^{:testable true } a-fake? [x]
+ (and (seq? x)
+ (semi-sweet-keyword? (first x))))
+
+(defn to-lexical-map-form [full-form]
+ (domonad validate-m [[call-form arrow expected-result & fakes+overrides] (validate full-form)
+ [fakes overrides] (separate-by a-fake? fakes+overrides)
+ _ (validate fakes)]
+ (expect-expansion call-form arrow expected-result fakes overrides)))
View
9 src/midje/semi_sweet.clj
@@ -81,10 +81,6 @@
[& _]
(parse-data-fakes/to-lexical-map-form &form))
-(defn- ^{:testable true } a-fake? [x]
- (and (seq? x)
- (semi-sweet-keyword? (first x))))
-
(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
@@ -96,10 +92,7 @@
{:arglists '([call-form arrow expected-result & fakes+overrides])}
[& _]
(when (user-desires-checking?)
- (domonad validate-m [[call-form arrow expected-result & fakes+overrides] (validate &form)
- [fakes overrides] (separate-by a-fake? fakes+overrides)
- _ (validate fakes)]
- (parse-examples/expect-expansion call-form arrow expected-result fakes overrides))))
+ (parse-examples/to-lexical-map-form &form)))
(defmacro not-called
View
3  test-resources/midje/semi_sweet_compile_out.clj
@@ -1,5 +1,6 @@
+(require 'clojure.test)
;; This file is used to check whether checks can be compiled out.
(expect (throw (Exception. "Should never be called")) => true)
-(deftest tests-can-be-compiled-out
+(clojure.test/deftest tests-can-be-compiled-out
(expect false => true))
View
16 test/midje/t_semi_sweet.clj → .../parsing/2_to_lexical_maps/t_examples.clj
@@ -1,13 +1,14 @@
-(ns midje.t-semi-sweet
+(ns midje.parsing.2-to-lexical-maps.t-examples
(:use [clojure.test] ;; This is used to check production mode with deftest.
[midje.sweet]
+ [midje.parsing.2-to-lexical-maps.examples]
[midje.util form-utils]
[midje.test-util]
midje.util)
(:require [clojure.zip :as zip]
[midje.config :as config]
[midje.emission.api :as emit]))
-(expose-testables midje.semi-sweet)
+(expose-testables midje.parsing.2-to-lexical-maps.examples)
(unfinished faked-function mocked-function other-function)
@@ -67,7 +68,7 @@
fake-streamed (fake (faked-function 0) =streams=> ['r1 'r2])]
(fact "The basic parts"
- (:var fake-0) => #'midje.t-semi-sweet/faked-function
+ (:var fake-0) => #'midje.parsing.2-to-lexical-maps.t-examples/faked-function
(:call-text-for-failures fake-1) => "(faked-function some-variable)"
(deref (:call-count-atom fake-0)) => 0)
@@ -101,7 +102,7 @@
(facts "about not-called"
(let [fake-0 (not-called faked-function)]
- (:var fake-0) => #'midje.t-semi-sweet/faked-function
+ (:var fake-0) => #'midje.parsing.2-to-lexical-maps.t-examples/faked-function
(:call-text-for-failures fake-0) => "faked-function was called."
@(:call-count-atom fake-0) => 0
(:arg-matchers fake-0) => nil?
@@ -261,13 +262,6 @@
(fake (testfun 1) => 32)))
-;; The files to be loaded will blow up unless we're in production-mode.
-(binding [clojure.test/*load-tests* false]
- (load "semi_sweet_compile_out"))
-
-(binding [midje.semi-sweet/*include-midje-checks* false]
- (load "semi_sweet_compile_out"))
-
(capturing-fact-output
(config/with-augmented-config {:visible-future true}
(expect (cons :fred) =future=> 3))
View
11 test/midje/t_sweet.clj
@@ -112,6 +112,17 @@
(binding [midje.semi-sweet/*include-midje-checks* false]
(load "sweet_compile_out"))
+
+;; For the time being, we still support semi-sweet macros.
+;; The files to be loaded will blow up unless we're in production-mode.
+(binding [clojure.test/*load-tests* false]
+ (load "semi_sweet_compile_out"))
+
+(binding [midje.semi-sweet/*include-midje-checks* false]
+ (load "semi_sweet_compile_out"))
+
+
+
;; It doesn't matter which namespace the => is in
(silent-fact (+ 1 1) midje.semi-sweet/=> 3)
Please sign in to comment.
Something went wrong with that request. Please try again.