From 7e88895bd03fed78028fc79c34856f162c7ba06b Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Sat, 16 Feb 2013 14:31:01 -0800 Subject: [PATCH] Add testcases for many already fixed bugs. Closes PR11901. Closes PR11972. Closes PR12022. Closes PR12224. Closes PR12506. Closes PR12533. Closes PR12596. Closes PR13198. Closes PR13418. Already fixed bugs, with existing testcases. Closes PR12529. Closes PR12631. Closes PR13127. Closes PR13128. Closes PR12970. --- collects/tests/typed-racket/succeed/for.rkt | 14 ++++++++++++++ collects/tests/typed-racket/succeed/pr11901.rkt | 3 +++ collects/tests/typed-racket/succeed/pr12224.rkt | 11 +++++++++++ .../tests/typed-racket/succeed/submod-vector.rkt | 10 ++++++++++ .../typed-racket/unit-tests/typecheck-tests.rkt | 12 ++++++++++++ 5 files changed, 50 insertions(+) create mode 100644 collects/tests/typed-racket/succeed/pr11901.rkt create mode 100644 collects/tests/typed-racket/succeed/pr12224.rkt create mode 100644 collects/tests/typed-racket/succeed/submod-vector.rkt diff --git a/collects/tests/typed-racket/succeed/for.rkt b/collects/tests/typed-racket/succeed/for.rkt index 1eb585d693..86493319d3 100644 --- a/collects/tests/typed-racket/succeed/for.rkt +++ b/collects/tests/typed-racket/succeed/for.rkt @@ -213,6 +213,20 @@ (for: ([x 10] #:unless (> x 3)) (display x)))) "0123") +(check equal? + (for/hasheq: : (HashTable Integer String) ([k (list 2 3 4)]) (values k "val")) + #hasheq((2 . "val") (3 . "val") (4 . "val"))) + +(check equal? + (for/vector: ([i : Natural (in-range 3)]) 5) + (vector 5 5 5)) + +(check equal? + (for/vector: : (Vectorof Number) ([i : Natural (in-range 3)]) 5) + (vector 5 5 5)) + + + ;; break and final clauses ;; TODO typechecker can't handle these ;; (check string=? diff --git a/collects/tests/typed-racket/succeed/pr11901.rkt b/collects/tests/typed-racket/succeed/pr11901.rkt new file mode 100644 index 0000000000..5e269ea187 --- /dev/null +++ b/collects/tests/typed-racket/succeed/pr11901.rkt @@ -0,0 +1,3 @@ +#lang typed/racket/base +(define-type (adder lhs rhs) (lhs rhs -> Number)) +(define-struct: (lhs rhs) adder-box ((a : adder))) diff --git a/collects/tests/typed-racket/succeed/pr12224.rkt b/collects/tests/typed-racket/succeed/pr12224.rkt new file mode 100644 index 0000000000..6975ae1f35 --- /dev/null +++ b/collects/tests/typed-racket/succeed/pr12224.rkt @@ -0,0 +1,11 @@ +#lang racket/load + +(module t1 typed/racket/base + (provide (all-defined-out)) + (define-struct: f ([n : ((Promise Number) -> Number)]))) + +(module t2 typed/racket/base + (require racket/promise 't1) + (: g (f (Promise Number) -> Number)) + (define (g fx k) + ((f-n fx) k))) diff --git a/collects/tests/typed-racket/succeed/submod-vector.rkt b/collects/tests/typed-racket/succeed/submod-vector.rkt new file mode 100644 index 0000000000..19d439e845 --- /dev/null +++ b/collects/tests/typed-racket/succeed/submod-vector.rkt @@ -0,0 +1,10 @@ +#lang racket +(module test typed/racket + (provide v-ref) + + (: v-ref ((Vectorof Symbol) Index -> Symbol)) + (define (v-ref v i) (vector-ref v i))) + +(require (submod "." test)) + +(v-ref (vector 'foo) 0) diff --git a/collects/tests/typed-racket/unit-tests/typecheck-tests.rkt b/collects/tests/typed-racket/unit-tests/typecheck-tests.rkt index 0f3bf4f5f8..bd35e73fb9 100644 --- a/collects/tests/typed-racket/unit-tests/typecheck-tests.rkt +++ b/collects/tests/typed-racket/unit-tests/typecheck-tests.rkt @@ -1546,6 +1546,18 @@ [tc-e ((inst list Any) 1 2 3) (-lst Univ)] + [tc-e (let () + (define f + (lambda: ((x : Boolean) (y : String)) + (if x y "false"))) + (apply f (list #f "2"))) + -String] + [tc-err (let () + (: f (All (i ...) Any -> (values Any ... i))) + (define (f x) (values 1 2)))] + [tc-err (let () + (: g (All (i ...) Any -> (values Any ... i))) + (define (g x) 2))] ) (test-suite "check-type tests"