4 Boolean and Logic Expectations
value
value
value
> (expect! 'foo expect-true) expected true
subject: 'foo
expected: #t
actual: 'foo
> (expect! 'foo expect-false) expected false
subject: 'foo
expected: #f
actual: 'foo
> (expect! 'foo expect-not-false) > (expect! #f expect-not-false) expected not false
subject: #f
expected: not #f
actual: #f
procedure
(expect-pred pred) → expectation?
pred : predicate/c
> (expect! 10 (expect-pred number?)) > (expect! 'foo (expect-pred number?)) expected a different kind of value
subject: 'foo
expected: number?
actual: 'foo
procedure
(expect-all exp ...) → expectation?
exp : expectation?
> (define positive-even (expect-all (expect-pred positive?) (expect-pred even?))) > (expect! 4 positive-even) > (expect! 7 positive-even) expected a different kind of value
subject: 7
expected: even?
actual: 7
> (expect! -4 positive-even) expected a different kind of value
subject: -4
expected: positive?
actual: -4
> (expect! -7 positive-even) multiple failures
subject: -7
fault: expected a different kind of value
expected: positive?
actual: -7
fault: expected a different kind of value
expected: even?
actual: -7
procedure
(expect-and exp ...) → expectation?
exp : expectation?
> (define (small? x) (< x 10))
> (define small-number (expect-and (expect-pred real?) (expect-pred positive?) (expect-pred small?))) > (expect! 5 small-number) > (expect! 20 small-number) expected a different kind of value
subject: 20
expected: small?
actual: 20
> (expect! -4 small-number) expected a different kind of value
subject: -4
expected: positive?
actual: -4
> (expect! 'foo small-number) expected a different kind of value
subject: 'foo
expected: real?
actual: 'foo
procedure
(expect-conjoin pred ...) → expectation?
pred : predicate/c
procedure
(expect-disjoin pred ...) → expectation?
pred : predicate/c
> (define exp-str-or-sym (expect-disjoin string? symbol?)) > (expect! "foo" exp-str-or-sym) > (expect! 'foo exp-str-or-sym) > (expect! 42 exp-str-or-sym) expected a different kind of value
subject: 42
expected: string? or symbol?
actual: 42
4.1 Boolean Attributes
struct
(struct not-attribute attribute (negated) #:transparent) negated : attribute?
procedure
(make-not-attribute negated) → not-attribute?
negated : attribute?
struct
(struct pred-attribute attribute (value) #:transparent) value : predicate/c
procedure
(make-pred-attribute value) → pred-attribute?
value : predicate/c
struct
(struct and-attribute attribute (cases) #:transparent) cases : (listof attribute?)
procedure
(make-and-attribute cases [ #:description desc]) → and-attribute? cases : (listof attribute?) desc : (or/c string? #f) = #f
struct
(struct or-attribute attribute (cases) #:transparent) cases : (listof attribute?)
procedure
(make-or-attribute cases [ #:description desc]) → or-attribute? cases : (listof attribute?) desc : (or/c string? #f) = #f