diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2008-09-28 13:46:07 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2008-09-28 13:46:07 (GMT) |
commit | f382ac98486d875787dc6b708fc22216a0246c48 (patch) | |
tree | 7a8011640225ca882d24e02ebed95a70dbb5b3fb /tests | |
parent | 0f26317d580254d922cc16f4e5586bce2c2d0a31 (diff) | |
download | tcl-f382ac98486d875787dc6b708fc22216a0246c48.zip tcl-f382ac98486d875787dc6b708fc22216a0246c48.tar.gz tcl-f382ac98486d875787dc6b708fc22216a0246c48.tar.bz2 |
* generic/tclBasic.c: Fix the numLevels computations on
* generic/tclInt.h: coroutine yield/resume
* tests/unsupported.test:
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unsupported.test | 88 |
1 files changed, 87 insertions, 1 deletions
diff --git a/tests/unsupported.test b/tests/unsupported.test index 74f91aa..553021b 100644 --- a/tests/unsupported.test +++ b/tests/unsupported.test @@ -9,7 +9,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: unsupported.test,v 1.10 2008/09/05 01:20:01 msofer Exp $ +# RCS: @(#) $Id: unsupported.test,v 1.11 2008/09/28 13:46:12 msofer Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -835,6 +835,92 @@ test unsupported-C.4.2 {bug #2093947} -constraints {coroutine} \ unset ::res } -result {{v {} write} {v {} write} {v {} unset} {v {} write} {v {} unset}} +test unsupported-C.5.1 {right numLevels on coro return} -constraints {coroutine testnrelevels} \ +-setup { + proc nestedYield {{val {}}} { + yield $val + } + proc getNumLevel {} { + # remove the level for this proc's call + expr {[lindex [testnrelevels] 1] - 1} + } + proc relativeLevel base { + # remove the level for this proc's call + expr {[getNumLevel] - $base - 1} + } + proc foo {} { + while 1 { + nestedYield + } + } + set res {} +} -body { + set base [getNumLevel] + lappend res [relativeLevel $base] + eval {coroutine a foo} + + # back to base level + lappend res [relativeLevel $base] + a + lappend res [relativeLevel $base] + eval a + lappend res [relativeLevel $base] + eval {eval a} + lappend res [relativeLevel $base] + rename a {} + lappend res [relativeLevel $base] + set res +} -cleanup { + rename foo {} + rename nestedYield {} + rename getNumLevel {} + rename relativeLevel {} + unset res +} -result {0 0 0 0 0 0} + +test unsupported-C.5.2 {right numLevels within coro} -constraints {coroutine testnrelevels} \ +-setup { + proc nestedYield {{val {}}} { + yield $val + } + proc getNumLevel {} { + # remove the level for this proc's call + expr {[lindex [testnrelevels] 1] - 1} + } + proc relativeLevel base { + # remove the level for this proc's call + expr {[getNumLevel] - $base - 1} + } + proc foo base { + while 1 { + set base [nestedYield [relativeLevel $base]] + } + } + set res {} +} -body { + lappend res [eval {coroutine a foo [getNumLevel]}] + lappend res [a [getNumLevel]] + lappend res [eval {a [getNumLevel]}] + lappend res [eval {eval {a [getNumLevel]}}] + set base [lindex $res 0] + foreach x $res[set res {}] { + # REMARK: the first call is one level deeper due to [coroutine] being + # on the Tcl call stack: the proper result is a leading 0 and a + # sequence of -1s + lappend res [expr {$x-$base}] + } + set res +} -cleanup { + rename a {} + rename foo {} + rename nestedYield {} + rename getNumLevel {} + rename relativeLevel {} + unset res +} -result {0 -1 -1 -1} + + + # cleanup ::tcltest::cleanupTests |