1 | # This file tests the AssocData facility of Tcl |
---|
2 | # |
---|
3 | # This file contains a collection of tests for one or more of the Tcl |
---|
4 | # built-in commands. Sourcing this file into Tcl runs the tests and |
---|
5 | # generates output for errors. No output means no errors were found. |
---|
6 | # |
---|
7 | # Copyright (c) 1991-1994 The Regents of the University of California. |
---|
8 | # Copyright (c) 1994 Sun Microsystems, Inc. |
---|
9 | # Copyright (c) 1998-1999 by Scriptics Corporation. |
---|
10 | # |
---|
11 | # See the file "license.terms" for information on usage and redistribution |
---|
12 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
13 | # |
---|
14 | # RCS: @(#) $Id: assocd.test,v 1.6 2004/05/19 10:42:00 dkf Exp $ |
---|
15 | |
---|
16 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
17 | package require tcltest |
---|
18 | namespace import -force ::tcltest::* |
---|
19 | } |
---|
20 | |
---|
21 | testConstraint testgetassocdata [llength [info commands testgetassocdata]] |
---|
22 | testConstraint testsetassocdata [llength [info commands testsetassocdata]] |
---|
23 | testConstraint testdelassocdata [llength [info commands testdelassocdata]] |
---|
24 | |
---|
25 | test assocd-1.1 {testing setting assoc data} testsetassocdata { |
---|
26 | testsetassocdata a 1 |
---|
27 | } "" |
---|
28 | test assocd-1.2 {testing setting assoc data} testsetassocdata { |
---|
29 | testsetassocdata a 2 |
---|
30 | } "" |
---|
31 | test assocd-1.3 {testing setting assoc data} testsetassocdata { |
---|
32 | testsetassocdata 123 456 |
---|
33 | } "" |
---|
34 | test assocd-1.4 {testing setting assoc data} testsetassocdata { |
---|
35 | testsetassocdata abc "abc d e f" |
---|
36 | } "" |
---|
37 | |
---|
38 | test assocd-2.1 {testing getting assoc data} testgetassocdata { |
---|
39 | testgetassocdata a |
---|
40 | } 2 |
---|
41 | test assocd-2.2 {testing getting assoc data} testgetassocdata { |
---|
42 | testgetassocdata 123 |
---|
43 | } 456 |
---|
44 | test assocd-2.3 {testing getting assoc data} testgetassocdata { |
---|
45 | testgetassocdata abc |
---|
46 | } {abc d e f} |
---|
47 | test assocd-2.4 {testing getting assoc data} testgetassocdata { |
---|
48 | testgetassocdata xxx |
---|
49 | } "" |
---|
50 | |
---|
51 | test assocd-3.1 {testing deleting assoc data} testdelassocdata { |
---|
52 | testdelassocdata a |
---|
53 | } "" |
---|
54 | test assocd-3.2 {testing deleting assoc data} testdelassocdata { |
---|
55 | testdelassocdata 123 |
---|
56 | } "" |
---|
57 | test assocd-3.3 {testing deleting assoc data} testdelassocdata { |
---|
58 | list [catch {testdelassocdata nonexistent} msg] $msg |
---|
59 | } {0 {}} |
---|
60 | |
---|
61 | # cleanup |
---|
62 | ::tcltest::cleanupTests |
---|
63 | return |
---|