Debian Codegraph @

tests/assocd.test

raw
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 package require tcltest 2.5
15 namespace import ::tcltest::*
16
17 ::tcltest::loadTestedCommands
18 catch [list package require -exact Tcltest [info patchlevel]]
19
20 testConstraint testgetassocdata [llength [info commands testgetassocdata]]
21 testConstraint testsetassocdata [llength [info commands testsetassocdata]]
22 testConstraint testdelassocdata [llength [info commands testdelassocdata]]
23
24 test assocd-1.1 {testing setting assoc data} testsetassocdata {
25 testsetassocdata a 1
26 } ""
27 test assocd-1.2 {testing setting assoc data} testsetassocdata {
28 testsetassocdata a 2
29 } ""
30 test assocd-1.3 {testing setting assoc data} testsetassocdata {
31 testsetassocdata 123 456
32 } ""
33 test assocd-1.4 {testing setting assoc data} testsetassocdata {
34 testsetassocdata abc "abc d e f"
35 } ""
36
37 test assocd-2.1 {testing getting assoc data} -setup {
38 testsetassocdata a 2
39 } -constraints {testgetassocdata} -body {
40 testgetassocdata a
41 } -result 2
42 test assocd-2.2 {testing getting assoc data} -setup {
43 testsetassocdata 123 456
44 } -constraints {testgetassocdata} -body {
45 testgetassocdata 123
46 } -result 456
47 test assocd-2.3 {testing getting assoc data} -setup {
48 testsetassocdata abc "abc d e f"
49 } -constraints {testgetassocdata} -body {
50 testgetassocdata abc
51 } -result "abc d e f"
52 test assocd-2.4 {testing getting assoc data} testgetassocdata {
53 testgetassocdata xxx
54 } ""
55
56 test assocd-3.1 {testing deleting assoc data} testdelassocdata {
57 testdelassocdata a
58 } ""
59 test assocd-3.2 {testing deleting assoc data} testdelassocdata {
60 testdelassocdata 123
61 } ""
62 test assocd-3.3 {testing deleting assoc data} testdelassocdata {
63 list [catch {testdelassocdata nonexistent} msg] $msg
64 } {0 {}}
65
66 # cleanup
67 cleanupTests
68 return