os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/cmdInfo.test
First public contribution.
1 # Commands covered: none
3 # This file contains a collection of tests for Tcl_GetCommandInfo,
4 # Tcl_SetCommandInfo, Tcl_CreateCommand, Tcl_DeleteCommand, and
5 # Tcl_NameOfCommand. Sourcing this file into Tcl runs the tests
6 # and generates output for errors. No output means no errors were
9 # Copyright (c) 1993 The Regents of the University of California.
10 # Copyright (c) 1994-1996 Sun Microsystems, Inc.
11 # Copyright (c) 1998-1999 by Scriptics Corporation.
13 # See the file "license.terms" for information on usage and redistribution
14 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
16 # RCS: @(#) $Id: cmdInfo.test,v 1.7 2002/06/22 04:19:47 dgp Exp $
18 if {[lsearch [namespace children] ::tcltest] == -1} {
19 package require tcltest 2
20 namespace import -force ::tcltest::*
23 ::tcltest::testConstraint testcmdinfo \
24 [llength [info commands testcmdinfo]]
25 ::tcltest::testConstraint testcmdtoken \
26 [llength [info commands testcmdtoken]]
28 test cmdinfo-1.1 {command procedure and clientData} {testcmdinfo} {
31 } {CmdProc1 original CmdDelProc1 original :: stringProc}
32 test cmdinfo-1.2 {command procedure and clientData} {testcmdinfo} {
36 test cmdinfo-1.3 {command procedure and clientData} {testcmdinfo} {
40 } {CmdProc2 new_command_data CmdDelProc2 new_delete_data :: stringProc}
41 test cmdinfo-1.4 {command procedure and clientData} {testcmdinfo} {
45 } {CmdProc2 new_command_data}
47 test cmdinfo-2.1 {command deletion callbacks} {testcmdinfo} {
50 } {CmdDelProc1 original}
51 test cmdinfo-2.2 {command deletion callbacks} {testcmdinfo} {
55 } {CmdDelProc2 new_delete_data}
57 test cmdinfo-3.1 {Tcl_Get/SetCommandInfo return values} {testcmdinfo} {
58 testcmdinfo get non_existent
60 test cmdinfo-3.2 {Tcl_Get/SetCommandInfo return values} {testcmdinfo} {
64 test cmdinfo-3.3 {Tcl_Get/SetCommandInfo return values} {testcmdinfo} {
65 testcmdinfo modify non_existent
68 test cmdinfo-4.1 {Tcl_GetCommandName/Tcl_GetCommandFullName procedures} \
70 set x [testcmdtoken create x1]
72 set y [testcmdtoken name $x]
74 eval lappend y [testcmdtoken name $x]
75 } {newName ::newName x1 ::x1}
77 catch {rename newTestCmd {}}
78 catch {rename newTestCmd2 {}}
80 test cmdinfo-5.1 {Names for commands created when inside namespaces} \
82 # create namespace cmdInfoNs1
83 namespace eval cmdInfoNs1 {} ;# creates namespace cmdInfoNs1
84 # create namespace cmdInfoNs1::cmdInfoNs2 and execute a script in it
85 set x [namespace eval cmdInfoNs1::cmdInfoNs2 {
86 # the following creates a cmd in the global namespace
87 testcmdtoken create testCmd
89 set y [testcmdtoken name $x]
90 rename ::testCmd newTestCmd
91 eval lappend y [testcmdtoken name $x]
92 } {testCmd ::testCmd newTestCmd ::newTestCmd}
94 test cmdinfo-6.1 {Names for commands created when outside namespaces} \
96 set x [testcmdtoken create cmdInfoNs1::cmdInfoNs2::testCmd]
97 set y [testcmdtoken name $x]
98 rename cmdInfoNs1::cmdInfoNs2::testCmd newTestCmd2
99 eval lappend y [testcmdtoken name $x]
100 } {testCmd ::cmdInfoNs1::cmdInfoNs2::testCmd newTestCmd2 ::newTestCmd2}
103 catch {namespace delete cmdInfoNs1::cmdInfoNs2 cmdInfoNs1}
105 ::tcltest::cleanupTests