Recognize cons? and empty? in contract coercion
This commit is contained in:
parent
f5eb600dd7
commit
3825a133ad
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
(require racket/contract
|
(require racket/contract
|
||||||
racket/contract/private/generate-base
|
racket/contract/private/generate-base
|
||||||
|
(only-in racket/list empty? cons?)
|
||||||
rackunit
|
rackunit
|
||||||
racket/math
|
racket/math
|
||||||
(for-syntax racket/base))
|
(for-syntax racket/base))
|
||||||
|
@ -112,6 +113,21 @@
|
||||||
(test-contract-generation
|
(test-contract-generation
|
||||||
null?)))
|
null?)))
|
||||||
|
|
||||||
|
(check-not-exn
|
||||||
|
(λ ()
|
||||||
|
(test-contract-generation
|
||||||
|
empty?)))
|
||||||
|
|
||||||
|
(check-not-exn
|
||||||
|
(λ ()
|
||||||
|
(test-contract-generation
|
||||||
|
pair?)))
|
||||||
|
|
||||||
|
(check-not-exn
|
||||||
|
(λ ()
|
||||||
|
(test-contract-generation
|
||||||
|
cons?)))
|
||||||
|
|
||||||
(check-not-exn
|
(check-not-exn
|
||||||
(λ ()
|
(λ ()
|
||||||
(test-contract-generation
|
(test-contract-generation
|
||||||
|
|
|
@ -366,12 +366,14 @@
|
||||||
[(and (procedure? x) (procedure-arity-includes? x 1))
|
[(and (procedure? x) (procedure-arity-includes? x 1))
|
||||||
(cond
|
(cond
|
||||||
[(chaperone-of? x null?) list/c-empty]
|
[(chaperone-of? x null?) list/c-empty]
|
||||||
|
[(chaperone-of? x empty?) list/c-empty]
|
||||||
[(chaperone-of? x list?)
|
[(chaperone-of? x list?)
|
||||||
(unless listof-any
|
(unless listof-any
|
||||||
(error 'coerce-contract/f::listof-any "too soon!"))
|
(error 'coerce-contract/f::listof-any "too soon!"))
|
||||||
listof-any]
|
listof-any]
|
||||||
[(chaperone-of? x boolean?) boolean?/c]
|
[(chaperone-of? x boolean?) boolean?/c]
|
||||||
[(chaperone-of? x pair?)
|
[(or (chaperone-of? x pair?)
|
||||||
|
(chaperone-of? x cons?))
|
||||||
(unless consc-anyany
|
(unless consc-anyany
|
||||||
(error 'coerce-contract/f::consc-anyany "too soon!"))
|
(error 'coerce-contract/f::consc-anyany "too soon!"))
|
||||||
consc-anyany]
|
consc-anyany]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user