Add more tests for continuation marks & Any wrapping

original commit: a42cc9a0012cb7490da13228d21b2182fb1af9d3
This commit is contained in:
Asumu Takikawa 2012-11-30 14:10:20 -05:00
parent bca928688a
commit fec01c3f97
4 changed files with 108 additions and 0 deletions

View File

@ -0,0 +1,29 @@
#;
(exn-pred exn:fail:contract?)
#lang racket/load
;; check typed-untyped interaction with cont marks
(module typed typed/racket
(provide call-f)
(: key (Continuation-Mark-Keyof (Integer -> String)))
(define key (make-continuation-mark-key))
(: call-f (((Continuation-Mark-Keyof (Integer -> String)) -> String)
-> String))
(define (call-f f)
(with-continuation-mark
key (λ (n) (number->string n))
(f key))))
(module untyped racket
(require 'typed)
(call-f
(λ (key)
(string-append "hello "
((continuation-mark-set-first #f key) 'bad)))))
(require 'untyped)

View File

@ -0,0 +1,28 @@
#;
(exn-pred exn:fail:contract?)
#lang racket/load
;; check typed-untyped interaction with cont marks
(module typed typed/racket
(provide key f)
(: key (Continuation-Mark-Keyof String))
(define key (make-continuation-mark-key))
(: f (-> String))
(define (f)
(apply string-append
(continuation-mark-set->list
(current-continuation-marks)
key))))
(module untyped racket
(require 'typed)
(with-continuation-mark
key 'hello ; should be string
(f)))
(require 'untyped)

View File

@ -0,0 +1,27 @@
#;
(exn-pred exn:fail:contract?)
#lang racket/load
;; check Any wrapper for default-continuation-prompt-tag
(module typed typed/racket
(provide f)
(: f (-> Void))
(define (f)
(abort-current-continuation
(default-continuation-prompt-tag)
(λ: ([x : Number]) (+ 1 x)))))
(module untyped racket
(require 'typed)
(call-with-continuation-prompt
(λ () (f))
(default-continuation-prompt-tag)
;; behavioral values are not allowed to pass
;; through the Any contract to here
(λ (f) (f 3))))
(require 'untyped)

View File

@ -0,0 +1,24 @@
#lang racket/load
;; successful typed-untyped interaction with cont marks
(module typed typed/racket
(provide call-f)
(: key (Continuation-Mark-Keyof String))
(define key (make-continuation-mark-key))
(: call-f (((Continuation-Mark-Keyof String) -> String) -> String))
(define (call-f f)
(with-continuation-mark key "hello" (f key))))
(module untyped racket
(require 'typed)
(call-f
(λ (key)
(string-append (continuation-mark-set-first #f key)
" world"))))
(require 'untyped)