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