- (matcher (check (subject) check-code) (message (form subject negate) message-code))syntax
This creates a fresh matcher object. You need to implement both the check and the message.
- check The check is a procedure that receives one argument, the subject. The subject is a promise so you need to force it if you want to retrieve the value.
- message This is the procedure that is invoked to generate the message. It receives three arguments
- form This is the quoted form that was passed to expect
- subject This is the subject. Again this is a promise so you need to force it to retrieve the actual value.
- negate Indicates if the check shall be negated. This is set to true if the expect-form has been wrapped into a (do-not) form.
(define (greater-than x) (matcher (check (subject) (> (force subject) x)) (message (form subject negate) (if negate (sprintf "Expected ~A to be less than or equal to ~A" (force subject) x) (sprintf "Expected ~A to be greater than ~A" (force subject) x))))) (expect 10 (be (greater-than 5)))