os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/async.test
Update contrib.
1 # Commands covered: none
3 # This file contains a collection of tests for Tcl_AsyncCreate and related
4 # library procedures. Sourcing this file into Tcl runs the tests and
5 # generates output for errors. No output means no errors were found.
7 # Copyright (c) 1993 The Regents of the University of California.
8 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
9 # Copyright (c) 1998-1999 by Scriptics Corporation.
11 # See the file "license.terms" for information on usage and redistribution
12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
14 # RCS: @(#) $Id: async.test,v 1.5 2000/04/10 17:18:56 ericm Exp $
16 if {[lsearch [namespace children] ::tcltest] == -1} {
17 package require tcltest
18 namespace import -force ::tcltest::*
21 if {[info commands testasync] == {}} {
22 puts "This application hasn't been compiled with the \"testasync\""
23 puts "command, so I can't test Tcl_AsyncCreate et al."
24 ::tcltest::cleanupTests
28 proc async1 {result code} {
34 proc async2 {result code} {
38 return -code error "xyzzy"
40 proc async3 {result code} {
42 set aresult "test pattern"
43 return -code $code $result
46 set handler1 [testasync create async1]
47 set handler2 [testasync create async2]
48 set handler3 [testasync create async3]
49 test async-1.1 {basic async handlers} {
52 list [catch {testasync mark $handler1 "original" 0} msg] $msg \
54 } {0 {new result} 0 original}
55 test async-1.2 {basic async handlers} {
58 list [catch {testasync mark $handler1 "original" 1} msg] $msg \
60 } {0 {new result} 1 original}
61 test async-1.3 {basic async handlers} {
64 list [catch {testasync mark $handler2 "old" 0} msg] $msg \
67 test async-1.4 {basic async handlers} {
70 list [catch {testasync mark $handler2 "old" 3} msg] $msg \
73 test async-1.5 {basic async handlers} {
75 list [catch {testasync mark $handler3 "foobar" 0} msg] $msg $aresult
76 } {0 foobar {test pattern}}
77 test async-1.6 {basic async handlers} {
79 list [catch {testasync mark $handler3 "foobar" 1} msg] $msg $aresult
80 } {1 foobar {test pattern}}
82 proc mult1 {result code} {
87 set hm1 [testasync create mult1]
88 proc mult2 {result code} {
93 set hm2 [testasync create mult2]
94 proc mult3 {result code} {
96 lappend x [catch {testasync mark $hm2 serial2 0}]
97 lappend x [catch {testasync mark $hm1 serial1 0}]
101 set hm3 [testasync create mult3]
103 test async-2.1 {multiple handlers} {
105 list [catch {testasync mark $hm3 "foobar" 5} msg] $msg $x
106 } {9 mult2 {0 0 mult3 mult1 mult2}}
108 proc del1 {result code} {
109 global x hm1 hm2 hm3 hm4
110 lappend x [catch {testasync mark $hm3 serial2 0}]
111 lappend x [catch {testasync mark $hm1 serial1 0}]
112 lappend x [catch {testasync mark $hm4 serial1 0}]
113 testasync delete $hm1
114 testasync delete $hm2
115 testasync delete $hm3
119 proc del2 {result code} {
124 testasync delete $handler1
125 testasync delete $hm2
126 testasync delete $hm3
127 set hm2 [testasync create del1]
128 set hm3 [testasync create mult2]
129 set hm4 [testasync create del2]
131 test async-3.1 {deleting handlers} {
133 list [catch {testasync mark $hm2 "foobar" 5} msg] $msg $x
134 } {3 del2 {0 0 0 del1 del2}}
138 ::tcltest::cleanupTests