diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2004-05-19 10:38:23 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2004-05-19 10:38:23 (GMT) |
commit | e2fad6a3fa1a1911c5c3014b6d9206aadcd7bf7e (patch) | |
tree | b036f8e5aab29934ba73f924fc0591df69bb193f /generic/tclTest.c | |
parent | 4a48fddf76997f4e8db2a639205e385eecf837d1 (diff) | |
download | tcl-e2fad6a3fa1a1911c5c3014b6d9206aadcd7bf7e.zip tcl-e2fad6a3fa1a1911c5c3014b6d9206aadcd7bf7e.tar.gz tcl-e2fad6a3fa1a1911c5c3014b6d9206aadcd7bf7e.tar.bz2 |
Fixed get.test so it really tests Tcl_GetInt() and uses constraints properly.
Diffstat (limited to 'generic/tclTest.c')
-rw-r--r-- | generic/tclTest.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c index 4867e1c..fc0356f 100644 --- a/generic/tclTest.c +++ b/generic/tclTest.c @@ -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: tclTest.c,v 1.81 2004/04/06 22:25:55 dgp Exp $ + * RCS: @(#) $Id: tclTest.c,v 1.82 2004/05/19 10:38:24 dkf Exp $ */ #define TCL_TEST @@ -257,6 +257,8 @@ static int TestfeventCmd _ANSI_ARGS_((ClientData dummy, Tcl_Interp *interp, int argc, CONST char **argv)); static int TestgetassocdataCmd _ANSI_ARGS_((ClientData dummy, Tcl_Interp *interp, int argc, CONST char **argv)); +static int TestgetintCmd _ANSI_ARGS_((ClientData dummy, + Tcl_Interp *interp, int argc, CONST char **argv)); static int TestgetplatformCmd _ANSI_ARGS_((ClientData dummy, Tcl_Interp *interp, int argc, CONST char **argv)); static int TestgetvarfullnameCmd _ANSI_ARGS_(( @@ -634,6 +636,8 @@ Tcltest_Init(interp) (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, "testgetassocdata", TestgetassocdataCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); + Tcl_CreateCommand(interp, "testgetint", TestgetintCmd, + (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateCommand(interp, "testgetplatform", TestgetplatformCmd, (ClientData) 0, (Tcl_CmdDeleteProc *) NULL); Tcl_CreateObjCommand(interp, "testgetvarfullname", @@ -6604,3 +6608,33 @@ TestHashSystemHashCmd(clientData, interp, objc, objv) Tcl_AppendResult(interp, "OK", NULL); return TCL_OK; } + +/* + * Used for testing Tcl_GetInt which is no longer used directly by the + * core very much. + */ +static int +TestgetintCmd(dummy, interp, argc, argv) + ClientData dummy; + Tcl_Interp *interp; + int argc; + CONST char **argv; +{ + if (argc < 2) { + Tcl_SetResult(interp, "wrong # args", TCL_STATIC); + return TCL_ERROR; + } else { + int val,i,total=0; + char buf[TCL_INTEGER_SPACE]; + + for (i=1 ; i<argc ; i++) { + if (Tcl_GetInt(interp, argv[i], &val) != TCL_OK) { + return TCL_ERROR; + } + total += val; + } + TclFormatInt(buf, total); + Tcl_SetResult(interp, buf, TCL_VOLATILE); + return TCL_OK; + } +} |