summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/thread.test35
1 files changed, 32 insertions, 3 deletions
diff --git a/tests/thread.test b/tests/thread.test
index 5a138e4..2686720 100644
--- a/tests/thread.test
+++ b/tests/thread.test
@@ -10,7 +10,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: thread.test,v 1.9 2000/04/10 17:19:05 ericm Exp $
+# RCS: @(#) $Id: thread.test,v 1.10 2000/05/02 22:02:36 kupries Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -43,7 +43,7 @@ test thread-1.1 {Tcl_ThreadObjCmd: no args} {testthread} {
test thread-1.2 {Tcl_ThreadObjCmd: bad option} {testthread} {
list [catch {testthread foo} msg] $msg
-} {1 {bad option "foo": must be create, exit, id, names, send, wait, or errorproc}}
+} {1 {bad option "foo": must be create, exit, id, join, names, send, wait, or errorproc}}
test thread-1.3 {Tcl_ThreadObjCmd: initial thread list} {testthread} {
list [threadReap] [llength [testthread names]]
@@ -62,7 +62,7 @@ test thread-1.5 {Tcl_ThreadObjCmd: thread create one shot} {testthread} {
threadReap
testthread create {set x 5}
foreach try {0 1 2 4 5 6} {
- # Try various ways to yeild
+ # Try various ways to yield
update
after 10
set l [llength [testthread names]]
@@ -230,6 +230,35 @@ test thread-4.5 {TclThreadSend preserve errorCode} {testthread} {
list $x $msg $errorCode
} {1 ERR CODE}
+
+test thread-5.0 {Joining threads} {testthread} {
+ threadReap
+ set serverthread [testthread create -joinable]
+ testthread send -async $serverthread {after 1000 ; testthread exit}
+ set res [testthread join $serverthread]
+ threadReap
+ set res
+} {0}
+
+test thread-5.1 {Joining threads after the fact} {testthread} {
+ threadReap
+ set serverthread [testthread create -joinable]
+ testthread send -async $serverthread {testthread exit}
+ after 2000
+ set res [testthread join $serverthread]
+ threadReap
+ set res
+} {0}
+
+test thread-5.2 {Try to join a detached thread} {testthread} {
+ threadReap
+ set serverthread [testthread create]
+ testthread send -async $serverthread {after 1000 ; testthread exit}
+ catch {set res [testthread join $serverthread]} msg
+ threadReap
+ lrange $msg 0 2
+} {cannot join thread}
+
# cleanup
::tcltest::cleanupTests
return