From 888893d81bbb0fb58f9650378cc9569861c235ba Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Thu, 12 Feb 2015 15:36:04 -0500 Subject: [PATCH] Work around type alias printing limitations Type aliases in internal definition contexts can affect type printing outside of the context, which can cause interference in unit tests. This only seems to happen when running with the TR test driver. --- typed-racket-test/unit-tests/class-tests.rkt | 21 +++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/typed-racket-test/unit-tests/class-tests.rkt b/typed-racket-test/unit-tests/class-tests.rkt index 6a8f77c3..0acc8dc2 100644 --- a/typed-racket-test/unit-tests/class-tests.rkt +++ b/typed-racket-test/unit-tests/class-tests.rkt @@ -1965,39 +1965,42 @@ ;; let-aliasing + occ. typing on fields (let ([y x]) (if (string? y) (string-append x) ""))) (-class)] + ;; Failure tests for occurrence typing on private fields. The types + ;; are obfuscated a bit to prevent interference from type aliases in + ;; another test. [tc-err (let () (define c% (class object% (super-new) - (: x (U String #f)) + (: x (U String 'obfuscate)) (define x "foo") - (set! x #f) ; prevents occ. typing + (set! x 'obfuscate) ; prevents occ. typing (: m (-> String)) (define/public (m) (if (string? x) (string-append x "bar") "baz")))) (error "foo")) - #:msg #rx"expected: String.*given: \\(U False String\\)"] + #:msg #rx"expected: String.*given: \\(U String 'obfuscate\\)"] [tc-err (let () (define c% (class object% (super-new) - (: x (U String #f)) + (: x (U String 'obfuscate)) (define x "foo") - (field [f (begin (set! x #f) "hello")]) + (field [f (begin (set! x 'obfuscate) "hello")]) (: m (-> String)) (define/public (m) (if (string? x) (string-append x "bar") "baz")))) (error "foo")) - #:msg #rx"expected: String.*given: \\(U False String\\)"] + #:msg #rx"expected: String.*given: \\(U String 'obfuscate\\)"] [tc-err (let () (define c% (class object% (super-new) - (: x (U String #f)) + (: x (U String 'obfuscate)) (define x "foo") - (define/public (n) (set! x #f)) + (define/public (n) (set! x 'obfuscate)) (: m (-> String)) (define/public (m) (if (string? x) (string-append x "bar") "baz")))) (error "foo")) - #:msg #rx"expected: String.*given: \\(U False String\\)"])) + #:msg #rx"expected: String.*given: \\(U String 'obfuscate\\)"]))