os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/cmdInfo.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
# Commands covered:  none
sl@0
     2
#
sl@0
     3
# This file contains a collection of tests for Tcl_GetCommandInfo,
sl@0
     4
# Tcl_SetCommandInfo, Tcl_CreateCommand, Tcl_DeleteCommand, and
sl@0
     5
# Tcl_NameOfCommand.  Sourcing this file into Tcl runs the tests
sl@0
     6
# and generates output for errors.  No output means no errors were
sl@0
     7
# found.
sl@0
     8
#
sl@0
     9
# Copyright (c) 1993 The Regents of the University of California.
sl@0
    10
# Copyright (c) 1994-1996 Sun Microsystems, Inc.
sl@0
    11
# Copyright (c) 1998-1999 by Scriptics Corporation.
sl@0
    12
#
sl@0
    13
# See the file "license.terms" for information on usage and redistribution
sl@0
    14
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
sl@0
    15
#
sl@0
    16
# RCS: @(#) $Id: cmdInfo.test,v 1.7 2002/06/22 04:19:47 dgp Exp $
sl@0
    17
sl@0
    18
if {[lsearch [namespace children] ::tcltest] == -1} {
sl@0
    19
    package require tcltest 2
sl@0
    20
    namespace import -force ::tcltest::*
sl@0
    21
}
sl@0
    22
sl@0
    23
::tcltest::testConstraint testcmdinfo \
sl@0
    24
	[llength [info commands testcmdinfo]]
sl@0
    25
::tcltest::testConstraint testcmdtoken \
sl@0
    26
	[llength [info commands testcmdtoken]]
sl@0
    27
sl@0
    28
test cmdinfo-1.1 {command procedure and clientData} {testcmdinfo} {
sl@0
    29
    testcmdinfo create x1
sl@0
    30
    testcmdinfo get x1
sl@0
    31
} {CmdProc1 original CmdDelProc1 original :: stringProc}
sl@0
    32
test cmdinfo-1.2 {command procedure and clientData} {testcmdinfo} {
sl@0
    33
    testcmdinfo create x1
sl@0
    34
    x1
sl@0
    35
} {CmdProc1 original}
sl@0
    36
test cmdinfo-1.3 {command procedure and clientData} {testcmdinfo} {
sl@0
    37
    testcmdinfo create x1
sl@0
    38
    testcmdinfo modify x1
sl@0
    39
    testcmdinfo get x1
sl@0
    40
} {CmdProc2 new_command_data CmdDelProc2 new_delete_data :: stringProc}
sl@0
    41
test cmdinfo-1.4 {command procedure and clientData} {testcmdinfo} {
sl@0
    42
    testcmdinfo create x1
sl@0
    43
    testcmdinfo modify x1
sl@0
    44
    x1
sl@0
    45
} {CmdProc2 new_command_data}
sl@0
    46
sl@0
    47
test cmdinfo-2.1 {command deletion callbacks} {testcmdinfo} {
sl@0
    48
    testcmdinfo create x1
sl@0
    49
    testcmdinfo delete x1
sl@0
    50
} {CmdDelProc1 original}
sl@0
    51
test cmdinfo-2.2 {command deletion callbacks} {testcmdinfo} {
sl@0
    52
    testcmdinfo create x1
sl@0
    53
    testcmdinfo modify x1
sl@0
    54
    testcmdinfo delete x1
sl@0
    55
} {CmdDelProc2 new_delete_data}
sl@0
    56
sl@0
    57
test cmdinfo-3.1 {Tcl_Get/SetCommandInfo return values} {testcmdinfo} {
sl@0
    58
    testcmdinfo get non_existent
sl@0
    59
} {??}
sl@0
    60
test cmdinfo-3.2 {Tcl_Get/SetCommandInfo return values} {testcmdinfo} {
sl@0
    61
    testcmdinfo create x1
sl@0
    62
    testcmdinfo modify x1
sl@0
    63
} 1
sl@0
    64
test cmdinfo-3.3 {Tcl_Get/SetCommandInfo return values} {testcmdinfo} {
sl@0
    65
    testcmdinfo modify non_existent
sl@0
    66
} 0
sl@0
    67
sl@0
    68
test cmdinfo-4.1 {Tcl_GetCommandName/Tcl_GetCommandFullName procedures} \
sl@0
    69
	{testcmdtoken} {
sl@0
    70
    set x [testcmdtoken create x1]
sl@0
    71
    rename x1 newName
sl@0
    72
    set y [testcmdtoken name $x]
sl@0
    73
    rename newName x1
sl@0
    74
    eval lappend y [testcmdtoken name $x]
sl@0
    75
} {newName ::newName x1 ::x1}
sl@0
    76
sl@0
    77
catch {rename newTestCmd {}}
sl@0
    78
catch {rename newTestCmd2 {}}
sl@0
    79
sl@0
    80
test cmdinfo-5.1 {Names for commands created when inside namespaces} \
sl@0
    81
	{testcmdtoken} {
sl@0
    82
    # create namespace cmdInfoNs1
sl@0
    83
    namespace eval cmdInfoNs1 {}   ;# creates namespace cmdInfoNs1
sl@0
    84
    # create namespace cmdInfoNs1::cmdInfoNs2 and execute a script in it
sl@0
    85
    set x [namespace eval cmdInfoNs1::cmdInfoNs2 {
sl@0
    86
        # the following creates a cmd in the global namespace
sl@0
    87
        testcmdtoken create testCmd
sl@0
    88
    }]
sl@0
    89
    set y [testcmdtoken name $x]
sl@0
    90
    rename ::testCmd newTestCmd
sl@0
    91
    eval lappend y [testcmdtoken name $x]
sl@0
    92
} {testCmd ::testCmd newTestCmd ::newTestCmd}
sl@0
    93
sl@0
    94
test cmdinfo-6.1 {Names for commands created when outside namespaces} \
sl@0
    95
	{testcmdtoken} {
sl@0
    96
    set x [testcmdtoken create cmdInfoNs1::cmdInfoNs2::testCmd]
sl@0
    97
    set y [testcmdtoken name $x]
sl@0
    98
    rename cmdInfoNs1::cmdInfoNs2::testCmd newTestCmd2
sl@0
    99
    eval lappend y [testcmdtoken name $x]
sl@0
   100
} {testCmd ::cmdInfoNs1::cmdInfoNs2::testCmd newTestCmd2 ::newTestCmd2}
sl@0
   101
sl@0
   102
# cleanup
sl@0
   103
catch {namespace delete cmdInfoNs1::cmdInfoNs2 cmdInfoNs1}
sl@0
   104
catch {rename x1 ""}
sl@0
   105
::tcltest::cleanupTests
sl@0
   106
return