Question about contracts: trying to randomly generate some hash inputs like so:
(contract-random-generate (hash/c integer? boolean?))But cannot:
> (contract-random-generate (hash/c integer? boolean?))
; contract-random-generate: unable to construct any generator for contract:
; (hash/c integer? boolean?) [,bt for context]How would I do this?
@d_run that sounds like hashes are unsupported
probably relatively easy to add in racket/contract/private/hash.rkt
An indirect workaround: (make-immutable-hash (contract-random-generate (listof (cons/c integer? boolean?))))
with raco setup is there a way to just recompile the <collects>/racket/private/contract ?
something like raco setup -l collects/racket/private/contract ?
@d_run raco setup racket/private/contract
hmmm
$ ./racket/bin/raco setup racket/private/contract
collection-path: collection not found
collection: "racket/private/contract"
in collection directories:
/Users/shibuya/Library/Racket/development/collects
/Users/shibuya/github/racket/racket/collects
... [184 additional linked and package directories]ah, you transposed private and contract from my original message to your question
derp
yah that got it - thanks
@d_run Another workaround would be to use flat-named-contract to attach a generator function. If you need an even more general workaround, you could acomplish the same thing with make-contract, prop:contract, etc. (But it would be great to add generation support to hash/c!)
well I seem to be stumbling onto something
$ ./racket/bin/racket -i
Welcome to Racket v7.0.0.17.
> (require racket/contract)
> (contract-random-generate (hash/c number? (listof number?)))
'#hash((0 . (0 1.308710636691283e-07)))> (contract-random-generate (hash/c number? (hash/c number? string?)))
'#hash((-150.0-2147483647.0i
.
#hash((-2147483647.0-185.0i
.
"\uA7CBጚ䛡\U000351CD𫑫\U000B46B6\U000FAAC2\U0008DD1F\U000AA812⛕\U0010D6B6\U000D8D2B\U00048EBE㷎\U00035091𩣲Ų볈⢍읿ଓ愒妙\U0009F757㏥\U00072BE1彞辯逰能\U0005F69E뮝\U0004ACA7\U00071BC1\U00099D0F𧎝ᐾ\U00093943㜷\U0001F964髣\U00062741꧖粫\U00065E50\U00087B85\U000D696F\U000C8D02\U00046E0D\U000BE119魥\U00013BFF\U000A502D\U0009C413㍡刬ᑨ\U000CD8EC鵸\U000342E6ⷲꪌ㔱\U0003579F\U000E3620똠\U000459D9죄膅骖䎷駥\U000D72A8\U000A201E\U000BFD8E\U000FC781\U00052888᧳玠u逫煃ᨠ鷊\U0008B647遤縙髆ᇪ🞛\U00056173\U0009FDD4\U000B2F5A熑藬\U000F4E9B\U00067EF7\U0002DAA6"))))that looks correct
need to write tests, run tests, etc - then will try and get a PR ready
Where would I find tests for the contracts?
ah cool! figured it was in a pkg but couldn’t find it, thanks
and ./racket/bin/raco test -l tests/racket/test would run those right?
ah looks like $ ./racket/bin/raco test -m ~/github/racket/pkgs/racket-test/tests/racket/contract will just run the contracts
I usually just run the all.rkt file in that directory as racket all.rkt which should run them all, you should be able to run individual test files the same way
ah cool thanks