typed-racket/typed-racket-test/succeed/sequenceof-integer.rkt
Ben Greenman 9fe2252eef add regression test for (Sequenceof T)
Test to make sure `(Sequenceof (Boxof T))` wraps sequence elements in a contract
2017-11-08 21:04:30 -05:00

28 lines
721 B
Racket

#lang racket/base
(module typed typed/racket/base
(provide foo)
(: foo (-> (U Integer (Sequenceof Integer)) String))
(define (foo x)
(if (integer? x)
(format "I got an integer: ~a" x)
(error "I did not get an integer: ~a" x))))
(module other-typed typed/racket/base
(provide bar)
(require (submod ".." typed))
(define (bar) (foo 0)))
(module contract-test typed/racket/base
(define b* : (Sequenceof (Boxof Integer)) (list (box 0)))
(provide b*))
(require 'typed
'other-typed
'contract-test
rackunit)
(check-equal? (foo 0) "I got an integer: 0")
(check-equal? (bar) "I got an integer: 0")
(check-exn exn:fail:contract?
(λ () (set-box! (car b*) 'NaN)))