summaryrefslogtreecommitdiffstats
path: root/generic/tclTest.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2025-05-09 18:13:17 (GMT)
committerdgp <dgp@users.sourceforge.net>2025-05-09 18:13:17 (GMT)
commit0e8128247f4e30a8267d342c323765b6bf6cd644 (patch)
tree178ac8dfc9bc556dc9b906db4b10fbec1d068146 /generic/tclTest.c
parent9c7449fb49496cf68c0eef7452e0ad2bb3fac931 (diff)
downloadtcl-0e8128247f4e30a8267d342c323765b6bf6cd644.zip
tcl-0e8128247f4e30a8267d342c323765b6bf6cd644.tar.gz
tcl-0e8128247f4e30a8267d342c323765b6bf6cd644.tar.bz2
[fd1585e2a1] Adopt efficient internal indexing calculation utility TclMSB().
Diffstat (limited to 'generic/tclTest.c')
-rw-r--r--generic/tclTest.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/generic/tclTest.c b/generic/tclTest.c
index d58478d..72ed211 100644
--- a/generic/tclTest.c
+++ b/generic/tclTest.c
@@ -251,6 +251,7 @@ static Tcl_ObjCmdProc TestlinkarrayCmd;
static Tcl_ObjCmdProc TestlistrepCmd;
static Tcl_ObjCmdProc TestlocaleCmd;
static Tcl_ObjCmdProc TestmainthreadCmd;
+static Tcl_ObjCmdProc TestmsbObjCmd;
static Tcl_ObjCmdProc TestsetmainloopCmd;
static Tcl_ObjCmdProc TestexitmainloopCmd;
static Tcl_ObjCmdProc TestpanicCmd;
@@ -647,6 +648,7 @@ Tcltest_Init(
Tcl_CreateObjCommand(interp, "testlistrep", TestlistrepCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testlocale", TestlocaleCmd, NULL,
NULL);
+ Tcl_CreateObjCommand(interp, "testmsb", TestmsbObjCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testpanic", TestpanicCmd, NULL, NULL);
Tcl_CreateObjCommand(interp, "testparseargs", TestparseargsCmd,NULL,NULL);
Tcl_CreateObjCommand(interp, "testparser", TestparserCmd,
@@ -4003,6 +4005,48 @@ CleanupTestSetassocdataTests(
/*
*----------------------------------------------------------------------
*
+ * TestmsbObjCmd --
+ *
+ * This procedure implements the "testmsb" command. It is
+ * used for testing the TclMSB() routine.
+ *
+ * Results:
+ * A standard Tcl result.
+ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+static int
+TestmsbObjCmd(
+ TCL_UNUSED(void *),
+ Tcl_Interp *interp, /* Current interpreter. */
+ int objc, /* Number of arguments. */
+ Tcl_Obj *const objv[]) /* The argument objects. */
+{
+ Tcl_WideInt w = 0;
+
+ if (objc != 2) {
+ Tcl_WrongNumArgs(interp, 1, objv, "integer");
+ return TCL_ERROR;
+ }
+ if (TCL_OK != Tcl_GetWideIntFromObj(interp, objv[1], &w)) {
+ return TCL_ERROR;
+ }
+ if (w <= 0) {
+ Tcl_SetObjResult(interp,
+ Tcl_NewStringObj("argument must be positive",-1));
+ return TCL_ERROR;
+ }
+ Tcl_SetObjResult(interp, Tcl_NewIntObj(TclMSB((unsigned long long)w)));
+ return TCL_OK;
+}
+
+/*
+ *----------------------------------------------------------------------
+ *
* TestparserCmd --
*
* This procedure implements the "testparser" command. It is