[25] | 1 | # This file contains a collection of tests for the procedures in the |
---|
| 2 | # file tclTimer.c, which includes the "after" Tcl command. Sourcing |
---|
| 3 | # this file into Tcl runs the tests and generates output for errors. |
---|
| 4 | # No output means no errors were found. |
---|
| 5 | # |
---|
| 6 | # This file contains a collection of tests for one or more of the Tcl |
---|
| 7 | # built-in commands. Sourcing this file into Tcl runs the tests and |
---|
| 8 | # generates output for errors. No output means no errors were found. |
---|
| 9 | # |
---|
| 10 | # Copyright (c) 1997 by Sun Microsystems, Inc. |
---|
| 11 | # Copyright (c) 1998-1999 by Scriptics Corporation. |
---|
| 12 | # |
---|
| 13 | # See the file "license.terms" for information on usage and redistribution |
---|
| 14 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 15 | # |
---|
| 16 | # RCS: @(#) $Id: timer.test,v 1.12 2005/11/09 21:28:36 kennykb Exp $ |
---|
| 17 | |
---|
| 18 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
| 19 | package require tcltest |
---|
| 20 | namespace import -force ::tcltest::* |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | test timer-1.1 {Tcl_CreateTimerHandler procedure} { |
---|
| 24 | foreach i [after info] { |
---|
| 25 | after cancel $i |
---|
| 26 | } |
---|
| 27 | set x "" |
---|
| 28 | foreach i {100 200 1000 50 150} { |
---|
| 29 | after $i lappend x $i |
---|
| 30 | } |
---|
| 31 | after 200 set done 1 |
---|
| 32 | vwait done |
---|
| 33 | set x |
---|
| 34 | } {50 100 150 200} |
---|
| 35 | |
---|
| 36 | test timer-2.1 {Tcl_DeleteTimerHandler procedure} { |
---|
| 37 | foreach i [after info] { |
---|
| 38 | after cancel $i |
---|
| 39 | } |
---|
| 40 | set x "" |
---|
| 41 | foreach i {100 200 1000 50 150} { |
---|
| 42 | after $i lappend x $i |
---|
| 43 | } |
---|
| 44 | after cancel lappend x 150 |
---|
| 45 | after cancel lappend x 50 |
---|
| 46 | after 200 set done 1 |
---|
| 47 | vwait done |
---|
| 48 | set x |
---|
| 49 | } {100 200} |
---|
| 50 | |
---|
| 51 | # No tests for Tcl_ServiceTimer or ResetTimer, since it is already tested |
---|
| 52 | # above. |
---|
| 53 | |
---|
| 54 | test timer-3.1 {TimerHandlerEventProc procedure: event masks} { |
---|
| 55 | set x start |
---|
| 56 | after 100 { set x fired } |
---|
| 57 | update idletasks |
---|
| 58 | set result $x |
---|
| 59 | after 200 |
---|
| 60 | update |
---|
| 61 | lappend result $x |
---|
| 62 | } {start fired} |
---|
| 63 | test timer-3.2 {TimerHandlerEventProc procedure: multiple timers} { |
---|
| 64 | foreach i [after info] { |
---|
| 65 | after cancel $i |
---|
| 66 | } |
---|
| 67 | foreach i {200 600 1000} { |
---|
| 68 | after $i lappend x $i |
---|
| 69 | } |
---|
| 70 | after 200 |
---|
| 71 | set result "" |
---|
| 72 | set x "" |
---|
| 73 | update |
---|
| 74 | lappend result $x |
---|
| 75 | after 400 |
---|
| 76 | update |
---|
| 77 | lappend result $x |
---|
| 78 | after 400 |
---|
| 79 | update |
---|
| 80 | lappend result $x |
---|
| 81 | } {200 {200 600} {200 600 1000}} |
---|
| 82 | test timer-3.3 {TimerHandlerEventProc procedure: reentrant timer deletion} { |
---|
| 83 | foreach i [after info] { |
---|
| 84 | after cancel $i |
---|
| 85 | } |
---|
| 86 | set x {} |
---|
| 87 | after 100 lappend x 100 |
---|
| 88 | set i [after 300 lappend x 300] |
---|
| 89 | after 200 after cancel $i |
---|
| 90 | after 400 |
---|
| 91 | update |
---|
| 92 | set x |
---|
| 93 | } 100 |
---|
| 94 | test timer-3.4 {TimerHandlerEventProc procedure: all expired timers fire} { |
---|
| 95 | foreach i [after info] { |
---|
| 96 | after cancel $i |
---|
| 97 | } |
---|
| 98 | set x {} |
---|
| 99 | after 100 lappend x a |
---|
| 100 | after 200 lappend x b |
---|
| 101 | after 300 lappend x c |
---|
| 102 | after 300 |
---|
| 103 | vwait x |
---|
| 104 | set x |
---|
| 105 | } {a b c} |
---|
| 106 | test timer-3.5 {TimerHandlerEventProc procedure: reentrantly added timers don't fire} { |
---|
| 107 | foreach i [after info] { |
---|
| 108 | after cancel $i |
---|
| 109 | } |
---|
| 110 | set x {} |
---|
| 111 | after 100 {lappend x a; after 0 lappend x b} |
---|
| 112 | after 100 |
---|
| 113 | vwait x |
---|
| 114 | set x |
---|
| 115 | } a |
---|
| 116 | test timer-3.6 {TimerHandlerEventProc procedure: reentrantly added timers don't fire} { |
---|
| 117 | foreach i [after info] { |
---|
| 118 | after cancel $i |
---|
| 119 | } |
---|
| 120 | set x {} |
---|
| 121 | after 100 {lappend x a; after 100 lappend x b; after 100} |
---|
| 122 | after 100 |
---|
| 123 | vwait x |
---|
| 124 | set result $x |
---|
| 125 | vwait x |
---|
| 126 | lappend result $x |
---|
| 127 | } {a {a b}} |
---|
| 128 | |
---|
| 129 | # No tests for Tcl_DoWhenIdle: it's already tested by other tests |
---|
| 130 | # below. |
---|
| 131 | |
---|
| 132 | test timer-4.1 {Tcl_CancelIdleCall procedure} { |
---|
| 133 | foreach i [after info] { |
---|
| 134 | after cancel $i |
---|
| 135 | } |
---|
| 136 | set x before |
---|
| 137 | set y before |
---|
| 138 | set z before |
---|
| 139 | after idle set x after1 |
---|
| 140 | after idle set y after2 |
---|
| 141 | after idle set z after3 |
---|
| 142 | after cancel set y after2 |
---|
| 143 | update idletasks |
---|
| 144 | concat $x $y $z |
---|
| 145 | } {after1 before after3} |
---|
| 146 | test timer-4.2 {Tcl_CancelIdleCall procedure} { |
---|
| 147 | foreach i [after info] { |
---|
| 148 | after cancel $i |
---|
| 149 | } |
---|
| 150 | set x before |
---|
| 151 | set y before |
---|
| 152 | set z before |
---|
| 153 | after idle set x after1 |
---|
| 154 | after idle set y after2 |
---|
| 155 | after idle set z after3 |
---|
| 156 | after cancel set x after1 |
---|
| 157 | update idletasks |
---|
| 158 | concat $x $y $z |
---|
| 159 | } {before after2 after3} |
---|
| 160 | |
---|
| 161 | test timer-5.1 {Tcl_ServiceIdle, self-rescheduling handlers} { |
---|
| 162 | foreach i [after info] { |
---|
| 163 | after cancel $i |
---|
| 164 | } |
---|
| 165 | set x 1 |
---|
| 166 | set y 23 |
---|
| 167 | after idle {incr x; after idle {incr x; after idle {incr x}}} |
---|
| 168 | after idle {incr y} |
---|
| 169 | vwait x |
---|
| 170 | set result "$x $y" |
---|
| 171 | update idletasks |
---|
| 172 | lappend result $x |
---|
| 173 | } {2 24 4} |
---|
| 174 | |
---|
| 175 | test timer-6.1 {Tcl_AfterCmd procedure, basics} { |
---|
| 176 | list [catch {after} msg] $msg |
---|
| 177 | } {1 {wrong # args: should be "after option ?arg arg ...?"}} |
---|
| 178 | test timer-6.2 {Tcl_AfterCmd procedure, basics} { |
---|
| 179 | list [catch {after 2x} msg] $msg |
---|
| 180 | } {1 {bad argument "2x": must be cancel, idle, info, or an integer}} |
---|
| 181 | test timer-6.3 {Tcl_AfterCmd procedure, basics} { |
---|
| 182 | list [catch {after gorp} msg] $msg |
---|
| 183 | } {1 {bad argument "gorp": must be cancel, idle, info, or an integer}} |
---|
| 184 | test timer-6.4 {Tcl_AfterCmd procedure, ms argument} { |
---|
| 185 | set x before |
---|
| 186 | after 400 {set x after} |
---|
| 187 | after 200 |
---|
| 188 | update |
---|
| 189 | set y $x |
---|
| 190 | after 400 |
---|
| 191 | update |
---|
| 192 | list $y $x |
---|
| 193 | } {before after} |
---|
| 194 | test timer-6.5 {Tcl_AfterCmd procedure, ms argument} { |
---|
| 195 | set x before |
---|
| 196 | after 300 set x after |
---|
| 197 | after 200 |
---|
| 198 | update |
---|
| 199 | set y $x |
---|
| 200 | after 200 |
---|
| 201 | update |
---|
| 202 | list $y $x |
---|
| 203 | } {before after} |
---|
| 204 | test timer-6.6 {Tcl_AfterCmd procedure, cancel option} { |
---|
| 205 | list [catch {after cancel} msg] $msg |
---|
| 206 | } {1 {wrong # args: should be "after cancel id|command"}} |
---|
| 207 | test timer-6.7 {Tcl_AfterCmd procedure, cancel option} { |
---|
| 208 | after cancel after#1 |
---|
| 209 | } {} |
---|
| 210 | test timer-6.8 {Tcl_AfterCmd procedure, cancel option} { |
---|
| 211 | after cancel {foo bar} |
---|
| 212 | } {} |
---|
| 213 | test timer-6.9 {Tcl_AfterCmd procedure, cancel option} { |
---|
| 214 | foreach i [after info] { |
---|
| 215 | after cancel $i |
---|
| 216 | } |
---|
| 217 | set x before |
---|
| 218 | set y [after 100 set x after] |
---|
| 219 | after cancel $y |
---|
| 220 | after 200 |
---|
| 221 | update |
---|
| 222 | set x |
---|
| 223 | } {before} |
---|
| 224 | test timer-6.10 {Tcl_AfterCmd procedure, cancel option} { |
---|
| 225 | foreach i [after info] { |
---|
| 226 | after cancel $i |
---|
| 227 | } |
---|
| 228 | set x before |
---|
| 229 | after 100 set x after |
---|
| 230 | after cancel {set x after} |
---|
| 231 | after 200 |
---|
| 232 | update |
---|
| 233 | set x |
---|
| 234 | } {before} |
---|
| 235 | test timer-6.11 {Tcl_AfterCmd procedure, cancel option} { |
---|
| 236 | foreach i [after info] { |
---|
| 237 | after cancel $i |
---|
| 238 | } |
---|
| 239 | set x before |
---|
| 240 | after 100 set x after |
---|
| 241 | set id [after 300 set x after] |
---|
| 242 | after cancel $id |
---|
| 243 | after 200 |
---|
| 244 | update |
---|
| 245 | set y $x |
---|
| 246 | set x cleared |
---|
| 247 | after 200 |
---|
| 248 | update |
---|
| 249 | list $y $x |
---|
| 250 | } {after cleared} |
---|
| 251 | test timer-6.12 {Tcl_AfterCmd procedure, cancel option} { |
---|
| 252 | foreach i [after info] { |
---|
| 253 | after cancel $i |
---|
| 254 | } |
---|
| 255 | set x first |
---|
| 256 | after idle lappend x second |
---|
| 257 | after idle lappend x third |
---|
| 258 | set i [after idle lappend x fourth] |
---|
| 259 | after cancel {lappend x second} |
---|
| 260 | after cancel $i |
---|
| 261 | update idletasks |
---|
| 262 | set x |
---|
| 263 | } {first third} |
---|
| 264 | test timer-6.13 {Tcl_AfterCmd procedure, cancel option, multiple arguments for command} { |
---|
| 265 | foreach i [after info] { |
---|
| 266 | after cancel $i |
---|
| 267 | } |
---|
| 268 | set x first |
---|
| 269 | after idle lappend x second |
---|
| 270 | after idle lappend x third |
---|
| 271 | set i [after idle lappend x fourth] |
---|
| 272 | after cancel lappend x second |
---|
| 273 | after cancel $i |
---|
| 274 | update idletasks |
---|
| 275 | set x |
---|
| 276 | } {first third} |
---|
| 277 | test timer-6.14 {Tcl_AfterCmd procedure, cancel option, cancel during handler, used to dump core} { |
---|
| 278 | foreach i [after info] { |
---|
| 279 | after cancel $i |
---|
| 280 | } |
---|
| 281 | set id [ |
---|
| 282 | after 100 { |
---|
| 283 | set x done |
---|
| 284 | after cancel $id |
---|
| 285 | } |
---|
| 286 | ] |
---|
| 287 | vwait x |
---|
| 288 | } {} |
---|
| 289 | test timer-6.15 {Tcl_AfterCmd procedure, cancel option, multiple interps} { |
---|
| 290 | foreach i [after info] { |
---|
| 291 | after cancel $i |
---|
| 292 | } |
---|
| 293 | interp create x |
---|
| 294 | x eval {set a before; set b before; after idle {set a a-after}; |
---|
| 295 | after idle {set b b-after}} |
---|
| 296 | set result [llength [x eval after info]] |
---|
| 297 | lappend result [llength [after info]] |
---|
| 298 | after cancel {set b b-after} |
---|
| 299 | set a aaa |
---|
| 300 | set b bbb |
---|
| 301 | x eval {after cancel set a a-after} |
---|
| 302 | update idletasks |
---|
| 303 | lappend result $a $b [x eval {list $a $b}] |
---|
| 304 | interp delete x |
---|
| 305 | set result |
---|
| 306 | } {2 0 aaa bbb {before b-after}} |
---|
| 307 | test timer-6.16 {Tcl_AfterCmd procedure, idle option} { |
---|
| 308 | list [catch {after idle} msg] $msg |
---|
| 309 | } {1 {wrong # args: should be "after idle script script ..."}} |
---|
| 310 | test timer-6.17 {Tcl_AfterCmd procedure, idle option} { |
---|
| 311 | set x before |
---|
| 312 | after idle {set x after} |
---|
| 313 | set y $x |
---|
| 314 | update idletasks |
---|
| 315 | list $y $x |
---|
| 316 | } {before after} |
---|
| 317 | test timer-6.18 {Tcl_AfterCmd procedure, idle option} { |
---|
| 318 | set x before |
---|
| 319 | after idle set x after |
---|
| 320 | set y $x |
---|
| 321 | update idletasks |
---|
| 322 | list $y $x |
---|
| 323 | } {before after} |
---|
| 324 | set event1 [after idle event 1] |
---|
| 325 | set event2 [after 1000 event 2] |
---|
| 326 | interp create x |
---|
| 327 | set childEvent [x eval {after idle event in child}] |
---|
| 328 | test timer-6.19 {Tcl_AfterCmd, info option} { |
---|
| 329 | lsort [after info] |
---|
| 330 | } [lsort "$event1 $event2"] |
---|
| 331 | test timer-6.20 {Tcl_AfterCmd, info option} { |
---|
| 332 | list [catch {after info a b} msg] $msg |
---|
| 333 | } {1 {wrong # args: should be "after info ?id?"}} |
---|
| 334 | test timer-6.21 {Tcl_AfterCmd, info option} { |
---|
| 335 | list [catch {after info $childEvent} msg] $msg |
---|
| 336 | } "1 {event \"$childEvent\" doesn't exist}" |
---|
| 337 | test timer-6.22 {Tcl_AfterCmd, info option} { |
---|
| 338 | list [after info $event1] [after info $event2] |
---|
| 339 | } {{{event 1} idle} {{event 2} timer}} |
---|
| 340 | |
---|
| 341 | after cancel $event1 |
---|
| 342 | after cancel $event2 |
---|
| 343 | interp delete x |
---|
| 344 | |
---|
| 345 | test timer-6.23 {Tcl_AfterCmd procedure, no option, script with NULL} { |
---|
| 346 | foreach i [after info] { |
---|
| 347 | after cancel $i |
---|
| 348 | } |
---|
| 349 | set x "hello world" |
---|
| 350 | after 1 "set x ab\0cd" |
---|
| 351 | after 10 |
---|
| 352 | update |
---|
| 353 | string length $x |
---|
| 354 | } {5} |
---|
| 355 | test timer-6.24 {Tcl_AfterCmd procedure, no option, script with NULL} { |
---|
| 356 | foreach i [after info] { |
---|
| 357 | after cancel $i |
---|
| 358 | } |
---|
| 359 | set x "hello world" |
---|
| 360 | after 1 set x ab\0cd |
---|
| 361 | after 10 |
---|
| 362 | update |
---|
| 363 | string length $x |
---|
| 364 | } {5} |
---|
| 365 | test timer-6.25 {Tcl_AfterCmd procedure, cancel option, script with NULL} { |
---|
| 366 | foreach i [after info] { |
---|
| 367 | after cancel $i |
---|
| 368 | } |
---|
| 369 | set x "hello world" |
---|
| 370 | after 1 set x ab\0cd |
---|
| 371 | after cancel "set x ab\0ef" |
---|
| 372 | set x [llength [after info]] |
---|
| 373 | foreach i [after info] { |
---|
| 374 | after cancel $i |
---|
| 375 | } |
---|
| 376 | set x |
---|
| 377 | } {1} |
---|
| 378 | test timer-6.26 {Tcl_AfterCmd procedure, cancel option, script with NULL} { |
---|
| 379 | foreach i [after info] { |
---|
| 380 | after cancel $i |
---|
| 381 | } |
---|
| 382 | set x "hello world" |
---|
| 383 | after 1 set x ab\0cd |
---|
| 384 | after cancel set x ab\0ef |
---|
| 385 | set y [llength [after info]] |
---|
| 386 | foreach i [after info] { |
---|
| 387 | after cancel $i |
---|
| 388 | } |
---|
| 389 | set y |
---|
| 390 | } {1} |
---|
| 391 | test timer-6.27 {Tcl_AfterCmd procedure, idle option, script with NULL} { |
---|
| 392 | foreach i [after info] { |
---|
| 393 | after cancel $i |
---|
| 394 | } |
---|
| 395 | set x "hello world" |
---|
| 396 | after idle "set x ab\0cd" |
---|
| 397 | update |
---|
| 398 | string length $x |
---|
| 399 | } {5} |
---|
| 400 | test timer-6.28 {Tcl_AfterCmd procedure, idle option, script with NULL} { |
---|
| 401 | foreach i [after info] { |
---|
| 402 | after cancel $i |
---|
| 403 | } |
---|
| 404 | set x "hello world" |
---|
| 405 | after idle set x ab\0cd |
---|
| 406 | update |
---|
| 407 | string length $x |
---|
| 408 | } {5} |
---|
| 409 | test timer-6.29 {Tcl_AfterCmd procedure, info option, script with NULL} { |
---|
| 410 | foreach i [after info] { |
---|
| 411 | after cancel $i |
---|
| 412 | } |
---|
| 413 | set x "hello world" |
---|
| 414 | set id junk |
---|
| 415 | set id [after 10 set x ab\0cd] |
---|
| 416 | update |
---|
| 417 | set y [string length [lindex [lindex [after info $id] 0] 2]] |
---|
| 418 | foreach i [after info] { |
---|
| 419 | after cancel $i |
---|
| 420 | } |
---|
| 421 | set y |
---|
| 422 | } {5} |
---|
| 423 | |
---|
| 424 | set event [after idle foo bar] |
---|
| 425 | scan $event after#%d id |
---|
| 426 | |
---|
| 427 | test timer-7.1 {GetAfterEvent procedure} { |
---|
| 428 | list [catch {after info xfter#$id} msg] $msg |
---|
| 429 | } "1 {event \"xfter#$id\" doesn't exist}" |
---|
| 430 | test timer-7.2 {GetAfterEvent procedure} { |
---|
| 431 | list [catch {after info afterx$id} msg] $msg |
---|
| 432 | } "1 {event \"afterx$id\" doesn't exist}" |
---|
| 433 | test timer-7.3 {GetAfterEvent procedure} { |
---|
| 434 | list [catch {after info after#ab} msg] $msg |
---|
| 435 | } {1 {event "after#ab" doesn't exist}} |
---|
| 436 | test timer-7.4 {GetAfterEvent procedure} { |
---|
| 437 | list [catch {after info after#} msg] $msg |
---|
| 438 | } {1 {event "after#" doesn't exist}} |
---|
| 439 | test timer-7.5 {GetAfterEvent procedure} { |
---|
| 440 | list [catch {after info after#${id}x} msg] $msg |
---|
| 441 | } "1 {event \"after#${id}x\" doesn't exist}" |
---|
| 442 | test timer-7.6 {GetAfterEvent procedure} { |
---|
| 443 | list [catch {after info afterx[expr $id+1]} msg] $msg |
---|
| 444 | } "1 {event \"afterx[expr $id+1]\" doesn't exist}" |
---|
| 445 | after cancel $event |
---|
| 446 | |
---|
| 447 | test timer-8.1 {AfterProc procedure} { |
---|
| 448 | set x before |
---|
| 449 | proc foo {} { |
---|
| 450 | set x untouched |
---|
| 451 | after 100 {set x after} |
---|
| 452 | after 200 |
---|
| 453 | update |
---|
| 454 | return $x |
---|
| 455 | } |
---|
| 456 | list [foo] $x |
---|
| 457 | } {untouched after} |
---|
| 458 | test timer-8.2 {AfterProc procedure} -setup { |
---|
| 459 | variable x empty |
---|
| 460 | proc myHandler {msg options} { |
---|
| 461 | variable x [list $msg [dict get $options -errorinfo]] |
---|
| 462 | } |
---|
| 463 | set handler [interp bgerror {}] |
---|
| 464 | interp bgerror {} [namespace which myHandler] |
---|
| 465 | } -body { |
---|
| 466 | after 100 {error "After error"} |
---|
| 467 | after 200 |
---|
| 468 | set y $x |
---|
| 469 | update |
---|
| 470 | list $y $x |
---|
| 471 | } -cleanup { |
---|
| 472 | interp bgerror {} $handler |
---|
| 473 | } -result {empty {{After error} {After error |
---|
| 474 | while executing |
---|
| 475 | "error "After error"" |
---|
| 476 | ("after" script)}}} |
---|
| 477 | test timer-8.3 {AfterProc procedure, deleting handler from itself} { |
---|
| 478 | foreach i [after info] { |
---|
| 479 | after cancel $i |
---|
| 480 | } |
---|
| 481 | proc foo {} { |
---|
| 482 | global x |
---|
| 483 | set x {} |
---|
| 484 | foreach i [after info] { |
---|
| 485 | lappend x [after info $i] |
---|
| 486 | } |
---|
| 487 | after cancel foo |
---|
| 488 | } |
---|
| 489 | after idle foo |
---|
| 490 | after 1000 {error "I shouldn't ever have executed"} |
---|
| 491 | update idletasks |
---|
| 492 | set x |
---|
| 493 | } {{{error "I shouldn't ever have executed"} timer}} |
---|
| 494 | test timer-8.4 {AfterProc procedure, deleting handler from itself} { |
---|
| 495 | foreach i [after info] { |
---|
| 496 | after cancel $i |
---|
| 497 | } |
---|
| 498 | proc foo {} { |
---|
| 499 | global x |
---|
| 500 | set x {} |
---|
| 501 | foreach i [after info] { |
---|
| 502 | lappend x [after info $i] |
---|
| 503 | } |
---|
| 504 | after cancel foo |
---|
| 505 | } |
---|
| 506 | after 1000 {error "I shouldn't ever have executed"} |
---|
| 507 | after idle foo |
---|
| 508 | update idletasks |
---|
| 509 | set x |
---|
| 510 | } {{{error "I shouldn't ever have executed"} timer}} |
---|
| 511 | |
---|
| 512 | foreach i [after info] { |
---|
| 513 | after cancel $i |
---|
| 514 | } |
---|
| 515 | |
---|
| 516 | # No test for FreeAfterPtr, since it is already tested above. |
---|
| 517 | |
---|
| 518 | |
---|
| 519 | test timer-9.1 {AfterCleanupProc procedure} { |
---|
| 520 | catch {interp delete x} |
---|
| 521 | interp create x |
---|
| 522 | x eval {after 200 { |
---|
| 523 | lappend x after |
---|
| 524 | puts "part 1: this message should not appear" |
---|
| 525 | }} |
---|
| 526 | after 200 {lappend x after2} |
---|
| 527 | x eval {after 200 { |
---|
| 528 | lappend x after3 |
---|
| 529 | puts "part 2: this message should not appear" |
---|
| 530 | }} |
---|
| 531 | after 200 {lappend x after4} |
---|
| 532 | x eval {after 200 { |
---|
| 533 | lappend x after5 |
---|
| 534 | puts "part 3: this message should not appear" |
---|
| 535 | }} |
---|
| 536 | interp delete x |
---|
| 537 | set x before |
---|
| 538 | after 300 |
---|
| 539 | update |
---|
| 540 | set x |
---|
| 541 | } {before after2 after4} |
---|
| 542 | |
---|
| 543 | test timer-10.1 {Bug 1016167: [after] overwrites imports} -setup { |
---|
| 544 | interp create slave |
---|
| 545 | slave eval namespace export after |
---|
| 546 | slave eval namespace eval foo namespace import ::after |
---|
| 547 | } -body { |
---|
| 548 | slave eval foo::after 1 |
---|
| 549 | slave eval namespace origin foo::after |
---|
| 550 | } -cleanup { |
---|
| 551 | # Bug will cause crash here; would cause failure otherwise |
---|
| 552 | interp delete slave |
---|
| 553 | } -result ::after |
---|
| 554 | |
---|
| 555 | test timer-11.1 {Bug 1350291: [after] overflowing 32-bit field} \ |
---|
| 556 | -body { |
---|
| 557 | set b ok |
---|
| 558 | set a [after 0x100000001 {set b "after fired early"}] |
---|
| 559 | after 100 set done 1 |
---|
| 560 | vwait done |
---|
| 561 | set b |
---|
| 562 | } \ |
---|
| 563 | -cleanup { |
---|
| 564 | catch {after cancel $a} |
---|
| 565 | } \ |
---|
| 566 | -result ok |
---|
| 567 | |
---|
| 568 | test timer-11.2 {Bug 1350293: [after] negative argument} \ |
---|
| 569 | -body { |
---|
| 570 | set l {} |
---|
| 571 | after 100 {lappend l 100; set done 1} |
---|
| 572 | after -1 {lappend l -1} |
---|
| 573 | vwait done |
---|
| 574 | set l |
---|
| 575 | } \ |
---|
| 576 | -result {-1 100} |
---|
| 577 | |
---|
| 578 | |
---|
| 579 | # cleanup |
---|
| 580 | ::tcltest::cleanupTests |
---|
| 581 | return |
---|
| 582 | |
---|
| 583 | # Local Variables: |
---|
| 584 | # mode: tcl |
---|
| 585 | # End: |
---|