aboutsummaryrefslogtreecommitdiff
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
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>
2023-04-19regexp: fix incorrect check for invalid escape sequence at end of charsetSteve Bennett1-0/+4
Fixes #259 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-04-19regexp: fix check for termination in [[:class:]]Steve Bennett1-0/+4
Fixes #259 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-02-24dict with: return script resultSteve Bennett2-2/+19
Previously dict with returned the new dict value. Also fix an issue in the case where a dict element mirrors the name of the dictionary. Fixes: #241 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-02-13ensemble: Add a simple ensemble commandSteve Bennett2-0/+122
Uses a prefix to automatically map from subcommand to implementation. Includes support for namespace ensemble Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-02-13vwait: add support for vwait -signalSteve Bennett1-6/+6
To break vwait if a handled signal is received. In this case, the handled signal(s) can be returned by signal check ?-clear? Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-02-13Tcl-compatible 'info frame'Steve Bennett2-13/+17
Returns a dictionary with file, line, cmd, (possibly) proc and level. And support 'info frame 0' for the current command. Note that now all evaluation frames are captured, not just call frames. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-02-06tests: exec2: may need to set default SIGPIPE dispositionSteve Bennett1-1/+1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2023-02-06tests: Don't run exec2 in a child interpreterSteve Bennett2-3/+4
Since signals aren't supported there and we need signals for some of these tests. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-12-26tests: add garbage collection testsSteve Bennett1-0/+80
These tests provoke the issues raised in #245 plus some additional issues. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-12-03regexp: fix end of word checkSteve Bennett1-0/+4
The end of word check was wrong and return true when it should not. Fixes #246 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-08-29tests: lock.test: child lock test should be more reliableSteve Bennett1-1/+1
Some systems need a little extra time for the child process to start and acquire the lock. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-08-21tree: node ids are now simple integersSteve Bennett1-1/+1
Dictionary lookups with simple integers are more efficient than with "node<integer>" Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-08-21tests: Fix file.test on WindowsSteve Bennett1-1/+1
file executable doesn't do anything useful on Windows Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-08-21tests: file.test - increase code coverageSteve Bennett1-0/+50
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-07-31tests: Fix SIGPIPE testsSteve Bennett1-9/+3
These tests were only working accidentally (typo >$@w). In fact since open |... already provides a pipe on output there is no need to create one manually, so the first test can run under Tcl too. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-07-25unset: don't return a result with -nocomplainSteve Bennett1-0/+6
unset -nocomplain abc(missing) was still returning an error message, but as a normal return. It should return an empty result. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-05-08tests: add tests for wait -1Steve Bennett2-0/+11
Only on unix systems, wait for any child process This was broken with a recent commit, so add an explicit test Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-04-14aio: TIP 603 - Implement stat of an open file handleSteve Bennett1-0/+18
Although the interface is different ('$handle stat' vs 'chan configure -stat') the behaviour is the same. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-04-14win32: Fix process handle vs pid distinctionSteve Bennett1-1/+1
On win32, a process is identified by a HANDLE, but for identifying a running process we should use GetProcessId() to return a meaningful integer. This means we need to be able to back and forth between a pid and a process handle (phandle). We also need to be careful to get the pid before the process handle closes since it isn't available afterwards. Also call the handle to intptr_t for open_osfhandle() to avoid a compiler warning. Fixes #217 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-04-14try: add support for trapSteve Bennett1-0/+44
In addition to "on codes ..." it is now possible to trap on errorcode with "trap sublist ..." e.g. try { ... } trap CHILDSTATUS {msg opts} { ... } Fixes #204 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-04-12getref, setref: No need to allow for leading, trailing spaceSteve Bennett1-2/+1
There is no reason to allow a reference to contain leading and/or trailing white space, so remove this check and simply treat it as an invalid reference. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-04-11getref, setref: reference may be qualifiedSteve Bennett1-0/+19
oo.tcl returns globally qualified names like ::<reference.<tree___>.00000000000000000000> So allow getref and setref to handle these qualified references Fixes #218 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2022-02-23tests: Fix load.test when jimsh not yet installedSteve Bennett1-19/+17
Needs include, lib paths when jim is not installed Fixes: #216 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-12-13dict: Fix possible duplicate entries when settingSteve Bennett1-0/+13
Due to the way hash collisions are managed it is possible to have a sequence where an entry is removed and then another entry is replaced, however the replacement adds an additional entry instead of updating the existing entry. Can be reproduced like this as there is a hash collision between these two keys: dict set d 0,13 X dict set d 8,4 Y dict unset d 0,13 dict set d 8,4 Z Should result in one entry in the dictionary, but instead ends with two. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-07-09tests: move garabage collection test to ref.testSteve Bennett2-17/+24
bootstrap jimsh doesn't have garbage collection, so move such tests into ref.test Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-07-08collect: correctly handle references as globally scoped namesSteve Bennett1-0/+17
When a reference is used as a command name (e.g. in oo.tcl) it is created in the global namespace as ::<reference... The current check for references that are commands with a reference count of 1 doesn't take this into account so these references were not being garbage collected. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-04-09build: Allow some paths to contain spacesSteve Bennett3-6/+4
Quote the build dir or and the path to jimsh/tclsh in the Makefile in case they contain spaces. Also fix a few problems in tests/ that arise when the build and/or source dir contain spaces. Fixes #199 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-03-10tests: Fix debug.test for single arg exprSteve Bennett1-1/+1
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-03-09expr: TIP 526, only support a single argSteve Bennett6-25/+25
Avoid unexpected issues by concatenating multiple arguments. This does create an incompatibility with early versions, but it is generally trivial to convert existing code to one of two forms: 1. expr {$a + $b} -- usually correct 2. expr "$a + $b" -- usually incorrect Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-02-27aio: tests: bootstrap jimsh doesn't have posix open flagsSteve Bennett1-5/+5
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-02-27tests: Fix return code from tests/runall.tclSteve Bennett1-2/+2
In the case where interp is not supported Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-02-27aio: open: support for POSIX open flagsSteve Bennett1-0/+30
Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-01-30lsearch, lsort: support for -stride and -indexSteve Bennett2-10/+151
Add -stride support to both lsearch and lsort Add -index support to lsearch Improve -index for lsort to support multiple indices Also harmonise some error messages with Tcl 8.7 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-01-23history: Add support for history keepSteve Bennett1-1/+1
Fixes #191 Signed-off-by: Steve Bennett <steveb@workware.net.au> Reported-by: D. Bohdan <dbohdan@dbohdan.com>
2021-01-09Add the [xtrace] commandSteve Bennett1-0/+62
Allows a debugger or tracing facility to be implemented Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-01-03bootstrap jimsh: pass all testsSteve Bennett7-72/+103
In order to test bootstrap jimsh, it is very helpful if it can pass all the unit tests. - Set tcl_platform(bootstrap) to 1 for bootstrap jimsh or 0 otherwise - Use getref to determine in we have references, not ref since we implement a poor-man's ref for bootstrap jimsh - bootstrap jimsh package doesn't return a "Can't load package" message if loading the package fails - exec tests using [open |command] need pipe - bootstrap jimsh can't set file times with [file mtime] Signed-off-by: Steve Bennett <steveb@workware.net.au>
2021-01-03core: fix parsing of booleansSteve Bennett1-0/+5
When boolean parsing was combined in commit 982ec4f524bc81a240cb729cf09bd3c677aea485 it broken parsing of boolean values in expressions that weren't standalone. e.g. expr {true} was fine, but expr {true ? 4 : 5} was not. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-12-26loop: Allow start value to be omittedSteve Bennett1-0/+8
It is convenient to be able to do just: loop i 5 { body } Where the start value is 0. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-12-26core: commands that take an index now use integer expressionsSteve Bennett9-27/+160
This means that instead of just [list index 2+1], we can now do [list index end-$n*2+1] This applies to: lindex, linsert, lreplace, lset, lrange, lsort, regexp, regsub string index,first,last,range Also add tests for both direct integer expressions and indexes. Still needs doc update. Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-12-26core: support integer expressions in various commandsSteve Bennett5-38/+36
For convenience, many commands now accept integer expressions rather than only simple integers. These are: loop, range, incr, string repeat, lrepeat, pack, unpack, rand This simplifies many cases where previously expr {} or $() was required. e.g. foreach i [range 4+1 2*$b] { ... } string repeat 2**$n a Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-12-11list, string: support any number of +/-n for indexSteve Bennett1-0/+28
It is especially convenient to add -1 for something like: lindex $list end-$BACK-1 or: string range $str $p $p+$len-1 Signed-off-by: Steve Bennett <steveb@workware.net.au>
2020-11-16expr: TIP 582 - comments in expressionsSteve Bennett2-3/+26
Add support for comments in expressions Signed-off-by: Steve Bennett <steveb@workware.net.au>