Fix default fallback for contract-struct-generate
The actual problem is that build-chaperone-contract-property exported to the user defaults #:exercise and #:generate to false. This commit changes the default fallback value in the case where #:generate is not a procedure instead of changing build-chaperone-contract-property directly to stay consistent with the how contract-struct-exercise currently does it.
This commit is contained in:
parent
aeab2420fa
commit
0c8c643989
|
@ -435,12 +435,20 @@
|
|||
#:late-neg-projection
|
||||
(λ (ctc) (λ (b) (λ (v np) v)))))
|
||||
(define impersonate-any/c (impersonate-any/c-struct))
|
||||
(struct chaperone-proc?/c-struct ()
|
||||
#:property prop:chaperone-contract
|
||||
(build-chaperone-contract-property
|
||||
#:late-neg-projection
|
||||
(λ (ctc) (λ (b) (λ (v np) v)))))
|
||||
(define chaperone-proc?/c (chaperone-proc?/c-struct))
|
||||
(check-exn cannot-generate-exn? (λ () (test-contract-generation impersonate-any/c)))
|
||||
(check-exn cannot-generate-exn?
|
||||
(λ ()
|
||||
(test-contract-generation
|
||||
(->i ([n integer?])
|
||||
[_ (n) (λ (r) (eq? r (even? n)))])))))
|
||||
[_ (n) (λ (r) (eq? r (even? n)))]))))
|
||||
;; Testing the default return value for contract-struct-generate
|
||||
(check-exn cannot-generate-exn? (λ () (test-contract-generation chaperone-proc?/c))))
|
||||
|
||||
(check-exercise
|
||||
10
|
||||
|
|
|
@ -199,7 +199,7 @@
|
|||
(define generate (contract-property-generate prop))
|
||||
(if (procedure? generate)
|
||||
(generate c)
|
||||
#f))
|
||||
(λ (fuel) #f)))
|
||||
|
||||
(define (contract-struct-exercise c)
|
||||
(define prop (contract-struct-property c))
|
||||
|
|
Loading…
Reference in New Issue
Block a user