Thanks for the examples!!<div>I was able to construct arbitrary lists, which is what I needed.</div><div><br></div><div>Some feedback you might find useful:</div><div><br></div><div>I wanted to create a list with fixed length and arbitrary integers, and I think it can't be done with the public API.</div>
<div>My idea was to use (choose-list arbitrary-integer 100), but arbitrary-integer is not a generator. My solution was to export arbitrary-generator and create the list using</div><div>(choose-list (arbitrary-generator arbitrary-integer) 100).</div>
<div><br></div><div>Is there a recommended way for user-defined generators?</div><div>I have a language grammar defined with PLAI's define-type, and was wondering how to create a generator for random programs (even if they are ill-typed).</div>
<div><br></div><div>Nevertheless I think your quickcheck library is cool, and would love to see it as part of the Racket distribution. (so much that I offer to help writing docs :)</div><div><br></div><div>Thanks<br><br><div class="gmail_quote">
2012/8/17 Michael Sperber <span dir="ltr"><<a href="mailto:sperber@deinprogramm.de" target="_blank">sperber@deinprogramm.de</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im"><br>
Ismael Figueroa Palet <<a href="mailto:ifigueroap@gmail.com">ifigueroap@gmail.com</a>> writes:<br>
<br>
</div><div class="im">> I copied the quickcheck folder to my project, but I don't know how to use<br>
> it :-(<br>
> do you have any examples of how to use it? do I need to copy other<br>
> collects, or do I have to use the full deinprogramm language?<br>
<br>
</div>No, you don't. It can be used as a library.<br>
<br>
Here's a few examples I use for testing (which can be run using<br>
`(quickcheck <property>)'):<br>
<br>
(define rev-app/<br>
(property ((xs (arbitrary-list arbitrary-integer))<br>
(ys (arbitrary-list arbitrary-integer)))<br>
(equal? (reverse (append xs ys)) (append (reverse ys) (reverse xs)))))<br>
<br>
(define broken-rev-app/<br>
(property ((xs (arbitrary-list arbitrary-integer))<br>
(ys (arbitrary-list arbitrary-integer)))<br>
(equal? (reverse (append ys xs)) (append (reverse ys) (reverse xs)))))<br>
<br>
(define char->integer/<br>
(property ((ch arbitrary-char))<br>
(char=? ch (integer->char (char->integer ch)))))<br>
<br>
(define string->list/<br>
(property ((str arbitrary-string))<br>
(string=? str (list->string (string->list str)))))<br>
<br>
(define vector->list/<br>
(property ((vec (arbitrary-vector arbitrary-integer)))<br>
(equal? vec (list->vector (vector->list vec)))))<br>
<br>
(define map-append/<br>
(property ((proc (arbitrary-procedure arbitrary-integer arbitrary-char))<br>
(xs (arbitrary-list arbitrary-char))<br>
(ys (arbitrary-list arbitrary-char)))<br>
(equal? (map proc (append xs ys))<br>
(append (map proc xs) (map proc ys)))))<br>
<br>
(define ttt/<br>
(property ((a (arbitrary-record cons (list car cdr) arbitrary-integer arbitrary-integer)))<br>
(write (list 'aaa a)) (newline)<br>
#t))<br>
<br>
(define max-le/<br>
(property ((x arbitrary-integer)<br>
(y arbitrary-integer))<br>
(==> (<= x y)<br>
(= (max x y) y))))<br>
<br>
(define insert1/<br>
(property ((x arbitrary-integer)<br>
(xs (arbitrary-list arbitrary-integer)))<br>
(==> (list-sorted? xs <)<br>
(trivial (null? xs)<br>
(list-sorted? (insert < x xs) <)))))<br>
<br>
(define insert2/<br>
(property ((x arbitrary-integer)<br>
(xs (arbitrary-list arbitrary-integer)))<br>
(==> (list-sorted? xs <)<br>
(collect (length xs)<br>
(list-sorted? (insert < x xs) <)))))<br>
<br>
(define (insert <= x xs)<br>
(cond<br>
((null? xs) (list x))<br>
((<= x (car xs))<br>
(cons x xs))<br>
(else<br>
(cons (car xs) (insert <= x (cdr xs))))))<br>
<br>
; This only tests whether the coarbitrary of arbitrary-real works in<br>
; acceptable time.<br>
(define xxx/<br>
(property ((x arbitrary-real)<br>
(p (arbitrary-procedure arbitrary-boolean arbitrary-real)))<br>
(or (p x)<br>
(not (p x)))))<br>
<br>
(define non-assoc/<br>
(property ((a arbitrary-real)<br>
(b arbitrary-real)<br>
(c arbitrary-real))<br>
(= (+ (+ a b) c)<br>
(+ a (+ b c)))))<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Cheers =8-} Mike<br>
Friede, Völkerverständigung und überhaupt blabla<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>Ismael<br><br>
</div>