1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# Commands covered: none
#
# This file contains a collection of tests for Tcl_AsyncCreate and related
# library procedures. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1993 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: async.test,v 1.6 2003/07/24 16:05:24 dgp Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
if {[info commands testasync] == {}} {
puts "This application hasn't been compiled with the \"testasync\""
puts "command, so I can't test Tcl_AsyncCreate et al."
::tcltest::cleanupTests
return
}
proc async1 {result code} {
global aresult acode
set aresult $result
set acode $code
return "new result"
}
|
|
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# Commands covered: none
#
# This file contains a collection of tests for Tcl_AsyncCreate and related
# library procedures. Sourcing this file into Tcl runs the tests and
# generates output for errors. No output means no errors were found.
#
# Copyright (c) 1993 The Regents of the University of California.
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
# RCS: @(#) $Id: async.test,v 1.7 2003/11/16 00:49:20 dkf Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
if {[info commands testasync] == {}} {
puts "This application hasn't been compiled with the \"testasync\""
puts "command, so I can't test Tcl_AsyncCreate et al."
::tcltest::cleanupTests
return
}
tcltest::testConstraint threaded [expr {
[info exists ::tcl_platform(threaded)] && $::tcl_platform(threaded)
}]
proc async1 {result code} {
global aresult acode
set aresult $result
set acode $code
return "new result"
}
|
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
set hm3 [testasync create mult2]
set hm4 [testasync create del2]
test async-3.1 {deleting handlers} {
set x {}
list [catch {testasync mark $hm2 "foobar" 5} msg] $msg $x
} {3 del2 {0 0 0 del1 del2}}
# cleanup
testasync delete
::tcltest::cleanupTests
return
|
>
|
>
>
>
>
|
<
|
|
|
|
|
>
|
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
|
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
set hm3 [testasync create mult2]
set hm4 [testasync create del2]
test async-3.1 {deleting handlers} {
set x {}
list [catch {testasync mark $hm2 "foobar" 5} msg] $msg $x
} {3 del2 {0 0 0 del1 del2}}
proc nothing {} {
# empty proc
}
proc hang1 {handle} {
global aresult
set aresult {Async event not delivered}
testasync marklater $handle
for {set i 0} {
$i < 2500000 && $aresult eq "Async event not delivered"
} {incr i} {
nothing
}
return $aresult
}
proc hang2 {handle} {
global aresult
set aresult {Async event not delivered}
testasync marklater $handle
for {set i 0} {
$i < 2500000 && $aresult eq "Async event not delivered"
} {incr i} {}
return $aresult
}
proc hang3 {handle} [concat {
global aresult
set aresult {Async event not delivered}
testasync marklater $handle
set i 0
} [string repeat {;incr i;} 1500000] {
return $aresult
}]
test async-4.1 {async interrupting bytecode sequence} -constraints {
threaded
} -setup {
set hm [testasync create async3]
} -body {
hang1 $hm
} -result {test pattern} -cleanup {
testasync delete $hm
}
test async-4.2 {async interrupting straight bytecode sequence} -constraints {
threaded
} -setup {
set hm [testasync create async3]
} -body {
hang2 $hm
} -result {test pattern} -cleanup {
testasync delete $hm
}
test async-4.3 {async interrupting loop-less bytecode sequence} -constraints {
threaded
} -setup {
set hm [testasync create async3]
} -body {
hang3 $hm
} -result {test pattern} -cleanup {
testasync delete $hm
}
# cleanup
testasync delete
::tcltest::cleanupTests
return
# Local Variables:
# mode: tcl
# End:
|