From 4a869d97d19059828e8a8f36c1e48cd715c79fc2 Mon Sep 17 00:00:00 2001 From: Andrew Kent Date: Fri, 10 Nov 2017 12:02:35 -0500 Subject: [PATCH] update check-duplicates with #:default kw arg --- .../typed-racket/base-env/base-env.rkt | 18 +++++++++++++++--- .../unit-tests/typecheck-tests.rkt | 16 ++++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/typed-racket-lib/typed-racket/base-env/base-env.rkt b/typed-racket-lib/typed-racket/base-env/base-env.rkt index 5b52797b..59db5f45 100644 --- a/typed-racket-lib/typed-racket/base-env/base-env.rkt +++ b/typed-racket-lib/typed-racket/base-env/base-env.rkt @@ -3323,10 +3323,22 @@ (->key (-lst a) (-> b b -Boolean) #:key (-> a b) #f #:cache-keys? -Boolean #f (-lst a))))) (check-duplicates (-poly - (a b) + (a b c) (cl->* - (->optkey (-lst a) ((-> a a Univ)) #:key (-> a a) #f (-opt a)) - (->optkey (-lst a) ((-> b b Univ)) #:key (-> a b) #f (-opt a))))) + (->optkey (-lst a) ((-> a a Univ)) + #:key (-> a a) #f + (-opt a)) + (->optkey (-lst a) ((-> b b Univ)) + #:key (-> a b) #f + (-opt a)) + (->optkey (-lst a) ((-> a a Univ)) + #:key (-> a a) #f + #:default (-> c) #f + (Un a c)) + (->optkey (-lst a) ((-> b b Univ)) + #:key (-> a b) #f + #:default (-> c) #f + (Un a c))))) (remove-duplicates (-poly (a b) diff --git a/typed-racket-test/unit-tests/typecheck-tests.rkt b/typed-racket-test/unit-tests/typecheck-tests.rkt index 0e0dc20f..709ae7e8 100644 --- a/typed-racket-test/unit-tests/typecheck-tests.rkt +++ b/typed-racket-test/unit-tests/typecheck-tests.rkt @@ -1439,6 +1439,22 @@ [tc-e (remf symbol? '(a b c)) (-lst (one-of/c 'a 'b 'c))] [tc-e (remf* symbol? '(a b c)) (-lst (one-of/c 'a 'b 'c))] [tc-e (check-duplicates '("a" "a" "b")) (-opt -String)] + [tc-e (check-duplicates '("a" "a" "b") string=?) (-opt -String)] + ;[tc-e ((inst check-duplicates String Number) + ; '("a" "aa" "aaa") + ; #:key string-length) + ; (-opt -String)] + [tc-e ((inst check-duplicates String Any 'nope) + '("a" "a" "b") + string=? + #:default (λ () 'nope)) + (Un (-val 'nope) -String)] + [tc-e ((inst check-duplicates String Number 'nope) + '("Hello" "world") + = + #:key string-length + #:default (λ () 'nope)) + (Un -String (-val 'nope))] ;;Path tests (tc-e (path-string? "foo") -Boolean)