aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2025-07-16core: Jim_SetVariable() now frees value on errorSteve Bennett1-0/+9
If the value has a zero reference count, free it in the error path. Otherwise callers can't do: Jim_SetVariable(..., Jim_New...()) in case the object is leaked in the error path. Fix various callers that were previously freeing the object in the error path, and add a test to loop.test to show that this was not. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16regexp: Handle non repeat count {...}Steve Bennett1-4/+16
If it does not contain a number, treat it as an exact match. Fixes #323 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16Update tests for new vwait with scriptSteve Bennett1-4/+23
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16regexp: assign match vars with -allSteve Bennett1-0/+5
To match the documentation and Tcl, if match vars are given with -all, the last match is assigned. Fixes #310 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16regexp, regsub: add support for -expandedSteve Bennett2-14/+18
Fixes #311 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16expr: add support for =* and =~Steve Bennett2-0/+28
glob match and regexp match operators Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16add lsubst commandSteve Bennett1-0/+139
Halfway between list and subst, makes it easy to construct lists with substitutions (as opposed to strings with substitutions) Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16info: procs, commands, don't returns commands with spacesSteve Bennett1-2/+2
We implement ensembles by creating commands with spaces, like {tree children}. This can clutter the commands returned by 'info procs', 'info commands'. So don't return these by default. Add the '-all' option return all commands. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16core: Add Jim_RegisterCommand()Steve Bennett8-23/+30
and wrappers Jim_RegisterCmd, Jim_RegisterSimpleCmd and Jim_RegisterSubCmd Allows usage, help and flags when registering commands. Allows for JIM_CMD_ISPROC, JIM_CMD_ISALIAS, JIM_CMD_ISCHANNEL 'info usage' and (later) 'info help' Now every command doesn't need to check min/max and print usage. This also adds support for 'info aliases', 'info channels' and 'exists -channel'. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16core: set -errorcode to TAINTED on taint errorSteve Bennett1-0/+8
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16core: taint supportSteve Bennett4-2/+219
See README.taint Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16tests: add tests for TIP424 exec syntaxSteve Bennett1-0/+424
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16exec: Implement TIP424 - new exec syntaxSteve Bennett1-1/+2
exec | {cmdlist ...} ?redir? ... This is a safer form of exec in that redirection meta characters are no longer searched in cmdlist Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-07-16exec: rework in prep for TIP 424Steve Bennett1-0/+4
Split out JimExecPipeline() in such a way that it will be possible to reuse this for TIP424 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-04-22try: Fix bug with `errorCode` being shorter than `match`Mason Jones1-1/+8
Currently jimtcl compares each element of `errorCode` against each `match` element. But, it doesn't account for the situation where `errorCode` is shorter than `match`. In this case the match should always fail (rather than segfaulting).
2025-04-22Fix abort on boolean negation/plus unary operatorsMason Jones1-0/+7
Currently jimtcl will abort if there is any unary operator besides ! in front of a boolean. It is possible to construct an expression with - or + before a boolean literal (e.g. expr {-true}) that currently aborts, but should return an error. I implemented this error handling with tcl's error message for this situation.
2025-02-07aio: add support for translation binary|textSteve Bennett1-0/+26
Mainly to support changing stdout,stderr to binary mode on Windows. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2025-01-10jimsh.test: update for new behaviourSteve Bennett1-21/+9
When stdin is not a tty Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-11-05add support for 'package forget'Steve Bennett2-0/+15
Sometimes useful if replacing a package that has already been loaded Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-09-20event.test: don't rely on 'stdin readable'Steve Bennett1-2/+2
Use after instead because otherwise the alarm in the readable script which confuses things later. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-09-20event.test: Fix spurious stderr outputSteve Bennett1-6/+13
Expect output to stderr when an error happens inside bgerror, so catch it. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-09-20shorten the name of breakcontinue.testSteve Bennett1-0/+0
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-08-28json::decode preserve line numbers if possibleSteve Bennett1-2/+14
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-08-28json::decode: run parser in strict modeSteve Bennett1-5/+5
To avoid invalid JSON causing core dumps. Minor changes to the jsmn parser to still allow Infinity and NaN. Fix some tests that didn't use strictly correct JSON. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-08-28lsort tests: some tests require utf-8 supportSteve Bennett1-2/+2
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-08-28lsort: add support for -dictSteve Bennett1-1/+128
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-02-15subst: don't ignore vars after first failed varSteve Bennett1-0/+5
If $ is followed by something that isn't a variable name, previously all subsequent variables were being ignored. Fixes #296 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-02-04aio: tty: Add support for vstart and vstopSteve Bennett1-1/+1
xonxoff start and stop chars Signed-off-by: Steve Bennett <steveb@workware.net.au>
2024-01-29regexp: implement regsub -commandSteve Bennett1-2/+41
Per Tcl 8.7 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-11-02tests: timer: skip unreliable testsSteve Bennett1-15/+34
On systems where we aren't getting enough cpu time. Heuristic check, but probably good enough in practice. Fixes #282 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-08-13jimsh, interp, tests: fixes when line editing is disabledSteve Bennett2-6/+8
- Set jim::lineedit to indicate if line editing is configured - Ensure that aio tty works even if line editing is disabled - Skip some tests if line editing is not configured Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-08-13tests: misc: improve 'info statics' testSteve Bennett1-3/+5
To show that it returns the current values, not just the original values Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-08-12tests: socket: hurd vs LinuxSteve Bennett1-2/+13
hurd does not return the path for unix domain sockets via getsockname() Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-08-12tests: support hurdSteve Bennett2-4/+4
socket operation on non-socket gives a different message Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-10tests: event.test: increase waits in event-11.4Steve Bennett1-3/+3
This test can be at bit flaky on slower machines (perhaps running under a VM or qemu). Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-10info script: return real current source fileSteve Bennett1-0/+10
And allow current source file to be set Fixes: #268 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-05tests: Fix/add some constraint checksSteve Bennett2-1/+3
In case socket pty, interp are not available Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-04core: add support for proc statics by referenceSteve Bennett1-0/+168
set a 5 proc b {} {&a} { incr a } b Now a is 6 because b captured a by reference instead of by value Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-04debug: convert to use subcmdSteve Bennett1-2/+2
This means we get -commands and usage via -help Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-04dict: convert to use subcmdSteve Bennett1-1/+1
This means we get -commands and usage via -help And update dict2.test for minor difference in usage Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-04interactive: enable hint supportSteve Bennett1-2/+10
And add a default implementation of tcl::stdhint to add hinting for some built-in commands. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-04tests: add aio.test for open -nocloseSteve Bennett1-2/+19
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-04tests: tty.test: use a pty pair if stdin/stdout is not a ttySteve Bennett1-12/+25
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-04tests: expect.tcl: leave the channel in non-blocking modeSteve Bennett1-2/+1
This is simpler now that we can write to a non-blocking socket even if it is "full". Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-04tcltest: rework constraint systemSteve Bennett34-137/+92
Now 'constraint cmd|package' is like 'needs' but sets a constraint The command to 'needs cmd' and 'constraint cmd' can now take a subcommand to check. Add 'constraint|needs eval|expr' to make some constraint checks simpler. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-07-04aio: change to use unix io, not stdioSteve Bennett4-27/+251
This changes especially makes buffered I/O work with non-blocking channels. - separate read and write buffering - support for timeout on blocking read - read/write on same channel in event loop with buffering - read buffer is the same across read, gets, copyto - autoflush non-blocking writes via event loop - copyto can now copy to any filehandle-like command - add some copyto tests Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-06-21core: Display errors in a more "pythonesque" waySteve Bennett5-68/+77
A typical error message now looks like this: t4.tcl:2: Error: syntax error in expression: "blah" Traceback (most recent call last): File "t4.tcl", line 14 c 1 2 3 File "t4.tcl", line 10, in c b a c File "t4.tcl", line 6, in b a A14 File "t4.tcl", line 2, in a expr blah This is produced by stackdump (that can be replaced), called by errorInfo. Note that now stacktraces (stacktrace, info stacktrace, $opts(-errorinfo)) include the running command at each level in addition to proc, file, line. In order for scripts to detect this new format, a new entry tcl_platform entry has been added: tcl_platform(stackFormat) = 4 (to signify 4 elements per frame) In addition, instead of building the error stack frame as the stack is unwound in response to an error, instead the entire current stack trace is captured by stacktrace. This means that the trace extends beyond the try/catch right back to the initial interpreter command. The 'stacktrace' command is now implemented in C based on the same code that generates the error stacktrace. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-05-25tests: for multi-level break, continueSteve Bennett1-0/+127
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-05-25core: support multi-level while, break from loopsSteve Bennett1-7/+15
loop i 5 { loop j 6 { # This breaks out of both loops break 2 } } Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-05-06jim: info frame improvementsSteve Bennett1-14/+17
always include 'proc' even if introspection disabled correctly set 'proc' at the eval frame level that is currently running in the given proc. This makes it easier to produce an accurate level stacktrace even across uplevel, etc. Update stacktrace to use the new info frame. Signed-off-by: Steve Bennett <steveb@workware.net.au>