-
Notifications
You must be signed in to change notification settings - Fork 128
Transitional prerequisite checkers
marick edited this page Feb 3, 2011
·
1 revision
Checkers within prerequisites explains how things will work in version 1.2. What about now?
Your facts will be future proof if you follow this rule:
-
If you want a function to be treated as a checker, use a predefined checker, wrap your checking form in
as-checker
or define it withchecker
ordefchecker
. -
If you want your function to be treated the same as a literal value (the same way that
1
, for example, would be treated) wrap it inexactly
.
Don't use bare functions.
Examples:
(fact
(f 1) => 1
(provided (g (as-checker even?)) => 33) ; will always work.
(fact
(f 1) => 1
(provided (filter (exactly even?) [4 5]) => [4]) ; will always work.
(fact
(f 1) => 1
(provided (g even?) => 33)
;; In Midje <1.2, this accepts any even argument to g.
;; In Midje >= 1.2, this accepts *only* the even? function.