From c2a473cba2d789fd96c5f70e72044fca0e7e9a43 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Mon, 20 Jun 2011 15:59:24 -0400 Subject: [PATCH] Added tests for parameterizations and thread cells. --- collects/tests/typed-scheme/succeed/param.rkt | 13 +++++++++- .../succeed/threads-and-channels.rkt | 25 ++++++++++++++++++- collects/typed-scheme/types/abbrev.rkt | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/collects/tests/typed-scheme/succeed/param.rkt b/collects/tests/typed-scheme/succeed/param.rkt index e149b2c3a2..afba015a5f 100644 --- a/collects/tests/typed-scheme/succeed/param.rkt +++ b/collects/tests/typed-scheme/succeed/param.rkt @@ -1,5 +1,16 @@ -#lang typed-scheme +#lang typed/racket (parameterize ([current-directory ".."]) (current-directory) (current-directory "..")) + + +(: old-param Parameterization) +(define old-param (current-parameterization)) + +(current-directory "..") + +(call-with-parameterization old-param (lambda () (current-directory))) + +(parameterization? old-param) + diff --git a/collects/tests/typed-scheme/succeed/threads-and-channels.rkt b/collects/tests/typed-scheme/succeed/threads-and-channels.rkt index 6261363e0c..997499e1e7 100644 --- a/collects/tests/typed-scheme/succeed/threads-and-channels.rkt +++ b/collects/tests/typed-scheme/succeed/threads-and-channels.rkt @@ -1,4 +1,4 @@ -#lang typed/scheme +#lang typed/racket (: chan (Channelof Symbol)) (define chan (make-channel)) @@ -48,3 +48,26 @@ (channel-put c2 (cons c3 'b)) (let: ((c4 : JumpingChannel (make-channel))) (channel-put c3 (cons c4 'c))))) + + + + +(: tc (ThreadCellof Integer)) +(define tc (make-thread-cell 0)) + +(thread-cell-set! tc 1) + +(thread-wait (thread (lambda () + (displayln (thread-cell-ref tc)) + (thread-cell-set! tc 2) + (displayln (thread-cell-ref tc))))) + +(thread-cell-ref tc) + +(define blocked-thread + (thread (lambda () + (channel-get ((inst make-channel 'unused)))))) + + +(thread-suspend blocked-thread) +(kill-thread blocked-thread) diff --git a/collects/typed-scheme/types/abbrev.rkt b/collects/typed-scheme/types/abbrev.rkt index fef34bfc7c..fade99b8da 100644 --- a/collects/typed-scheme/types/abbrev.rkt +++ b/collects/typed-scheme/types/abbrev.rkt @@ -214,7 +214,7 @@ (define -Custodian (make-Base 'Custodian #'custodian? custodian? #'Custodian)) -(define -Parameterization (make-Base 'Parameterization #'parameterization? parameterization? #'Parameterization)) +(define -Parameterization (make-Base 'Parameterization #'parameterization? parameterization? #'-Parameterization)) (define -Inspector (make-Base 'Inspector #'inspector inspector? #'-Inspector))