aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2020-12-10 20:05:15 +1000
committerSteve Bennett <steveb@workware.net.au>2020-12-11 22:00:00 +1000
commit0490da395651936d844cce2e32d4972cc2ba985a (patch)
tree3a118717b441eef30618a9db6e2bfe84e709aaf1 /tests
parenta2816313da54dcadcdb8eecb3875fcc7373432ea (diff)
downloadjimtcl-0490da395651936d844cce2e32d4972cc2ba985a.zip
jimtcl-0490da395651936d844cce2e32d4972cc2ba985a.tar.gz
jimtcl-0490da395651936d844cce2e32d4972cc2ba985a.tar.bz2
list, string: support any number of +/-n for index
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/jim.test28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/jim.test b/tests/jim.test
index eaef8aa..ba76879 100644
--- a/tests/jim.test
+++ b/tests/jim.test
@@ -1837,6 +1837,34 @@ test lindex-17.1 {no index} {
lindex {a b c}
} {a b c}
+test lindex-18.1 {multiple +n} {
+ lindex {a b c d e f g} 1+1+1
+} {d}
+
+test lindex-18.2 {multiple +n/-n} {
+ lindex {a b c d e f g} 1+2-1
+} {c}
+
+test lindex-18.3 {end + multiple +n/-n} {
+ lindex {a b c d e f g} end-1-1
+} {e}
+
+test lindex-18.3 {end + multiple +n/-n} {
+ lindex {a b c d e f g} end-3+1
+} {e}
+
+test lindex-18.4 {multiple +/- in error} -body {
+ lindex {a b c d e f g} 1-x+3
+} -returnCodes error -match glob -result "bad index*"
+
+test lindex-18.5 {multiple +/- in error} -body {
+ lindex {a b c d e f g} 2-1+4x
+} -returnCodes error -match glob -result "bad index*"
+
+test lindex-18.6 {multiple +/- in error} -body {
+ lindex {a b c d e f g} end-3x-1
+} -returnCodes error -match glob -result "bad index*"
+
catch { unset lindex}
catch { unset minus }