fixing docs and tests for maybe/c (old option/c)

This commit is contained in:
chrdimo 2013-01-28 16:55:33 -05:00
parent c8bee5acf7
commit 5348a4d2de
2 changed files with 18 additions and 18 deletions

View File

@ -38,31 +38,31 @@
(in-dict (list (cons 1 'one) (cons 2 'two))))]) (in-dict (list (cons 1 'one) (cons 2 'two))))])
(void))))) (void)))))
(test-suite "Data structure contracts" (test-suite "Data structure contracts"
(test-suite "option/c" (test-suite "maybe/c"
(test-true "flat" (flat-contract? (option/c number?))) (test-true "flat" (flat-contract? (maybe/c number?)))
(test-true "chaperone" (chaperone-contract? (option/c (box/c number?)))) (test-true "chaperone" (chaperone-contract? (maybe/c (box/c number?))))
(test-true "impersonator" (impersonator-contract? (option/c (object/c)))) (test-true "impersonator" (impersonator-contract? (maybe/c (object/c))))
(test-ok (with/c (option/c number?) 0)) (test-ok (with/c (maybe/c number?) 0))
(test-ok (with/c (option/c number?) #f)) (test-ok (with/c (maybe/c number?) #f))
(test-ok (with/c (option/c (-> number? number?)) #f)) (test-ok (with/c (maybe/c (-> number? number?)) #f))
(test-ok (with/c (option/c (-> number? number?)) +)) (test-ok (with/c (maybe/c (-> number? number?)) +))
(test-ok (with/c (option/c (class/c (field [x number?]))) (test-ok (with/c (maybe/c (class/c (field [x number?])))
(class object% (super-new) (field [x 0])))) (class object% (super-new) (field [x 0]))))
(test-ok (with/c (option/c (class/c (field [x number?]))) #f)) (test-ok (with/c (maybe/c (class/c (field [x number?]))) #f))
(test-ok (with/c (class/c (field [c (option/c string?)])) (test-ok (with/c (class/c (field [c (maybe/c string?)]))
(class object% (super-new) (field [c #f])))) (class object% (super-new) (field [c #f]))))
(test-bad (with/c (option/c number?) "string")) (test-bad (with/c (maybe/c number?) "string"))
(test-bad (with/c (option/c (-> number? number?)) (test-bad (with/c (maybe/c (-> number? number?))
(lambda (x y) x))) (lambda (x y) x)))
(test-bad (test-bad
([with/c (option/c (-> number? number?)) ([with/c (maybe/c (-> number? number?))
(lambda (x) (void))] (lambda (x) (void))]
0)) 0))
(test-bad (with/c (option/c (class/c (field [x number?]))) (test-bad (with/c (maybe/c (class/c (field [x number?])))
(class object% (super-new)))) (class object% (super-new))))
(test-bad (with/c (option/c (class/c (field [x number?]))) 5)) (test-bad (with/c (maybe/c (class/c (field [x number?]))) 5))
(test-bad (test-bad
(get-field c (with/c (class/c (field [c (option/c string?)])) (get-field c (with/c (class/c (field [c (maybe/c string?)]))
(class object% (class object%
(super-new) (super-new)
(field [c 70]))))))))) (field [c 70])))))))))

View File

@ -72,7 +72,7 @@ flat contract.
@addition{Asumu Takikawa} @addition{Asumu Takikawa}
@defproc[(option/c [contract contract?]) contract?]{ @defproc[(maybe/c [contract contract?]) contract?]{
Creates a contract that acts like @racket[contract] but will also Creates a contract that acts like @racket[contract] but will also
accept @racket[#f]. Intended to describe situations where a failure accept @racket[#f]. Intended to describe situations where a failure