rename contract-generate to contract-random-generate

This commit is contained in:
Robby Findler 2011-11-25 09:08:50 -06:00
parent 989fcc4c22
commit e0ea64c758
3 changed files with 12 additions and 10 deletions

View File

@ -548,7 +548,7 @@ v4 todo:
[gen-if-fun (λ (c v)
; If v is a function we need to gen the domain and call
(if (procedure? v)
(let ([newargs (map (λ (c) (contract-generate c new-fuel))
(let ([newargs (map (λ (c) (contract-random-generate c new-fuel))
(base->-doms/c c))])
(let* ([result (call-with-values
(λ () (apply v newargs))

View File

@ -9,7 +9,7 @@
(provide generate-env
env-stash
contract-generate
contract-random-generate
generate/direct
generate/choose
@ -101,11 +101,13 @@
(generate/direct ctc fuel)))
; generate : contract int -> ctc value or error
(define (contract-generate ctc fuel [fail (λ ()
(error 'contract-generate
"Unable to construct any generator for contract: ~s"
(contract-struct-name (coerce-contract 'contract-generate ctc))))])
(let ([def-ctc (coerce-contract 'contract-generate ctc)])
(define (contract-random-generate ctc fuel
[fail (λ ()
(error 'contract-random-generate
"Unable to construct any generator for contract: ~s"
(contract-struct-name
(coerce-contract 'contract-random-generate ctc))))])
(let ([def-ctc (coerce-contract 'contract-random-generate ctc)])
(printf "def-ctc ~s\n" def-ctc)
(parameterize ([generate-env (make-hash)])
; choose randomly

View File

@ -2089,10 +2089,10 @@ parts of the contract system.
}
@section{Random generation}
@defproc[(contract-generate [ctc contract?] [fuel int?] [fail (-> any/c) (λ () (error ...))]) any/c]{
@defproc[(contract-random-generate [ctc contract?] [fuel int?] [fail (-> any/c) (λ () (error ...))]) any/c]{
Attempts to randomly generate a value which will match the contract. The fuel
argument limits how hard the generator tries to generate a contract and is a rough
limit of the size of the resulting value.
argument limits how hard the generator tries to generate a value matching the
contract and is a rough limit of the size of the resulting value.
The generator may fail to generate a contract, either because some contracts
do not have corresponding generators (for example, not all predicates have