Add more tests for continuation marks & Any wrapping
original commit: a42cc9a0012cb7490da13228d21b2182fb1af9d3
This commit is contained in:
parent
bca928688a
commit
fec01c3f97
29
collects/tests/typed-racket/fail/control-test-4.rkt
Normal file
29
collects/tests/typed-racket/fail/control-test-4.rkt
Normal 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)
|
||||
|
28
collects/tests/typed-racket/fail/control-test-5.rkt
Normal file
28
collects/tests/typed-racket/fail/control-test-5.rkt
Normal 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)
|
||||
|
27
collects/tests/typed-racket/fail/control-test-6.rkt
Normal file
27
collects/tests/typed-racket/fail/control-test-6.rkt
Normal 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)
|
||||
|
24
collects/tests/typed-racket/succeed/continuation-mark.rkt
Normal file
24
collects/tests/typed-racket/succeed/continuation-mark.rkt
Normal 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)
|
||||
|
Loading…
Reference in New Issue
Block a user