Make contracted unit tests pass
This commit is contained in:
parent
900d2b0be0
commit
b869f18f1c
|
@ -5,10 +5,13 @@
|
|||
racket/list
|
||||
racket/match
|
||||
(rep type-rep filter-rep)
|
||||
(types abbrev subtype tc-result))
|
||||
(except-in (types abbrev subtype tc-result)
|
||||
-> ->* one-of/c))
|
||||
|
||||
(provide possible-domains
|
||||
cleanup-type)
|
||||
(provide possible-domains)
|
||||
|
||||
(provide/cond-contract
|
||||
[cleanup-type ((Type/c) ((or/c #f Type/c) any/c) . ->* . Type/c)])
|
||||
|
||||
;; to avoid long and confusing error messages, in the case of functions with
|
||||
;; multiple similar domains (<, >, +, -, etc.), we show only the domains that
|
||||
|
@ -144,8 +147,6 @@
|
|||
list)]))
|
||||
|
||||
;; Wrapper over possible-domains that works on types.
|
||||
(provide/cond-contract
|
||||
[cleanup-type ((Type/c) ((or/c #f Type/c) any/c) . ->* . Type/c)])
|
||||
(define (cleanup-type t [expected #f] [permissive? #t])
|
||||
(match t
|
||||
;; function type, prune if possible.
|
||||
|
|
|
@ -75,9 +75,11 @@
|
|||
(define (make-printable t)
|
||||
(match t
|
||||
[(tc-result1: t) (cleanup-type t)]
|
||||
[(tc-results: ts) (-values (map cleanup-type ts))]
|
||||
[(or (tc-results: ts)
|
||||
(tc-results: ts _ _ _ _))
|
||||
(-values (map cleanup-type ts))]
|
||||
[(tc-any-results: f) (-AnyValues -top)]
|
||||
[_ (cleanup-type t)]))
|
||||
[_ t]))
|
||||
|
||||
(define (stringify-domain dom rst drst [rng #f])
|
||||
(let ([doms-string (if (null? dom) "" (string-append (stringify (map make-printable dom)) " "))]
|
||||
|
@ -178,13 +180,12 @@
|
|||
return]
|
||||
[else
|
||||
;; if not, print the message as usual
|
||||
(define pdoms* (map make-printable pdoms))
|
||||
(define err-doms
|
||||
(string-append
|
||||
label
|
||||
(stringify (if expected
|
||||
(map stringify-domain pdoms* rests drests rngs)
|
||||
(map stringify-domain pdoms* rests drests))
|
||||
(map stringify-domain pdoms rests drests rngs)
|
||||
(map stringify-domain pdoms rests drests))
|
||||
nl+spc)
|
||||
"\nArguments: "
|
||||
arguments-str
|
||||
|
|
Loading…
Reference in New Issue
Block a user