diff options
Diffstat (limited to 'tests/indexObj.test')
| -rw-r--r-- | tests/indexObj.test | 73 |
1 files changed, 63 insertions, 10 deletions
diff --git a/tests/indexObj.test b/tests/indexObj.test index 7fea854..646cb02 100644 --- a/tests/indexObj.test +++ b/tests/indexObj.test @@ -1,22 +1,24 @@ # This file is a Tcl script to test out the the procedures in file -# tkIndexObj.c, which implement indexed table lookups. The tests here -# are organized in the standard fashion for Tcl tests. +# tkIndexObj.c, which implement indexed table lookups. The tests here are +# organized in the standard fashion for Tcl tests. # # Copyright (c) 1997 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: indexObj.test,v 1.9 2004/11/25 16:37:15 dkf Exp $ +# See the file "license.terms" for information on usage and redistribution of +# this file, and for a DISCLAIMER OF ALL WARRANTIES. if {[lsearch [namespace children] ::tcltest] == -1} { - package require tcltest + package require tcltest 2 namespace import -force ::tcltest::* } -testConstraint testindexobj [llength [info commands testindexobj]] +::tcltest::loadTestedCommands +catch [list package require -exact Tcltest [info patchlevel]] +testConstraint testindexobj [llength [info commands testindexobj]] +testConstraint testparseargs [llength [info commands testparseargs]] + test indexObj-1.1 {exact match} testindexobj { testindexobj 1 1 xyz abc def xyz alm } {2} @@ -38,6 +40,12 @@ test indexObj-1.6 {forced exact match} testindexobj { test indexObj-1.7 {forced exact match} testindexobj { testindexobj 1 0 x abc def xalb xyz alm x } {5} +test indexObj-1.8 {exact match of empty values} testindexobj { + testindexobj 1 1 {} a aa aaa {} b bb bbb +} 3 +test indexObj-1.9 {exact match of empty values} testindexobj { + testindexobj 1 0 {} a aa aaa {} b bb bbb +} 3 test indexObj-2.1 {no match} testindexobj { list [catch {testindexobj 1 1 dddd abc def xalb xyz alm x} msg] $msg @@ -54,6 +62,22 @@ test indexObj-2.4 {ambiguous value} testindexobj { test indexObj-2.5 {omit error message} testindexobj { list [catch {testindexobj 0 1 d x} msg] $msg } {1 {}} +test indexObj-2.6 {TCL_EXACT => no "ambiguous" error message} testindexobj { + list [catch {testindexobj 1 0 d dumb daughter a c} msg] $msg +} {1 {bad token "d": must be dumb, daughter, a, or c}} +test indexObj-2.7 {exact match of empty values} testindexobj { + list [catch {testindexobj 1 1 {} a b c} msg] $msg +} {1 {ambiguous token "": must be a, b, or c}} +test indexObj-2.8 {exact match of empty values: singleton case} testindexobj { + list [catch {testindexobj 1 0 {} a} msg] $msg +} {1 {bad token "": must be a}} +test indexObj-2.9 {non-exact match of empty values: singleton case} testindexobj { + # NOTE this is a special case. Although the empty string is a + # unique prefix, we have an established history of rejecting + # empty lookup keys, requiring any unique prefix match to have + # at least one character. + list [catch {testindexobj 1 1 {} a} msg] $msg +} {1 {bad token "": must be a}} test indexObj-3.1 {cache result to skip next lookup} testindexobj { testindexobj check 42 @@ -66,8 +90,8 @@ test indexObj-4.1 {free old internal representation} testindexobj { } {2} test indexObj-5.1 {Tcl_WrongNumArgs} testindexobj { - testwrongnumargs 1 "?option?" mycmd -} "wrong # args: should be \"mycmd ?option?\"" + testwrongnumargs 1 "?-switch?" mycmd +} "wrong # args: should be \"mycmd ?-switch?\"" test indexObj-5.2 {Tcl_WrongNumArgs} testindexobj { testwrongnumargs 2 "bar" mycmd foo } "wrong # args: should be \"mycmd foo bar\"" @@ -108,6 +132,35 @@ test indexObj-6.4 {Tcl_GetIndexFromObjStruct} testindexobj { testgetindexfromobjstruct $x 1 } "wrong # args: should be \"testgetindexfromobjstruct c 1\"" +test indexObj-7.1 {Tcl_ParseArgsObjv} testparseargs { + testparseargs +} {0 1 testparseargs} +test indexObj-7.2 {Tcl_ParseArgsObjv} testparseargs { + testparseargs -bool +} {1 1 testparseargs} +test indexObj-7.3 {Tcl_ParseArgsObjv} testparseargs { + testparseargs -bool bar +} {1 2 {testparseargs bar}} +test indexObj-7.4 {Tcl_ParseArgsObjv} testparseargs { + testparseargs bar +} {0 2 {testparseargs bar}} +test indexObj-7.5 {Tcl_ParseArgsObjv} -constraints testparseargs -body { + testparseargs -help +} -returnCodes error -result {Command-specific options: + -bool: booltest + --: Marks the end of the options + -help: Print summary of command-line options and abort} +test indexObj-7.6 {Tcl_ParseArgsObjv} testparseargs { + testparseargs -- -bool -help +} {0 3 {testparseargs -bool -help}} +test indexObj-7.7 {Tcl_ParseArgsObjv memory management} testparseargs { + testparseargs 1 2 3 4 5 6 7 8 9 0 -bool 1 2 3 4 5 6 7 8 9 0 +} {1 21 {testparseargs 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0}} + # cleanup ::tcltest::cleanupTests return + +# Local Variables: +# mode: tcl +# End: |
