| Artifact ID: | 8e4f319c9f9e88e983eca57009aff223f4d5b96b5285ed8d005bba4c62a85ca3 |
|---|---|
| Page Name: | tcl::test commands |
| Date: | 2026-04-11 12:39:40 |
| Original User: | apnadkarni |
| Mimetype: | text/x-markdown |
Tcl Test Harness Commands Reference
This document has been generated using Claude. There will be errors of omission and commission. Please fix as you run into them and add new commands here when you add them to the code.
This document lists all Tcl commands implemented by the Tcl test harness, as
found in the source files
generic/tclTest.c,
generic/tclTestObj.c,
generic/tclTestProcBodyObj.c,
and
generic/tclTestABSList.c.
These commands are not part of the standard Tcl distribution. They are
loaded only by the test suite (via the tcl::test package / tcltest
extension) and are intended exclusively for testing Tcl's C interfaces.
Summary Table
| Command | Source File | Description |
|---|---|---|
gettimes |
tclTest.c |
Measures time taken by various low-level Tcl operations. |
lstring |
tclTestABSList.c |
Creates an abstract-list object whose elements are the individual characters of a string. |
noop |
tclTest.c |
No-operation command; used to measure dispatch overhead. |
tcl::procbodytest::check |
tclTestProcBodyObj.c |
Verifies the tcl::procbodytest package version matches what was registered. |
tcl::procbodytest::proc |
tclTestProcBodyObj.c |
Creates a procedure by copying a compiled body from an existing proc. |
testapplylambda |
tclTest.c |
Directly exercises the C entry point of the apply command. |
testappverifierpresent |
tclTest.c |
Returns whether the Windows Application Verifier is attached. (Windows only) |
testasync |
tclTest.c |
Tests async handler facilities (Tcl_AsyncCreate, Tcl_AsyncMark, etc.). |
testbigdata |
tclTestObj.c |
Tests list/string operations near the Tcl_Size/INT_MAX boundary. (64-bit only) |
testbignumobj |
tclTestObj.c |
Tests the bignum (mp_int) Tcl object type. |
testbooleanobj |
tclTestObj.c |
Tests the boolean Tcl object type. |
testbumpinterpepoch |
tclTest.c |
Increments the compile epoch to force bytecode recompilation. |
testbytestring |
tclTest.c |
Creates a byte-array object from a string without encoding conversion. |
testchancreate |
tclTest.c |
Creates an in-memory test channel. |
testchannel |
tclTest.c |
Exercises the channel I/O management internals. |
testchannelevent |
tclTest.c |
Installs a Tcl script as a channel event handler. |
testcmdinfo |
tclTest.c |
Tests Tcl_GetCommandInfo and Tcl_SetCommandInfo. |
testcmdtrace |
tclTest.c |
Tests Tcl_CreateTrace / Tcl_DeleteTrace. |
testcmdtoken |
tclTest.c |
Tests Tcl_Command tokens and name-lookup functions. |
testconcatobj |
tclTest.c |
Tests Tcl_ConcatObj with a fixed set of objects. |
testcpuid |
tclTest.c |
Executes the CPUID instruction and returns register values. (x86/non-macOS only) |
testcreatecommand |
tclTest.c |
Tests namespace placement of commands created with Tcl_CreateCommand. |
testdcall |
tclTest.c |
Tests Tcl_CallWhenDeleted / Tcl_DontCallWhenDeleted. |
testdel |
tclTest.c |
Tests command deletion callbacks via a cross-interpreter command. |
testdelassocdata |
tclTest.c |
Calls Tcl_DeleteAssocData to remove an association from the interpreter. |
testdoubledigits |
tclTest.c |
Directly exercises the TclDoubleDigits floating-point digit extractor. |
testdoubleobj |
tclTestObj.c |
Tests the double-precision floating-point Tcl object type. |
testdstring |
tclTest.c |
Tests the Tcl_DString dynamic-string API. |
testencoding |
tclTest.c |
Tests the encoding system, including direct calls to conversion functions. |
testevalex |
tclTest.c |
Calls Tcl_EvalEx on a script, optionally in the global namespace. |
testevalobjv |
tclTest.c |
Calls Tcl_EvalObjv with a list of word objects. |
testevent |
tclTest.c |
Tests the event queue (Tcl_QueueEvent, Tcl_DeleteEvents). |
testexithandler |
tclTest.c |
Tests Tcl_CreateExitHandler / Tcl_DeleteExitHandler. |
testexitmainloop |
tclTest.c |
Signals the test main loop installed by testsetmainloop to exit. |
testexprdouble |
tclTest.c |
Calls Tcl_ExprDouble and appends the result without clearing the interpreter result. |
testexprdoubleobj |
tclTest.c |
Calls Tcl_ExprDoubleObj (object form) and appends the result. |
testexprlong |
tclTest.c |
Calls Tcl_ExprLong and appends the result without clearing the interpreter result. |
testexprlongobj |
tclTest.c |
Calls Tcl_ExprLongObj (object form) and appends the result. |
testexprparser |
tclTest.c |
Parses an expression with Tcl_ParseExpr and returns the parse tree. |
testexprstring |
tclTest.c |
Calls Tcl_ExprString on an expression. |
testfevent |
tclTest.c |
Tests file-event handling by associating a script with a channel event. |
testfile |
tclTest.c |
Tests miscellaneous VFS operations (stat, access, chdir, etc.). |
testfilelink |
tclTest.c |
Tests Tcl_FSLink for reading and creating filesystem links. |
testfilesystem |
tclTest.c |
Registers/unregisters a logging virtual filesystem. |
testfindfirst |
tclTest.c |
Tests Tcl_UtfFindFirst to locate a character in a string. |
testfindlast |
tclTest.c |
Tests Tcl_UtfFindLast to locate the last occurrence of a character. |
testfstildeexpand |
tclTest.c |
Tests tilde expansion in paths via Tcl_FSTildeExpand. |
testgetassocdata |
tclTest.c |
Calls Tcl_GetAssocData and returns the stored string. |
testgetindexfromobjstruct |
tclTest.c |
Directly calls Tcl_GetIndexFromObjStruct for strided table lookup. |
testgetint |
tclTest.c |
Tests Tcl_GetInt by converting a string to an integer. |
testgetintforindex |
tclTest.c |
Tests Tcl_GetIntForIndex for list-index expressions like end-2. |
testgetplatform |
tclTest.c |
Returns the current platform string from TclGetPlatform. |
testgetunichar |
tclTest.c |
Returns the Unicode code point at a byte position in a string. |
testgetvarfullname |
tclTest.c |
Returns the fully-qualified name of a variable. |
testhandlecount |
tclTest.c |
Returns the current Windows handle count for the process. (Windows only) |
testhashsystemhash |
tclTest.c |
Tests the system hash function by hashing a string a given number of times. |
testindexobj |
tclTestObj.c |
Tests Tcl_GetIndexFromObj and keyword-table lookup. |
testinterpdelete |
tclTest.c |
Directly deletes a child interpreter by path. |
testinterpresolver |
tclTest.c |
Tests custom variable/namespace resolvers. |
testintobj |
tclTestObj.c |
Tests the integer Tcl object type. |
testisempty |
tclTestObj.c |
Tests the TclIsEmpty fast-path for empty-string detection. |
testlink |
tclTest.c |
Tests Tcl_LinkVar / Tcl_UnlinkVar for all supported C types. |
testlinkarray |
tclTest.c |
Tests Tcl_LinkArray for typed C array linking. |
testlistapi |
tclTest.c |
Exercises list C API functions not easily reachable from script level. |
testlistrep |
tclTest.c |
Inspects and manipulates list internal representations. |
testlistobj |
tclTestObj.c |
Tests the list Tcl object type and associated C API. |
testlocale |
tclTest.c |
Tests setlocale for different locale categories. |
testlongsize |
tclTest.c |
Returns the size of the C long type on the current platform. |
testlutil |
tclTest.c |
Tests internal list utility functions. |
testmainthread |
tclTest.c |
Returns the Tcl thread ID of the main thread. |
testmsb |
tclTest.c |
Returns the position of the most significant set bit via TclMSB. |
testnrelevels |
tclTest.c |
Returns the current NRE and overall Tcl call stack depths. |
testnreunwind |
tclTest.c |
Tests NRE call-stack unwinding. |
testnumutfchars |
tclTest.c |
Returns the number of UTF-8 characters in a string using Tcl_NumUtfChars. |
testobj |
tclTestObj.c |
Tests generic Tcl object operations (ref counting, type conversion, etc.). |
testpanic |
tclTest.c |
Calls Tcl_Panic, causing immediate abnormal termination. |
testparseargs |
tclTest.c |
Tests Tcl_ParseArgsObjv with a fixed option table. |
testparser |
tclTest.c |
Calls Tcl_ParseCommand and returns the parse tree. |
testparsevar |
tclTest.c |
Tests Tcl_ParseVar on a variable reference string. |
testparsevarname |
tclTest.c |
Tests Tcl_ParseVarName directly. |
testpreferstable |
tclTest.c |
Returns whether the interpreter is configured for stable sorting. |
testprint |
tclTest.c |
Tests internal print/format utilities for floating-point values. |
testpurebytesobj |
tclTest.c |
Creates a "pure bytes" Tcl object with no internal type. |
testregexp |
tclTest.c |
Extended regexp variant that accepts internal low-level flags. |
testreturn |
tclTest.c |
Tests Tcl_Return by constructing a return object with given options. |
testservicemode |
tclTest.c |
Gets or sets the interpreter's event-service mode flag. |
testset2 |
tclTest.c |
Tests the two-part Tcl_SetVar2 interface (array name + element name). |
testsetassocdata |
tclTest.c |
Calls Tcl_SetAssocData to store a string under a key. |
testsetbytearraylength |
tclTest.c |
Sets the internal length of a byte-array object without reallocating. |
testseterr |
tclTest.c |
Calls Tcl_SetVar with TCL_LEAVE_ERR_MSG. |
testseterrorcode |
tclTest.c |
Tests Tcl_SetErrorCode by setting the error code to a list. |
testsetmainloop |
tclTest.c |
Installs a minimal C-level main loop via Tcl_SetMainLoop. |
testsetnoerr |
tclTest.c |
Calls Tcl_SetVar without TCL_LEAVE_ERR_MSG. |
testsetobjerrorcode |
tclTest.c |
Tests Tcl_SetObjErrorCode. |
testsetplatform |
tclTest.c |
Overrides the platform string returned by TclGetPlatform. |
testsimplefilesystem |
tclTest.c |
Registers/unregisters a minimal virtual filesystem. |
testsize |
tclTest.c |
Returns sizes of various Tcl internal types on the current platform. |
testsocket |
tclTest.c |
Tests low-level socket creation via Tcl_OpenTcpClient / Tcl_OpenTcpServer. |
teststaticlibrary |
tclTest.c |
Tests Tcl_StaticLibrary by registering and loading a dummy package. |
teststringbytes |
tclTest.c |
Returns the raw byte representation of a string. |
teststringobj |
tclTestObj.c |
Tests the string Tcl object type. |
testtranslatefilename |
tclTest.c |
Calls Tcl_TranslateFileName and returns the translated path. |
testuniclass |
tclTest.c |
Tests Tcl_UniCharIs* character-classification functions. |
testupvar |
tclTest.c |
Tests Tcl_UpVar to link a variable across call levels. |
testutfnext |
tclTest.c |
Returns the byte offset of the next UTF-8 character using TclUtfNext. |
testutfprev |
tclTest.c |
Returns the byte offset of the previous UTF-8 character using TclUtfPrev. |
testutftonormalized |
tclTest.c |
Converts a string to Unicode NFC normalization form. |
testutftonormalizeddstring |
tclTest.c |
Like testutftonormalized but returns the result via a Tcl_DString. |
testwrongnumargs |
tclTest.c |
Calls Tcl_WrongNumArgs and returns the resulting error message. |
Command Reference
gettimes
Defined in tclTest.c
Measures and reports the time taken by various low-level Tcl operations (object creation, string manipulation, list operations, etc.). Takes no arguments. Used for performance regression testing.
lstring
Defined in tclTestABSList.c
Syntax: lstring string ?typeVariant?
Creates and returns an lstring abstract-list object whose elements are the
individual characters of string. Supports all standard list operations
(llength, lindex, lrange, lreverse, lreplace, lset) through the
abstract-list dispatch table without materialising a conventional Tcl list.
An optional integer typeVariant (0–10) selects one of 11 internal
Tcl_ObjType V2 table configurations in which individual function pointers
(Length, Index, Slice, Reverse, GetElements, SetElement, Replace)
are progressively omitted, exercising the abstract-list fallback paths when
individual operations are not provided.
noop
Defined in tclTest.c
A no-operation command. Accepts any arguments and returns nothing. Used to measure command dispatch overhead and as a placeholder in tests.
tcl::procbodytest::check
Defined in tclTestProcBodyObj.c
Syntax: tcl::procbodytest::check
Verifies that Tcl_PkgPresent returns the same version string that was
registered when the tcl::procbodytest package was loaded. Returns a boolean
(1 if they match, 0 otherwise).
tcl::procbodytest::proc
Defined in tclTestProcBodyObj.c
Syntax: tcl::procbodytest::proc newName argList bodyName
Creates a new Tcl procedure newName with argument list argList, copying
the compiled body from the existing procedure bodyName as a procbody
object rather than recompiling a source string. Exercises the
Tcl_ProcObjCmd code path that accepts a pre-compiled procedure body.
proc a {x} { return $x }
a 42 ;# populate the compiled body
tcl::procbodytest::proc b {x} a
testapplylambda
Defined in tclTest.c
Syntax: testapplylambda lambda ?arg ...?
Tests Tcl_ApplyObjCmd directly by applying lambda to the supplied
arguments, exercising the apply implementation's C entry point.
testappverifierpresent
Defined in tclTest.c (Windows only)
Returns 1 if the Windows Application Verifier is attached to the current
process, 0 otherwise. Takes no arguments.
testasync
Defined in tclTest.c
Syntax: testasync option ?args?
Tests the asynchronous handler facilities (Tcl_AsyncCreate, Tcl_AsyncDelete, Tcl_AsyncMark).
| Subcommand | Description |
|---|---|
create script |
Creates an async handler that evaluates script when triggered; returns an integer handler ID. |
delete ?id? |
Deletes the handler with the given id, or all handlers if no id is given. |
mark id result code |
Marks handler id as ready, sets the interpreter result to result, and returns code. |
marklater id |
Marks the handler from a newly spawned thread after a short delay. |
testbigdata
Defined in tclTestObj.c (64-bit platforms only)
Tests list and string operations near the Tcl_Size / INT_MAX boundary by
constructing large objects. Available only when sizeof(Tcl_Size) == sizeof(Tcl_WideInt).
testbignumobj
Defined in tclTestObj.c
Syntax: testbignumobj subcommand varIndex ?value?
Tests the bignum (mp_int) Tcl object type using a pool of 20 shared object
variables (indexed 0–19).
| Subcommand | Description |
|---|---|
set varIndex value |
Parses value as a decimal bignum and stores it in variable varIndex. |
get varIndex |
Returns the bignum stored in varIndex. |
mult10 varIndex |
Multiplies the bignum in varIndex by 10 in place. |
div10 varIndex |
Divides the bignum in varIndex by 10 in place. |
iseven varIndex |
Replaces the bignum with a boolean indicating whether it is even. |
radixsize varIndex |
Replaces the bignum with the number of decimal digits required to represent it. |
testbooleanobj
Defined in tclTestObj.c
Syntax: testbooleanobj subcommand varIndex ?value?
Tests the boolean Tcl object type using the shared object variable pool.
| Subcommand | Description |
|---|---|
set varIndex bool |
Stores the boolean bool in variable varIndex. |
get varIndex |
Returns the boolean stored in varIndex. |
not varIndex |
Logically negates the boolean in varIndex. |
testbumpinterpepoch
Defined in tclTest.c
Increments the interpreter's compile epoch directly, forcing all cached bytecodes to be recompiled on their next execution. Takes no arguments.
testbytestring
Defined in tclTest.c
Syntax: testbytestring string
Creates a byte-array Tcl object from string without any encoding conversion. Used to test pure byte-array handling paths that bypass the string-encoding layer.
testchancreate
Defined in tclTest.c
Syntax: testchancreate mode name
Creates a test channel with the given mode (r, w, or rw) and name,
backed by an in-memory buffer. Used to test the channel-creation API
(Tcl_CreateChannel) without requiring real I/O.
testchannel
Defined in tclTest.c
Syntax: testchannel subcommand ?arg ...?
Exercises the channel I/O system. Subcommands include cut, splice, info,
isstandard, readable, writable, inputbuffered, outputbuffered,
mode, name, open, close, refcount, and maxinputbuffered. Used to
test channel management internals defined in tclIO.h.
testchannelevent
Defined in tclTest.c
Syntax: testchannelevent channel script ?flag?
Installs a Tcl script as a channel event handler and exercises
Tcl_CreateChannelHandler / Tcl_DeleteChannelHandler.
testcmdinfo
Defined in tclTest.c
Syntax: testcmdinfo option commandName
Tests Tcl_GetCommandInfo and Tcl_SetCommandInfo.
| Subcommand | Description |
|---|---|
create name |
Creates a test command named name with a known proc and delete proc. |
delete name |
Deletes the command and returns the deletion-callback string. |
get name |
Returns info about the command's proc, delete proc, namespace, and native-object proc status. |
modify name |
Replaces the command's implementation with a different proc/delete-proc pair. |
testcmdtrace
Defined in tclTest.c
Syntax: testcmdtrace option script
Tests Tcl_CreateTrace / Tcl_DeleteTrace.
| Subcommand | Description |
|---|---|
tracetest script |
Installs a trace, evals script, and returns the accumulated trace log. |
deletetest script |
Installs a trace that removes itself on first invocation, then evals script. |
leveltest script |
Installs a trace limited to the current call depth plus 4 levels. |
resulttest script |
Installs an object-based trace that can return non-TCL_OK codes. |
doubletest script |
Installs two overlapping traces to test ordering. |
testcmdtoken
Defined in tclTest.c
Syntax: testcmdtoken option arg
Tests Tcl_Command tokens and related functions (Tcl_GetCommandName,
Tcl_GetCommandFullName).
| Subcommand | Description |
|---|---|
create name |
Creates a command and returns its integer token ID. |
name id |
Returns the short and fully-qualified name of the command identified by id. |
testconcatobj
Defined in tclTest.c
Tests Tcl_ConcatObj by concatenating a fixed set of test objects and
returning the result. Takes no arguments.
testcpuid
Defined in tclTest.c (x86 / non-macOS only)
Syntax: testcpuid index
Executes the CPUID instruction with leaf index and returns a list of four
integer register values {eax ebx ecx edx}. Used to test the TclWinCPUID
helper function.
testcreatecommand
Defined in tclTest.c
Syntax: testcreatecommand option
Tests that Tcl_CreateCommand places a new command in the correct namespace.
Also verifies that single colons in the middle or end of a command name are
not treated as namespace separators.
| Subcommand | Description |
|---|---|
create |
Creates the command test_ns_basic::createdcommand. |
delete |
Deletes test_ns_basic::createdcommand. |
create2 |
Creates the command value:at:. |
delete2 |
Deletes value:at:. |
testdcall
Defined in tclTest.c
Syntax: testdcall ?id ...?
Tests Tcl_CallWhenDeleted / Tcl_DontCallWhenDeleted. Creates a child
interpreter, registers delete callbacks for each positive id (and
de-registers for negative id), deletes the interpreter, and returns the list
of callbacks that fired in the order they were called.
testdel
Defined in tclTest.c
Syntax: testdel interp name delcmdname
Creates a command named name in the child interpreter interp that, when deleted, evaluates delcmdname in the parent interpreter. Used to test command deletion callbacks across interpreter boundaries.
testdelassocdata
Defined in tclTest.c
Syntax: testdelassocdata key
Calls Tcl_DeleteAssocData to remove the key-value association for key
from the current interpreter.
testdoubledigits
Defined in tclTest.c
Syntax: testdoubledigits fpval ndigits type ?shorten?
Directly exercises TclDoubleDigits, the low-level floating-point
digit-extraction primitive. type is one of shortest, e, or f. The
optional shorten flag enables the shortest-representation mode. Returns a
three-element list {digits decpt sign}.
testdoubleobj
Defined in tclTestObj.c
Syntax: testdoubleobj subcommand varIndex ?value?
Tests the double-precision floating-point Tcl object type using the shared object variable pool.
| Subcommand | Description |
|---|---|
set varIndex double |
Stores double in variable varIndex. |
get varIndex |
Returns the double stored in varIndex. |
mult10 varIndex |
Multiplies the double in varIndex by 10.0 in place. |
div10 varIndex |
Divides the double in varIndex by 10.0 in place. |
testdstring
Defined in tclTest.c
Syntax: testdstring option ?args?
Tests the Tcl_DString dynamic-string API using a single global Tcl_DString.
| Subcommand | Description |
|---|---|
append string count |
Appends count bytes of string to the dynamic string. |
element string |
Appends string as a properly quoted list element. |
end |
Ends the current sublist. |
free |
Frees and re-initialises the dynamic string. |
get |
Returns the current dynamic string value. |
gresult type |
Sets the interpreter result to one of staticsmall, staticlarge, free, or special, then retrieves it into the dynamic string via Tcl_DStringGetResult. |
length |
Returns the current length of the dynamic string in bytes. |
result |
Moves the dynamic string value to the interpreter result. |
toobj |
Converts the dynamic string to a Tcl object via Tcl_DStringToObj. |
trunc length |
Truncates the dynamic string to length bytes. |
start |
Starts a new sublist. |
testencoding
Defined in tclTest.c
Syntax: testencoding option ?args?
Tests the encoding subsystem.
| Subcommand | Description |
|---|---|
create name toutfcmd fromutfcmd |
Registers a new encoding that delegates conversion to Tcl scripts. |
delete name |
Frees a previously registered test encoding. |
nullength ?encoding? |
Returns the NUL-terminator byte size for the given encoding. |
Tcl_ExternalToUtf encoding src flags state dstlen ... |
Directly calls Tcl_ExternalToUtf. |
Tcl_UtfToExternal encoding src flags state dstlen ... |
Directly calls Tcl_UtfToExternal. |
Tcl_ExternalToUtfEx ... |
Calls the extended Tcl_ExternalToUtfEx variant. |
Tcl_UtfToExternalEx ... |
Calls the extended Tcl_UtfToExternalEx variant. |
Tcl_GetEncodingNameFromEnvironment |
Returns the encoding name obtained from the environment. |
Tcl_GetEncodingNameForUser |
Returns the user-preferred encoding name. |
testevalex
Defined in tclTest.c
Syntax: testevalex script ?global?
Calls Tcl_EvalEx on script. If the optional argument global is supplied,
evaluates in the global namespace (TCL_EVAL_GLOBAL).
testevalobjv
Defined in tclTest.c
Syntax: testevalobjv global word ?word ...?
Calls Tcl_EvalObjv with the given words. If global is true (1), evaluates
in the global namespace.
testevent
Defined in tclTest.c
Syntax: testevent subcommand ?args?
Tests the event queue management functions Tcl_QueueEvent and
Tcl_DeleteEvents.
| Subcommand | Description |
|---|---|
queue name position script |
Queues an event tagged name at position (head, tail, or mark) that evaluates script when processed. |
delete name |
Removes all queued events tagged name from the event queue. |
testexithandler
Defined in tclTest.c
Syntax: testexithandler create|delete value
Tests Tcl_CreateExitHandler / Tcl_DeleteExitHandler. Creates or deletes an
exit handler identified by the integer value. Odd values use one callback
function; even values use another.
testexitmainloop
Defined in tclTest.c
Sets the flag that causes the test main loop installed by testsetmainloop to
exit. Takes no arguments.
testexprdouble
Defined in tclTest.c
Syntax: testexprdouble expression
Calls Tcl_ExprDouble on expression and appends the floating-point result
to the current interpreter result, verifying that a successful evaluation does
not clear the existing result.
testexprdoubleobj
Defined in tclTest.c
Syntax: testexprdoubleobj expression
Calls Tcl_ExprDoubleObj on expression passed as a Tcl object, and appends
the result to the current interpreter result.
testexprlong
Defined in tclTest.c
Syntax: testexprlong expression
Calls Tcl_ExprLong on expression and appends the integer result to the
current interpreter result, verifying that a successful evaluation does not
clear the existing result.
testexprlongobj
Defined in tclTest.c
Syntax: testexprlongobj expression
Calls Tcl_ExprLongObj on expression passed as a Tcl object, and appends
the result to the current interpreter result.
testexprparser
Defined in tclTest.c
Syntax: testexprparser expr length
Parses expr as a Tcl expression using Tcl_ParseExpr (treating length
bytes, or the full string if length is 0) and returns a structured
description of the resulting parse tree.
testexprstring
Defined in tclTest.c
Syntax: testexprstring expression
Calls Tcl_ExprString on expression and returns the result.
testfevent
Defined in tclTest.c
Syntax: testfevent channel script
Tests file-event handling by associating a Tcl script with a channel's readable or writable event.
testfile
Defined in tclTest.c
Syntax: testfile option ?args?
Tests miscellaneous filesystem operations (stat, access, chdir,
getcwd) through the VFS layer.
testfilelink
Defined in tclTest.c
Syntax: testfilelink source ?target?
Tests Tcl_FSLink. With one argument, reads the target of a symbolic link.
With two arguments, creates a link from source to target
(tries both symbolic and hard link types).
testfilesystem
Defined in tclTest.c
Syntax: testfilesystem mount|unmount
Registers or unregisters a "reporting" virtual filesystem that logs every
filesystem operation it intercepts. Used to test Tcl_FSRegister /
Tcl_FSUnregister and to verify that VFS callbacks are invoked correctly.
testfindfirst
Defined in tclTest.c
Syntax: testfindfirst string char
Tests Tcl_UtfFindFirst by searching string for the first occurrence of the
Unicode character char and returning the byte offset.
testfindlast
Defined in tclTest.c
Syntax: testfindlast string char
Tests Tcl_UtfFindLast by searching string for the last occurrence of the
Unicode character char and returning the byte offset.
testfstildeexpand
Defined in tclTest.c
Syntax: testfstildeexpand path
Tests tilde expansion in paths using Tcl_FSTildeExpand and returns the
expanded path.
testgetassocdata
Defined in tclTest.c
Syntax: testgetassocdata key
Calls Tcl_GetAssocData and returns the string stored under key in the
current interpreter's association table.
testgetindexfromobjstruct
Defined in tclTest.c
Syntax: testgetindexfromobjstruct objPtr tablePtr offset
Directly calls Tcl_GetIndexFromObjStruct to look up objPtr in a table
whose entries are offset bytes apart. Used to test strided keyword-table
lookup.
testgetint
Defined in tclTest.c
Syntax: testgetint string
Tests Tcl_GetInt by converting string to an integer and returning it.
testgetintforindex
Defined in tclTest.c
Syntax: testgetintforindex string end
Tests Tcl_GetIntForIndex by converting the list-index expression string
(which may use forms like end, end-2, or 3) into an absolute integer
relative to the list length end.
testgetplatform
Defined in tclTest.c
Returns the current platform string (unix, mac, or windows) as reported
by the internal TclGetPlatform function. Takes no arguments.
testgetunichar
Defined in tclTest.c
Syntax: testgetunichar string index
Returns the Unicode code point at byte position index in string using the internal UTF navigation functions.
testgetvarfullname
Defined in tclTest.c
Syntax: testgetvarfullname varname namespace
Returns the fully-qualified name of a variable, exercising
Tcl_FindNamespaceVar and Tcl_GetVariableFullName.
testhandlecount
Defined in tclTest.c (Windows only)
Returns the current Windows handle count for the process, used to detect handle leaks in tests. Takes no arguments.
testhashsystemhash
Defined in tclTest.c
Syntax: testhashsystemhash string count
Tests the system hash function by hashing string the given number of times and returning the final hash value.
testindexobj
Defined in tclTestObj.c
Syntax: testindexobj subcommand ?args?
Tests Tcl_GetIndexFromObj and related keyword-table lookup functions,
including the cached vs. non-cached code paths and error reporting.
| Subcommand | Description |
|---|---|
set varIndex tableIndex |
Looks up a keyword by index and stores the result. |
get varIndex |
Returns the keyword object stored in varIndex. |
get2 varIndex |
Exercises an alternative lookup path. |
formatwithmax ... |
Tests keyword lookup with a maximum-length bound. |
nosuchindex |
Tests error reporting when an index is out of range. |
testinterpdelete
Defined in tclTest.c
Syntax: testinterpdelete path
Looks up the child interpreter at path relative to the current interpreter
and deletes it directly using Tcl_DeleteInterp. Used to test interpreter
deletion callbacks.
testinterpresolver
Defined in tclTest.c
Syntax: testinterpresolver option
Tests custom variable and namespace resolvers installed via
Tcl_AddInterpResolvers. Subcommands: install, remove, query.
testintobj
Defined in tclTestObj.c
Syntax: testintobj subcommand varIndex ?value?
Tests the integer and wide-integer Tcl object types using the shared object
variable pool. Subcommands: set, get, mult10, div10, set2
(uses Tcl_SetIntObj instead of Tcl_NewIntObj), testseterror.
testisempty
Defined in tclTestObj.c
Syntax: testisempty obj
Returns 1 if obj is the empty string using the internal TclIsEmpty
fast-path check, 0 otherwise.
testlink
Defined in tclTest.c
Syntax: testlink option ?args?
Tests Tcl_LinkVar, Tcl_UnlinkVar, and Tcl_UpdateLinkedVar for all
supported C types: int, double, bool, string, wide, char, uchar,
short, ushort, uint, long, ulong, float, and uwide.
| Subcommand | Description |
|---|---|
create boolFlags... |
Links each of the 14 typed C variables to a Tcl variable, using per-type boolean flags to set read-only status. |
delete |
Unlinks all previously linked variables. |
get |
Returns the current C-side values of all linked variables as a list. |
set values... |
Sets the C-side values directly, bypassing any Tcl write trace. |
update values... |
Sets the C-side values and calls Tcl_UpdateLinkedVar to propagate them to Tcl. |
testlinkarray
Defined in tclTest.c
Syntax: testlinkarray option ?args?
Tests Tcl_LinkArray for array-linking of typed C data.
| Subcommand | Description |
|---|---|
create ?-readonly? type size name ?address? |
Links a Tcl variable to a C array of size elements of the given type. |
remove name ?name ...? |
Unlinks the named array variables. |
update name ?name ...? |
Pushes C-side array values back to their linked Tcl variables. |
testlistapi
Defined in tclTest.c
Syntax: testlistapi subcommand refcount list ?args?
Exercises list C API functions not easily reached from script level, including
Tcl_ListObjRange, Tcl_ListObjReverse, and Tcl_ListObjRepeat. The
refcount argument controls how many extra references are held on the input
list to test shared-object handling. Returns a dictionary of input/output
object addresses, reference counts, type names, and results.
testlistrep
Defined in tclTest.c
Syntax: testlistrep subcommand ?args?
Inspects and manipulates list internal representations directly.
| Subcommand | Description |
|---|---|
new length ?leadSpace endSpace? |
Creates a list object with a specific store layout including optional leading and trailing spare slots. |
describe object |
Returns a structured description of the list's store and optional span pointers, including memory addresses and field values. |
config |
Returns compile-time list configuration constants such as LIST_SPAN_THRESHOLD. |
validate object |
Panics if the list's internal representation is inconsistent; returns empty string on success. |
testlistobj
Defined in tclTestObj.c
Syntax: testlistobj subcommand varIndex ?args?
Tests the list Tcl object type and the associated C API
(Tcl_NewListObj, Tcl_ListObjAppendElement, Tcl_ListObjReplace,
Tcl_ListObjGetElements, etc.) using the shared object variable pool.
Subcommands: set, get, get2, replace, indexobj, setobj.
testlocale
Defined in tclTest.c
Syntax: testlocale category ?locale?
Tests setlocale by setting or querying the C locale for the given category
(ctype, numeric, time, collate, monetary, all). Returns the
current locale string.
testlongsize
Defined in tclTest.c
Returns the size in bytes of the C long type on the current platform. Takes
no arguments.
testlutil
Defined in tclTest.c
Syntax: testlutil subcommand ?args?
Tests internal list utility functions used in the implementation of commands
such as lmap and lassign.
testmainthread
Defined in tclTest.c
Returns the Tcl thread ID of the main thread as recorded at initialization
time by Tcl_GetCurrentThread. Takes no arguments.
testmsb
Defined in tclTest.c
Syntax: testmsb integer
Returns the zero-based position of the most significant set bit in the positive
integer, exercising the internal TclMSB utility macro/function.
testnrelevels
Defined in tclTest.c
Returns a description of the current NRE (non-recursive evaluation) call stack depth and the overall Tcl call depth, used to verify that NRE level accounting is correct. Takes no arguments.
testnreunwind
Defined in tclTest.c
Tests NRE call-stack unwinding by scheduling a post-processing callback via
Tcl_NRAddCallback that verifies the NRE stack is correctly cleaned up after
evaluation. Takes no arguments.
testnumutfchars
Defined in tclTest.c
Syntax: testnumutfchars string ?length?
Returns the number of UTF-8 characters in string up to length bytes
(or the full string if length is omitted) using Tcl_NumUtfChars.
testobj
Defined in tclTestObj.c
Syntax: testobj subcommand ?args?
Tests generic Tcl object operations using the shared variable pool. Subcommands:
assign, convert, copy, decrefcount, deleteobj, freeallvars,
increfcount, ispresent, newobj, objtype, refcount, setintobj,
setvar.
testpanic
Defined in tclTest.c
Syntax: testpanic message
Calls Tcl_Panic with message, causing an immediate abnormal termination.
Used to test panic handling and to verify that a custom panic handler is invoked.
testparseargs
Defined in tclTest.c
Syntax: testparseargs ?options?
Tests Tcl_ParseArgsObjv with a fixed option table, verifying correct option
parsing, default-value assignment, and error reporting for unrecognised options.
testparser
Defined in tclTest.c
Syntax: testparser script length
Calls Tcl_ParseCommand on script (treating length bytes, or the full
string if length is 0) and returns a structured description of the resulting
parse tree, including token types, positions, and word counts.
testparsevar
Defined in tclTest.c
Syntax: testparsevar string
Tests Tcl_ParseVar by parsing string as a Tcl variable reference and
returning the parsed structure.
testparsevarname
Defined in tclTest.c
Syntax: testparsevarname string length simple
Tests Tcl_ParseVarName directly, returning parse-tree information for the
variable name found in string.
testpreferstable
Defined in tclTest.c
Returns 1 if the interpreter is currently configured to prefer stable
(order-preserving) sorting, 0 otherwise. Takes no arguments.
testprint
Defined in tclTest.c
Syntax: testprint format value
Tests internal print and format utility functions by formatting the floating-point value with the given format string and returning the result.
testpurebytesobj
Defined in tclTest.c
Creates a "pure bytes" Tcl object — an object with only a string representation and no internal type pointer — used to test code paths that check for the absence of an internal type. Takes no arguments.
testregexp
Defined in tclTest.c
Syntax: testregexp ?flags? pattern string
An extended variant of regexp that accepts additional internal flags (prefixed
with --) to exercise low-level regular-expression code paths not reachable
through the standard regexp command.
testreturn
Defined in tclTest.c
Syntax: testreturn ?option value ...?
Tests Tcl_Return by constructing and returning a return object with the
specified options (-code, -errorinfo, -errorcode, -level, etc.).
testservicemode
Defined in tclTest.c
Syntax: testservicemode ?mode?
Gets or sets the interpreter's event-service mode flag, which controls whether
Tcl_ServiceAll processes events. Used to test event-loop behaviour.
testset2
Defined in tclTest.c
Syntax: testset2 varname ?value?
Tests the two-part Tcl_SetVar2 interface by splitting varname into an array
name and an element name.
testsetassocdata
Defined in tclTest.c
Syntax: testsetassocdata key value
Stores value (as a string) under key in the current interpreter's
association table using Tcl_SetAssocData.
testsetbytearraylength
Defined in tclTest.c
Syntax: testsetbytearraylength obj length
Sets the internal length of the byte-array object obj to length without changing its allocated storage, used to test byte-array edge cases.
testseterr
Defined in tclTest.c
Syntax: testseterr varname ?value?
Calls Tcl_SetVar with the TCL_LEAVE_ERR_MSG flag, so errors are reported
in the interpreter result.
testseterrorcode
Defined in tclTest.c
Syntax: testseterrorcode ?element ...?
Tests Tcl_SetErrorCode by setting the interpreter's error code to the list
formed from the supplied element arguments.
testsetmainloop
Defined in tclTest.c
Installs a minimal C-level main loop via Tcl_SetMainLoop that runs until
testexitmainloop is called. Takes no arguments.
testsetnoerr
Defined in tclTest.c
Syntax: testsetnoerr varname ?value?
Calls Tcl_SetVar without TCL_LEAVE_ERR_MSG, so errors are silently
ignored. Returns the variable value.
testsetobjerrorcode
Defined in tclTest.c
Syntax: testsetobjerrorcode obj
Tests Tcl_SetObjErrorCode by setting the interpreter's error code to the
given Tcl object.
testsetplatform
Defined in tclTest.c
Syntax: testsetplatform platform
Overrides the platform string returned by TclGetPlatform to platform
(unix, mac, or windows), used to exercise platform-specific code paths
on any host operating system.
testsimplefilesystem
Defined in tclTest.c
Syntax: testsimplefilesystem mount|unmount
Registers or unregisters a minimal "simple" virtual filesystem that implements only the most basic operations. Used to test the abstract filesystem layer with a reduced-functionality implementation.
testsize
Defined in tclTest.c
Returns a dictionary containing the sizes (in bytes) of various Tcl internal
types (Tcl_Obj, Tcl_Interp, etc.) on the current platform. Takes no
arguments.
testsocket
Defined in tclTest.c
Syntax: testsocket ?options?
Tests low-level socket creation via Tcl_OpenTcpClient and
Tcl_OpenTcpServer, verifying socket option flags and error paths.
teststaticlibrary
Defined in tclTest.c
Tests Tcl_StaticLibrary (formerly Tcl_StaticPackage) by registering a
dummy static package and then loading it into the interpreter. Takes no
arguments.
teststringbytes
Defined in tclTest.c
Syntax: teststringbytes string
Returns the raw byte representation of string without performing any Unicode processing. Used to inspect low-level string storage.
teststringobj
Defined in tclTestObj.c
Syntax: teststringobj subcommand varIndex ?args?
Tests the string Tcl object type using the shared variable pool. Subcommands:
set, set2 (via Tcl_SetStringObj), get, append, appendstrings,
getlength, getunicode, appendself, appendself2.
testtranslatefilename
Defined in tclTest.c
Syntax: testtranslatefilename name
Calls Tcl_TranslateFileName on name and returns the translated path.
testuniclass
Defined in tclTest.c
Syntax: testuniclass char class
Tests Tcl_UniCharIs* character-classification functions. Returns 1 if the
Unicode character char belongs to class (e.g., alpha, digit, space,
upper, lower), 0 otherwise.
testupvar
Defined in tclTest.c
Syntax: testupvar level srcVar destVar
Tests Tcl_UpVar by linking the variable destVar in the current scope to
srcVar at call level level.
testutfnext
Defined in tclTest.c
Syntax: testutfnext string
Returns the byte offset of the start of the next UTF-8 character after position
0 in string, using the internal TclUtfNext function.
testutfprev
Defined in tclTest.c
Syntax: testutfprev string ?index?
Returns the byte offset of the start of the UTF-8 character immediately before
index (or before the end of string if index is omitted), using TclUtfPrev.
testutftonormalized
Defined in tclTest.c
Syntax: testutftonormalized string
Converts string to Unicode NFC (Canonical Decomposition followed by Canonical Composition) normalization form using the internal UTF normalization routines and returns the result.
testutftonormalizeddstring
Defined in tclTest.c
Syntax: testutftonormalizeddstring string
Like testutftonormalized but accumulates the result via a Tcl_DString
rather than directly constructing a Tcl object.
testwrongnumargs
Defined in tclTest.c
Syntax: testwrongnumargs level message ?arg ...?
Calls Tcl_WrongNumArgs with the supplied arguments and returns the resulting
error message. Used to test the wrong-argument-count error reporting API.
All commands in this document are for testing purposes only and are not part of the public Tcl API.