summaryrefslogtreecommitdiffstats
path: root/tests/event.test
diff options
context:
space:
mode:
authorsebres <sebres@users.sourceforge.net>2017-07-03 13:22:04 (GMT)
committersebres <sebres@users.sourceforge.net>2017-07-03 13:22:04 (GMT)
commitc2e3847bb8d6327328f95266f169d2d3d49b1861 (patch)
tree32562e2202860a87262f5e88531d671fa0304d30 /tests/event.test
parenta66afb09682a193da54b17a65482242d1e7a23ff (diff)
downloadtcl-c2e3847bb8d6327328f95266f169d2d3d49b1861.zip
tcl-c2e3847bb8d6327328f95266f169d2d3d49b1861.tar.gz
tcl-c2e3847bb8d6327328f95266f169d2d3d49b1861.tar.bz2
after-id: introduced object of type "afterObjType" as self-referenced weak pointer to timer/idle event, used for fast access to the "after" event (cancel, info etc.);
test cases extended to cover it additionally
Diffstat (limited to 'tests/event.test')
-rw-r--r--tests/event.test53
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/event.test b/tests/event.test
index 4996b97..b6d4144 100644
--- a/tests/event.test
+++ b/tests/event.test
@@ -513,6 +513,59 @@ test event-11.4 {Tcl_VwaitCmd procedure} {} {
list [vwait y] $x $y $z $q
} {{} x-done y-done before q-done}
+test event-11.4.2 {cancel} {} {
+ foreach i [after info] {
+ after cancel $i
+ }
+ set x {}
+ # success cases:
+ after 10 {lappend x 1}
+ after 10 {lappend x 2}
+ after 10 {lappend x 3}
+ # cancel via object representation (4-6) and searching by id (7-9):
+ foreach i [list \
+ [after 0 {lappend x 4-unexpected}] \
+ [after 5 {lappend x 5-unexpected}] \
+ [after 10 {lappend x 6-unexpected}] \
+ [string trim " [after 0 {lappend x 7-unexpected}] "] \
+ [string trim " [after 5 {lappend x 8-unexpected}] "] \
+ [string trim " [after 10 {lappend x 9-unexpected}] "] \
+ ] {
+ after cancel $i
+ }
+ after 20 {set y done}
+ list [vwait y] $x $y
+} {{} {1 2 3} done}
+
+test event-11.4.3 {cancel twice and info} {} {
+ foreach i [after info] {
+ after cancel $i
+ }
+ set x {}
+ # success cases:
+ after 10 {lappend x 1}
+ after 10 {lappend x 2}
+ after 10 {lappend x 3}
+ # cancel via object representation (4-6) and searching by id (7-9):
+ foreach i [list \
+ [after 0 {lappend x 4-unexpected}] \
+ [after 5 {lappend x 5-unexpected}] \
+ [after 10 {lappend x 6-unexpected}] \
+ [string trim " [after 0 {lappend x 7-unexpected}] "] \
+ [string trim " [after 5 {lappend x 8-unexpected}] "] \
+ [string trim " [after 10 {lappend x 9-unexpected}] "] \
+ ] {
+ after cancel $i
+ # just to test possible segfault:
+ after cancel $i
+ if {![catch {after info $i} i]} {; # unexpected (event doesn't exist)
+ error "\"after info\" returns \"$i\" - should be an error"
+ }
+ }
+ after 20 {set y done}
+ list [vwait y] $x $y
+} {{} {1 2 3} done}
+
foreach i [after info] {
after cancel $i
}