Permalink
Browse files

1.1-alpha-1

  • Loading branch information...
marick committed Feb 3, 2011
1 parent 6ffdd37 commit b8bb742b7cfe210f66a6820e96b151e138f8fbb6
View
19 HISTORY
@@ -1,4 +1,21 @@
-= 1.0.1
+= 1.1-alpha-1
+* Syntax errors made in Midje forms are somewhat better
+ more gracefully reported.
+* The #'roughly checker can be used for inexact numerical
+ comparisons.
+* #'irrelevant is a synonym for #anything
+* Line numbers are better reported for failures of very
+ stripped-down forms (like (fact 1 => odd?)
+* When stack traces are reported, they are better trimmed
+ down.
+* A prerequisite like (f 1) =streams=> [1 2 3] produces
+ the next value each time it's called.
+* Issue warning when bare function is used in a
+ prerequisite. Behavior will change in 1.2.
+* Several ways to make checkers that can be used in
+ prerequisites.
+
+= 1.0.1 (stable)
* Ben Mabey fix: eagerly preserve record types
* Extended-= and collection checkers have semantics for
mixing maps and records.
View
Binary file not shown.
@@ -10,5 +10,5 @@
[hiccup "0.2.6"]]
:dev-dependencies
[[lein-run "1.0.0"]
- [midje "1.0.1"]
+ [midje "1.1-alpha-1"]
])
@@ -17,7 +17,7 @@ Actual result did not agree with the checking function.
Actual result: [3 3 1 2]
Checking function: (just [1 2 3] :in-any-order)
The checker said this about the reason:
- Expected three elements. There were four.
+ Expected three elements. There were four.
^^^^ The previous failure was expected ^^^^
FAIL at (core_test.clj:120)
You claimed the following was needed, but it was never used:
@@ -30,11 +30,24 @@ Actual result did not agree with the checking function.
Actual result: nil
Checking function: truthy
^^^^ The previous three failures were expected ^^^^
-FAIL at (core_test.clj:211)
+-----
+-- WARNING: In this version, prerequisite arguments that are functions are
+-- considered checkers. In the near future, they'll be considered ordinary
+-- values. If you want them to be checkers, you need to declare them as such.
+-- The function argument I'm objecting to is:
+-- a function named 'odd?'
+-- near (core_test.clj:197)
+-- To future-proof your fact (and make this message go away), do this:
+-- (as-checker <<<your function argument>>>)
+-- If you never wanted this argument to be treated as a checker, do this:
+ (exactly <<<your function argument>>>)
+-- For more, see https://github.com/marick/Midje/wiki/Checkers-within-prerequisites
+-----
+FAIL at (core_test.clj:227)
You claimed the following was needed, but it was never used:
(data-structure)
-FAIL at (core_test.clj:211)
+FAIL at (core_test.clj:227)
You claimed the following was needed, but it was never used:
(property-of ...data-structure-value-1...)
^^^^ The previous two failures were expected ^^^^
-FAILURE: 9 facts were not confirmed. (But 10 were.)
+FAILURE: 9 facts were not confirmed. (But 14 were.)
@@ -2,6 +2,6 @@
:description "An example of using Midje's sweet interface"
:dependencies [[org.clojure/clojure "[1.1.0,1.2.0]"]
[org.clojure/clojure-contrib "[1.1.0,1.2.0]"]
- [midje "1.0.1"]]
+ [midje "1.1-alpha-1"]]
)
View
@@ -1,2 +1,2 @@
cd test
-java -cp ../lib/clojure-1.2.0.jar:../lib/clojure-contrib-1.2.0.jar:../lib/core-1.3.0-20101116.112441-56.jar:../lib/def-1.3.0-20101116.112441-56.jar:../lib/midje-1.0.1.jar:../lib/unifycle-0.5.0.jar clojure.main -i basic/core_test.clj -e '(ns basic.core-test)(run-tests)'
+java -cp ../lib/clojure-1.2.0.jar:../lib/clojure-contrib-1.2.0.jar:../lib/core-1.3.0-20101116.112441-56.jar:../lib/def-1.3.0-20101116.112441-56.jar:../lib/midje-1.1-alpha-1.jar:../lib/unifycle-0.5.0.jar clojure.main -i basic/core_test.clj -e '(ns basic.core-test)(run-tests)'
@@ -21,7 +21,7 @@ Actual result did not agree with the checking function.
Actual result: [3 3 1 2]
Checking function: (just [1 2 3] :in-any-order)
The checker said this about the reason:
- Expected three elements. There were four.
+ Expected three elements. There were four.
^^^^ The previous failure was expected ^^^^
FAIL at (core_test.clj:120)
@@ -37,12 +37,25 @@ Actual result did not agree with the checking function.
Actual result: nil
Checking function: truthy
^^^^ The previous three failures were expected ^^^^
+-----
+-- WARNING: In this version, prerequisite arguments that are functions are
+-- considered checkers. In the near future, they'll be considered ordinary
+-- values. If you want them to be checkers, you need to declare them as such.
+-- The function argument I'm objecting to is:
+-- a function named 'odd?'
+-- near (core_test.clj:197)
+-- To future-proof your fact (and make this message go away), do this:
+-- (as-checker <<<your function argument>>>)
+-- If you never wanted this argument to be treated as a checker, do this:
+ (exactly <<<your function argument>>>)
+-- For more, see https://github.com/marick/Midje/wiki/Checkers-within-prerequisites
+-----
-FAIL at (core_test.clj:211)
+FAIL at (core_test.clj:227)
You claimed the following was needed, but it was never used:
(data-structure)
-FAIL at (core_test.clj:211)
+FAIL at (core_test.clj:227)
You claimed the following was needed, but it was never used:
(property-of ...data-structure-value-1...)
^^^^ The previous two failures were expected ^^^^
@@ -64,7 +64,7 @@
;; gobbledeegook like #<core$even_QMARK_ clojure.core$even_QMARK_@21a722ef>.)
;; There are a number of matching functions available. You can find them all with
-;; (ns-publics 'midje.utils.checkers)
+;; (ns-publics 'midje.checkers)
;; They have doc strings.
;; (Or you can look at the wiki: http://github.com/marick/Midje/wiki/Checkers)
;; Here's one of them:
@@ -77,7 +77,7 @@
;; Actual result: [3 3 1 2]
;; Checking function: (just [1 2 3] :in-any-order)
;; The checker said this about the reason:
-;; Expected three elements. There were four.
+;; Expected three elements. There were four.
;; Facts work with variables bound both within and outside of the fact form:
(let [a 3]
@@ -165,22 +165,38 @@
(g 2) => 4
(g 3) => 7))
-;; When trying to match arguments in the provided functions, Midje
-;; uses the same rules as when checking a function-under-test's actual
-;; result. That means you can use single-argument matching functions
-;; and you must use (exactly) to match a functional argument.
+;; When looking for a matching prerequisite, Midje 1.1 uses the same rules as
+;; when checking a function-under-test's actual result. Because that's
+;; been found to be confusing, it'll change. What follows is future-proof
+;; test-writing.
-(unfinished first-subfunction another-subfunction)
+(unfinished subfunction)
+
+(defn function-under-test [value-to-pass]
+ (subfunction value-to-pass))
+
+(facts "about functions in the argument list of a prerequisite"
+ "Predefined checkers can be used unadorned"
+ (function-under-test 'blue-cow) => 11
+ (provided (subfunction anything) => 11)
+
+ (function-under-test 3.00000001) => 11
+ (provided (subfunction (roughly 3.0)) => 11)
+
+ "If you want to use an ordinary function as a checker, wrap it in as-checker."
+ (function-under-test 3) => 11
+ (provided (subfunction (as-checker odd?)) => 11)
+
+ "If you want a functional argument NOT to be run to check for a match,
+ but rather to be matched literally, wrapp it in exactly."
+ (function-under-test odd?) => 11
+ (provided (subfunction (exactly odd?)) => 11)
+
+ "In Midje 1.1, an unwrapped ordinary function is treated as a checker,
+ but you'll get a warning because that behavior will change."
+ (function-under-test 333333) => 11
+ (provided (subfunction odd?) => 11))
-(defn function-under-test []
- (+ (first-subfunction 1 2 '(a blue cow))
- (another-subfunction inc)))
-
-(fact (function-under-test) => 11
- (provided
- (first-subfunction odd? even? anything) => 1
- (another-subfunction (exactly inc)) => 10))
-
;; The return values of a prerequisite function don't follow the rules
;; for arguments. They're literal constant values.
@@ -2,4 +2,4 @@
:description "TODO: add summary of your project"
:dependencies [[clojure "1.2.0"]
[clojure-contrib "1.2.0"]]
- :dev-dependencies [[midje "1.0.1"]])
+ :dev-dependencies [[midje "1.1-alpha-1"]])
@@ -4,4 +4,4 @@
[[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]]
:dev-dependencies
- [[midje "1.0.1"]])
+ [[midje "1.1-alpha-1"]])
@@ -2,4 +2,4 @@
:description "FIXME: write"
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
- [midje "1.0.1"]])
+ [midje "1.1-alpha-1"]])
@@ -2,4 +2,4 @@
:description "FIXME: write"
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]
- [midje "1.0.1"]])
+ [midje "1.1-alpha-1"]])
@@ -18,11 +18,24 @@ Actual result did not agree with the checking function.
Actual result: [3 3 1 2]
Checking function: (just [1 2 3] :in-any-order)
The checker said this about the reason:
- Expected three elements. There were four.
+ Expected three elements. There were four.
^^^^ The previous failure was expected ^^^^
FAIL at (core_test.clj:78)
You claimed the following was needed, but it was never used:
(first-fake 3)
^^^^ The previous failure was expected ^^^^
-Ran 11 tests containing 14 assertions.
+-----
+-- WARNING: In this version, prerequisite arguments that are functions are
+-- considered checkers. In the near future, they'll be considered ordinary
+-- values. If you want them to be checkers, you need to declare them as such.
+-- The function argument I'm objecting to is:
+-- a function named 'odd?'
+-- near (core_test.clj:125)
+-- To future-proof your fact (and make this message go away), do this:
+-- (as-checker <<<your function argument>>>)
+-- If you never wanted this argument to be treated as a checker, do this:
+ (exactly <<<your function argument>>>)
+-- For more, see https://github.com/marick/Midje/wiki/Checkers-within-prerequisites
+-----
+Ran 11 tests containing 18 assertions.
5 failures, 0 errors.
@@ -2,7 +2,7 @@
:description "An example of using Midje semi-sweet mocking"
:dependencies [[org.clojure/clojure "[1.1.0,1.2.0]"]
[org.clojure/clojure-contrib "[1.1.0,1.2.0]"]
- [midje "1.0.1"]
+ [midje "1.1-alpha-1"]
]
)
@@ -1,2 +1,2 @@
cd test
-java -cp ../lib/clojure-1.2.0.jar:../lib/clojure-contrib-1.2.0.jar:../lib/core-1.3.0-20101116.112441-56.jar:../lib/def-1.3.0-20101116.112441-56.jar:../lib/midje-1.0.1.jar:../lib/unifycle-0.5.0.jar clojure.main -i semi_sweet_simple/core_test.clj -e '(ns semi-sweet-simple.core-test)(run-tests)'
+java -cp ../lib/clojure-1.2.0.jar:../lib/clojure-contrib-1.2.0.jar:../lib/core-1.3.0-20101116.112441-56.jar:../lib/def-1.3.0-20101116.112441-56.jar:../lib/midje-1.1-alpha-1.jar:../lib/unifycle-0.5.0.jar clojure.main -i semi_sweet_simple/core_test.clj -e '(ns semi-sweet-simple.core-test)(run-tests)'
@@ -23,14 +23,27 @@ Actual result did not agree with the checking function.
Actual result: [3 3 1 2]
Checking function: (just [1 2 3] :in-any-order)
The checker said this about the reason:
- Expected three elements. There were four.
+ Expected three elements. There were four.
^^^^ The previous failure was expected ^^^^
FAIL at (core_test.clj:78)
You claimed the following was needed, but it was never used:
(first-fake 3)
^^^^ The previous failure was expected ^^^^
+-----
+-- WARNING: In this version, prerequisite arguments that are functions are
+-- considered checkers. In the near future, they'll be considered ordinary
+-- values. If you want them to be checkers, you need to declare them as such.
+-- The function argument I'm objecting to is:
+-- a function named 'odd?'
+-- near (core_test.clj:125)
+-- To future-proof your fact (and make this message go away), do this:
+-- (as-checker <<<your function argument>>>)
+-- If you never wanted this argument to be treated as a checker, do this:
+ (exactly <<<your function argument>>>)
+-- For more, see https://github.com/marick/Midje/wiki/Checkers-within-prerequisites
+-----
-Ran 11 tests containing 14 assertions.
+Ran 11 tests containing 18 assertions.
5 failures, 0 errors.
-{:type :summary, :test 11, :pass 9, :fail 5, :error 0}
+{:type :summary, :test 11, :pass 13, :fail 5, :error 0}
@@ -43,7 +43,7 @@
;; actual result: #<core$even_QMARK___4680 clojure.core$even_QMARK___4680@494b6bed>
;; There are a number of matching functions available. You can find them all with
-;; (ns-publics (40 'midje.checkers))
+;; (ns-publics 'midje.checkers)
;; They have doc strings.
;; Here's one of them:
(deftest example-of-a-predefined-checker
@@ -97,18 +97,33 @@
(fake (first-fake 2 2) => 10)
(fake (another-fake) => 100)))
-;; When looking for a matching fake, Midje uses the same rules as when
-;; checking a function-under-test's actual result. That means you can
-;; use single-argument matching functions and you must use (exactly) to
-;; match a functional argument.
-(defn function-under-test-4 []
- (+ (first-fake 1 2 '(a blue cow))
- (another-fake inc)))
+;; When looking for a matching fake, Midje 1.1 uses the same rules as
+;; when checking a function-under-test's actual result. Because that's
+;; been found to be confusing, it'll change. Here's future-proof
+;; behavior. Given this function:
+
+(defn function-under-test-4 [value-to-pass]
+ (first-fake value-to-pass))
+
(deftest example-of-interesting-functional-args
- (expect (function-under-test-4) => 11
- (fake (first-fake odd? even? anything) => 1)
- (fake (another-fake (exactly inc)) => 10)))
+ ;; You can use predefined checkers as arguments.
+ (expect (function-under-test-4 'hops) => 11
+ (fake (first-fake anything) => 11))
+ (expect (function-under-test-4 3.0) => 11
+ (fake (first-fake (roughly 3.0 0.1)) => 11))
+ ;; If you want to use an ordinary function as a checker, wrap it in
+ ;; as-checker:
+ (expect (function-under-test-4 3) => 11
+ (fake (first-fake (as-checker odd?)) => 11))
+ ;; If you don't want the function to run to check for a match, but
+ ;; rather to be matched literally, wrap it in exactly:
+ (expect (function-under-test-4 odd?) => 11
+ (fake (first-fake (exactly odd?)) => 11))
+ ;; As of 1.1, an unwrapped ordinary function will be treated as a checker,
+ ;; but you'll get a warning because that behavior will change:
+ (expect (function-under-test-4 3) => 11
+ (fake (first-fake odd?) => 11)))
;; The return values of a fake don't follow the rules for fake
;; arguments. I suppose I could be convinced that a "returning" a
@@ -124,13 +139,13 @@
(expect (not-caller 3) => 4
(not-called some-function-never-called)))
-;; You can fake a function outside the current namespace. Suppose we
+;; You can fake a function that's part of Clojure. Suppose we
;; have a function that operates on two sets. We want to override
;; clojure.set/intersection so that our tests can only talk about properties
;; of tests, rather than have to laboriously construct actual sets with those
;; properties. So we pass in descriptive strings and fake out intersection.
;;
-;; There is (will be) more support for this style in midje.sweet.
+;; There is more support for this style in midje.sweet.
(use 'clojure.set)
(defn set-handler [set1 set2]
@@ -144,30 +159,7 @@
(fake (intersection "some set" "some disjoint set") => #{}))
"For overlapping sets, return the intersection"
(expect (set-handler "set" "overlapping set") => #{"intersection"}
- (fake (intersection "set" "overlapping set") => #{"intersection"}))
-)
-
-
-;; My development style is "programming by wishful thinking"
-;; (Sussman). Suppose I'm writing function (quux). If I hit anything
-;; hard, I say "I really really believe there's already a function
-;; (frozzle) that does just what I need". I then fake (frozzle) until
-;; I'm done writing (quux). Later I'll get around to writing
-;; (frozzle). In the meantime I need to define it somehow. Preferably
-;; I'll define it in a way that will make it really obvious what
-;; happens if I try to run the whole program before I've got a real
-;; (frozzle). The way (declare) fails is not revealing enough. So I
-;; use this:
-
-(only-mocked frozzle another-function)
-
-;; If I call (frozzle), I get this:
-;; Exception in thread "main" java.lang.Error: frozzle has no
-;; implementation. It's used in mock tests. (core_test.clj:1)
-
-
-
-
+ (fake (intersection "set" "overlapping set") => #{"intersection"})))
(defn test-ns-hook []
"This calls the functions in order."
View
@@ -1,4 +1,4 @@
-(defproject midje "1.0.1"
+(defproject midje "1.1-alpha-1"
:description "A TDD library for Clojure, with an emphasis on mocks"
:dependencies [[org.clojure/clojure "1.2.0"]
[org.clojure/clojure-contrib "1.2.0"]

0 comments on commit b8bb742

Please sign in to comment.