Fail random generation of range contracts with bad bounds
This commit is contained in:
parent
f1fb22f0a7
commit
7f34da35e7
|
@ -245,7 +245,9 @@
|
|||
(exn-message x))))
|
||||
(check-exn cannot-generate-exn? (λ () (test-contract-generation some-crazy-predicate?)))
|
||||
(check-exn cannot-generate-exn? (λ () (test-contract-generation (list/c some-crazy-predicate?))))
|
||||
|
||||
(check-exn cannot-generate-exn? (λ () (test-contract-generation (between/c 10 0))))
|
||||
(check-exn cannot-generate-exn? (λ () (test-contract-generation (integer-in 10 0))))
|
||||
(check-exn cannot-generate-exn? (λ () (test-contract-generation (char-in #\z #\a))))
|
||||
|
||||
(check-not-exn (lambda () (test-contract-generation (or/c #f number?))))
|
||||
(check-not-exn (lambda () (test-contract-generation (first-or/c #f number?))))
|
||||
|
|
|
@ -348,9 +348,11 @@
|
|||
[(or start end)
|
||||
(define _start (or start (- end max-random-range)))
|
||||
(define _end (or end (+ start max-random-range)))
|
||||
(define upper-bound (min 4294967087 (+ (- _end _start) 1)))
|
||||
(λ (fuel)
|
||||
(λ ()
|
||||
(+ _start (random (min 4294967087 (+ (- _end _start) 1))))))]
|
||||
(and (>= upper-bound 1)
|
||||
(λ ()
|
||||
(+ _start (random upper-bound)))))]
|
||||
[else
|
||||
(λ (fuel)
|
||||
(λ ()
|
||||
|
|
|
@ -723,8 +723,9 @@
|
|||
(define high (char->integer (char-in/c-high ctc)))
|
||||
(define delta (+ (- high low) 1))
|
||||
(λ (fuel)
|
||||
(λ ()
|
||||
(integer->char (+ low (random delta))))))))
|
||||
(and (>= delta 1)
|
||||
(λ ()
|
||||
(integer->char (+ low (random delta)))))))))
|
||||
|
||||
(define (regexp/c-equivalent this that)
|
||||
(and (regexp/c? that)
|
||||
|
|
|
@ -127,6 +127,7 @@
|
|||
(* 1.0 choice)
|
||||
choice))]
|
||||
[else choice]))]
|
||||
[(> n m) #f]
|
||||
[else
|
||||
(λ ()
|
||||
(rand-choice
|
||||
|
|
Loading…
Reference in New Issue
Block a user