diff options
-rw-r--r-- | generic/tclProc.c | 33 | ||||
-rw-r--r-- | tests/compile.test | 5 | ||||
-rw-r--r-- | tests/init.test | 8 | ||||
-rw-r--r-- | tests/proc-old.test | 38 | ||||
-rw-r--r-- | tests/proc.test | 4 | ||||
-rw-r--r-- | tests/rename.test | 4 |
6 files changed, 52 insertions, 40 deletions
diff --git a/generic/tclProc.c b/generic/tclProc.c index feff5a0..d2c8227 100644 --- a/generic/tclProc.c +++ b/generic/tclProc.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclProc.c,v 1.23 1999/12/12 02:26:42 hobbs Exp $ + * RCS: @(#) $Id: tclProc.c,v 1.24 2000/05/03 00:14:35 hobbs Exp $ */ #include "tclInt.h" @@ -840,6 +840,7 @@ TclObjInterpProc(clientData, interp, objc, objv) register CompiledLocal *localPtr; char *procName; int nameLen, localCt, numArgs, argCt, i, result; + Tcl_Obj *objResult = Tcl_GetObjResult(interp); /* * This procedure generates an array "compiledLocals" that holds the @@ -960,20 +961,32 @@ TclObjInterpProc(clientData, interp, objc, objv) Tcl_IncrRefCount(objPtr); /* since the local variable now has * another reference to object. */ } else { - Tcl_ResetResult(interp); - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "no value given for parameter \"", localPtr->name, - "\" to \"", Tcl_GetString(objv[0]), "\"", (char *) NULL); - result = TCL_ERROR; - goto procDone; + goto incorrectArgs; } varPtr++; localPtr = localPtr->nextPtr; } if (argCt > 0) { - Tcl_AppendStringsToObj(Tcl_GetObjResult(interp), - "called \"", Tcl_GetString(objv[0]), - "\" with too many arguments", (char *) NULL); + incorrectArgs: + /* + * Build up equivalent to Tcl_WrongNumArgs message for proc + */ + Tcl_ResetResult(interp); + Tcl_AppendStringsToObj(objResult, + "wrong # args: should be \"", procName, (char *) NULL); + localPtr = procPtr->firstLocalPtr; + for (i = 1; i <= numArgs; i++) { + if (localPtr->defValuePtr != NULL) { + Tcl_AppendStringsToObj(objResult, + " ?", localPtr->name, "?", (char *) NULL); + } else { + Tcl_AppendStringsToObj(objResult, + " ", localPtr->name, (char *) NULL); + } + localPtr = localPtr->nextPtr; + } + Tcl_AppendStringsToObj(objResult, "\"", (char *) NULL); + result = TCL_ERROR; goto procDone; } diff --git a/tests/compile.test b/tests/compile.test index e231ffe..7a26031 100644 --- a/tests/compile.test +++ b/tests/compile.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: compile.test,v 1.8 2000/04/10 17:18:58 ericm Exp $ +# RCS: @(#) $Id: compile.test,v 1.9 2000/05/03 00:14:36 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -44,8 +44,7 @@ test compile-1.1 {TclCompileString: look up cmds in proc ns, not current ns} { test compile-1.2 {TclCompileString, error result is reset if TclGetLong determines word isn't an integer} { proc p {x} {info commands 3m} list [catch {p} msg] $msg -} {1 {no value given for parameter "x" to "p"}} - +} {1 {wrong # args: should be "p x"}} test compile-2.1 {TclCompileDollarVar: global scalar name with ::s} { catch {unset x} set x 123 diff --git a/tests/init.test b/tests/init.test index 7c5a159..46f4429 100644 --- a/tests/init.test +++ b/tests/init.test @@ -10,7 +10,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: init.test,v 1.6 2000/04/10 17:19:00 ericm Exp $ +# RCS: @(#) $Id: init.test,v 1.7 2000/05/03 00:14:36 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -78,13 +78,13 @@ test init-2.0 {load parray - stage 1} { set ret [catch {namespace eval ::tcltest {parray}} error] rename parray {} ; # remove it, for the next test - that should not fail. list $ret $error -} {1 {no value given for parameter "a" to "parray"}} +} {1 {wrong # args: should be "parray a ?pattern?"}} test init-2.1 {load parray - stage 2} { set ret [catch {namespace eval ::tcltest {parray}} error] list $ret $error -} {1 {no value given for parameter "a" to "parray"}} +} {1 {wrong # args: should be "parray a ?pattern?"}} auto_reset @@ -139,7 +139,7 @@ test init-2.8 {load http::geturl (package)} { # removing it, for the next test. should not fail. rename ::http::geturl {} ; list $ret $error -} {1 {no value given for parameter "url" to "http:::geturl"}} +} {1 {wrong # args: should be "http:::geturl url args"}} test init-3.0 {random stuff in the auto_index, should still work} { diff --git a/tests/proc-old.test b/tests/proc-old.test index f139f8c..9365042 100644 --- a/tests/proc-old.test +++ b/tests/proc-old.test @@ -14,7 +14,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: proc-old.test,v 1.6 2000/04/10 17:19:03 ericm Exp $ +# RCS: @(#) $Id: proc-old.test,v 1.7 2000/05/03 00:14:36 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -160,80 +160,80 @@ test proc-old-3.9 {local and global arrays} { } {{w t1}} catch {unset a} -test proc-old-3.1 {arguments and defaults} { +test proc-old-30.1 {arguments and defaults} { proc tproc {x y z} { return [list $x $y $z] } tproc 11 12 13 } {11 12 13} -test proc-old-3.2 {arguments and defaults} { +test proc-old-30.2 {arguments and defaults} { proc tproc {x y z} { return [list $x $y $z] } list [catch {tproc 11 12} msg] $msg -} {1 {no value given for parameter "z" to "tproc"}} -test proc-old-3.3 {arguments and defaults} { +} {1 {wrong # args: should be "tproc x y z"}} +test proc-old-30.3 {arguments and defaults} { proc tproc {x y z} { return [list $x $y $z] } list [catch {tproc 11 12 13 14} msg] $msg -} {1 {called "tproc" with too many arguments}} -test proc-old-3.4 {arguments and defaults} { +} {1 {wrong # args: should be "tproc x y z"}} +test proc-old-30.4 {arguments and defaults} { proc tproc {x {y y-default} {z z-default}} { return [list $x $y $z] } tproc 11 12 13 } {11 12 13} -test proc-old-3.5 {arguments and defaults} { +test proc-old-30.5 {arguments and defaults} { proc tproc {x {y y-default} {z z-default}} { return [list $x $y $z] } tproc 11 12 } {11 12 z-default} -test proc-old-3.6 {arguments and defaults} { +test proc-old-30.6 {arguments and defaults} { proc tproc {x {y y-default} {z z-default}} { return [list $x $y $z] } tproc 11 } {11 y-default z-default} -test proc-old-3.7 {arguments and defaults} { +test proc-old-30.7 {arguments and defaults} { proc tproc {x {y y-default} {z z-default}} { return [list $x $y $z] } list [catch {tproc} msg] $msg -} {1 {no value given for parameter "x" to "tproc"}} -test proc-old-3.8 {arguments and defaults} { +} {1 {wrong # args: should be "tproc x ?y? ?z?"}} +test proc-old-30.8 {arguments and defaults} { list [catch { proc tproc {x {y y-default} z} { return [list $x $y $z] } tproc 2 3 } msg] $msg -} {1 {no value given for parameter "z" to "tproc"}} -test proc-old-3.9 {arguments and defaults} { +} {1 {wrong # args: should be "tproc x ?y? z"}} +test proc-old-30.9 {arguments and defaults} { proc tproc {x {y y-default} args} { return [list $x $y $args] } tproc 2 3 4 5 } {2 3 {4 5}} -test proc-old-3.10 {arguments and defaults} { +test proc-old-30.10 {arguments and defaults} { proc tproc {x {y y-default} args} { return [list $x $y $args] } tproc 2 3 } {2 3 {}} -test proc-old-3.11 {arguments and defaults} { +test proc-old-30.11 {arguments and defaults} { proc tproc {x {y y-default} args} { return [list $x $y $args] } tproc 2 } {2 y-default {}} -test proc-old-3.12 {arguments and defaults} { +test proc-old-30.12 {arguments and defaults} { proc tproc {x {y y-default} args} { return [list $x $y $args] } list [catch {tproc} msg] $msg -} {1 {no value given for parameter "x" to "tproc"}} +} {1 {wrong # args: should be "tproc x ?y? args"}} test proc-old-4.1 {variable numbers of arguments} { proc tproc args {return $args} @@ -258,7 +258,7 @@ test proc-old-4.5 {variable numbers of arguments} { test proc-old-4.6 {variable numbers of arguments} { proc tproc {x missing args} {return $args} list [catch {tproc 1} msg] $msg -} {1 {no value given for parameter "missing" to "tproc"}} +} {1 {wrong # args: should be "tproc x missing args"}} test proc-old-5.1 {error conditions} { list [catch {proc} msg] $msg diff --git a/tests/proc.test b/tests/proc.test index e4fa1aa..a96373a 100644 --- a/tests/proc.test +++ b/tests/proc.test @@ -13,7 +13,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: proc.test,v 1.7 2000/04/10 17:19:03 ericm Exp $ +# RCS: @(#) $Id: proc.test,v 1.8 2000/05/03 00:14:36 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -159,7 +159,7 @@ test proc-3.4 {TclObjInterpProc, procs execute in the namespace in which they we test proc-3.5 {TclObjInterpProc, any old result is reset before appending error msg about missing arguments} { proc p {x} {info commands 3m} list [catch {p} msg] $msg -} {1 {no value given for parameter "x" to "p"}} +} {1 {wrong # args: should be "p x"}} catch {eval namespace delete [namespace children :: test_ns_*]} catch {rename p ""} diff --git a/tests/rename.test b/tests/rename.test index 246dbf8..bb71112 100644 --- a/tests/rename.test +++ b/tests/rename.test @@ -11,7 +11,7 @@ # See the file "license.terms" for information on usage and redistribution # of this file, and for a DISCLAIMER OF ALL WARRANTIES. # -# RCS: @(#) $Id: rename.test,v 1.8 2000/04/10 17:19:03 ericm Exp $ +# RCS: @(#) $Id: rename.test,v 1.9 2000/05/03 00:14:36 hobbs Exp $ if {[lsearch [namespace children] ::tcltest] == -1} { package require tcltest @@ -168,7 +168,7 @@ test rename-6.1 {old code invalidated (epoch incremented) when cmd with compile proc incr {} {puts "new incr called!"} catch {x} msg set msg -} {called "incr" with too many arguments} +} {wrong # args: should be "incr"} if {[info commands incr.old] != {}} { catch {rename incr {}} |