summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2021-06-23 12:56:22 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2021-06-23 12:56:22 (GMT)
commite966cabc8dc8b12ec4047c2f84237745740182fb (patch)
treea6a1b6b304987f3ca967da49b3271bc3909ae04c /tests
parenta04a01603dff351c666f4eee9ab2a166ed28a7a1 (diff)
parent501954d5aaf9401f977885fd340298baacde61a2 (diff)
downloadtcl-e966cabc8dc8b12ec4047c2f84237745740182fb.zip
tcl-e966cabc8dc8b12ec4047c2f84237745740182fb.tar.gz
tcl-e966cabc8dc8b12ec4047c2f84237745740182fb.tar.bz2
Merge 8.7
Diffstat (limited to 'tests')
-rw-r--r--tests/coroutine.test71
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/coroutine.test b/tests/coroutine.test
index b129c03..c3023f7 100644
--- a/tests/coroutine.test
+++ b/tests/coroutine.test
@@ -755,6 +755,77 @@ test coroutine-7.12 {coro floor above street level #3008307} -body {
rename boom {}; rename cc {}; rename c {}
} -result {}
+
+test coroutine-7.13 {
+ issue f9800d52bd61f240
+
+ vwait is not NRE-enabled, and yieldto cannot find the right splicing spot
+} -body {
+ coroutine c0 apply [list {} {
+ variable done
+ yield
+ yieldto c1
+ after 0 c2
+ vwait [namespace current]::done
+ } [namespace current]]
+
+ coroutine c1 apply [list {} {
+ yield
+ tailcall c0
+ } [namespace current]]
+
+ coroutine c2 apply [list {} {
+ variable done
+ yield
+ yieldto try {yieldto c1} on error {} [list after 0 [list [info coroutine]]]
+ yieldto try {yieldto c1} on error {} [list after 0 [list [info coroutine]]]
+ set done 1
+ } [namespace current]]
+
+ after 0 [list [namespace which c0]]
+ vwait [namespace current]::done
+ return $done
+} -result 1
+
+
+test coroutine-7.14 {
+ issue 5106fddd4400e5b9
+
+ failure to yieldto is not the same thing as not calling yieldto in the
+ first place
+} -body {
+ variable done
+ variable done1
+
+ coroutine c0 ::apply [list {} {
+ yield
+ after 0 [list [namespace which c1]]
+ vwait [namespace current]::done1
+ } [namespace current]]
+
+ coroutine c1 ::apply [list {} {
+ variable done1
+ yield
+ yieldto try "yieldto [list [info coroutine]]" on error {} "
+ ::set [list [namespace current]]::done1 failure
+ ::set [list [namespace current]]::done0 failure
+ "
+ set done1 success
+
+ } [namespace current]]
+ after 1 [list [namespace which c0]]
+ vwait [namespace current]::done0
+ if {[namespace which [namespace current]::c1] ne {}} {
+ # prior to the fix for 5106fddd4400e5b9, the nested yieldto turned into a
+ # tailcall which was eventutally activated, causing control to return to
+ # c1. After the fix, that doesn't happen, so if c1 still exists call it
+ # one final time to allow it to finish and clean up
+ rename c1 {}
+ }
+ return [list $done0 $done1]
+} -result {failure failure}
+
+
test coroutine-8.0.0 {coro inject executed} -body {
coroutine demo apply {{} { foreach i {1 2} yield }}
demo