summaryrefslogtreecommitdiffstats
path: root/tests/assocd.test
blob: 9fc3871dec6a60d69fb4bde323c11c1af26daf20 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# This file tests the AssocData facility of Tcl
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 1991-1994 The Regents of the University of California.
# Copyright (c) 1994 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: assocd.test,v 1.4 1999/06/26 03:54:10 jenn Exp $

if {[lsearch [namespace children] ::tcltest] == -1} {
    package require tcltest
    namespace import ::tcltest::*
}

if {[string compare testsetassocdata [info commands testsetassocdata]] != 0} {
    puts "This application hasn't been compiled with the tests for assocData,"
    puts "therefore I am skipping all of these tests."
    ::tcltest::cleanupTests
    return
}

test assocd-1.1 {testing setting assoc data} {
   testsetassocdata a 1
} ""
test assocd-1.2 {testing setting assoc data} {
   testsetassocdata a 2
} ""
test assocd-1.3 {testing setting assoc data} {
   testsetassocdata 123 456
} ""
test assocd-1.4 {testing setting assoc data} {
   testsetassocdata abc "abc d e f"
} ""

test assocd-2.1 {testing getting assoc data} {
   testgetassocdata a
} 2
test assocd-2.2 {testing getting assoc data} {
   testgetassocdata 123
} 456
test assocd-2.3 {testing getting assoc data} {
   testgetassocdata abc
} {abc d e f}
test assocd-2.4 {testing getting assoc data} {
   testgetassocdata xxx
} ""

test assocd-3.1 {testing deleting assoc data} {
   testdelassocdata a
} ""
test assocd-3.2 {testing deleting assoc data} {
   testdelassocdata 123
} ""
test assocd-3.3 {testing deleting assoc data} {
   list [catch {testdelassocdata nonexistent} msg] $msg
} {0 {}}

# cleanup
::tcltest::cleanupTests
return