aboutsummaryrefslogtreecommitdiff
path: root/tests/misc.test
diff options
context:
space:
mode:
authorSteve Bennett <steveb@workware.net.au>2010-01-24 12:44:43 +1000
committerSteve Bennett <steveb@workware.net.au>2010-10-15 11:02:44 +1000
commita230afdc68bcad14a9dfd0f9c8c6955980669cd6 (patch)
tree7f0824345c96818381a7e8c4f919d1aadce44322 /tests/misc.test
parent9652302fec62f76bf894c6b9eb849bda6994c293 (diff)
downloadjimtcl-a230afdc68bcad14a9dfd0f9c8c6955980669cd6.zip
jimtcl-a230afdc68bcad14a9dfd0f9c8c6955980669cd6.tar.gz
jimtcl-a230afdc68bcad14a9dfd0f9c8c6955980669cd6.tar.bz2
Many improvements, bug fixes
*: Allow math functions to be enabled via configure *: Allow support for references to be removed *: Documentation updates *: Jim_ListLength() now returns the result directly *: Optimise list -> dict conversion *: Consistent capitalisation of some structures, functions *: Add support for abbreviations to Jim_GetEnum() *: The commands to 'info' may be abbreviated *: Use abbreviation support in parsing options to 'subst' *: Use Jim_GetEnum() to parse return code names *: Optimise 'array get', 'array set' if no conversion needed *: Import Tcl string.test *: string compare now returns -1,0,1 like Tcl *: Fix 'string last' with index=0 *: Add support for 'string reverse' *: Add -nocase option to 'string equal' *: Fix infinite loop in 'string repeat str -1' *: Support braced patterns in glob *: glob should not return dot files unless the pattern starts with . *: Simplify glob.tcl by using some new features *: When creating C extensions from Tcl, preserve newlines and invoke with Jim_Eval_Named() to produce more meaningful error messages. *: Also remove all comments, not just those starting in the first column *: Add support for 'n+n' and 'n-n' in string/list indexes (Tcl 8.5) *: Add a level to the stack trace for 'return -code error' *: 'return -code' should also affect the return from 'source' (see Tcl docs) *: Fix lsort -command *: Some systems don't have INFINITY
Diffstat (limited to 'tests/misc.test')
-rw-r--r--tests/misc.test79
1 files changed, 78 insertions, 1 deletions
diff --git a/tests/misc.test b/tests/misc.test
index c5d45e5..53c37eb 100644
--- a/tests/misc.test
+++ b/tests/misc.test
@@ -123,6 +123,83 @@ test lrepeat-1.8 "Errors" {
catch {lrepeat -10 a}
} {1}
-section "unset"
+section "string/list index"
+
+test lindex-1.1 "Integer" {
+ lindex {a b c} 0
+} a
+
+test lindex-1.1 "Integer" {
+ lindex {a b c} 2
+} c
+
+test lindex-1.1 "Integer" {
+ lindex {a b c} -1
+} {}
+
+test lindex-1.1 "Integer" {
+ lindex {a b c} 4
+} {}
+
+test lindex-1.1 "end" {
+ lindex {a b c} end
+} c
+
+test lindex-1.1 "end" {
+ lindex {a b c} end-1
+} b
+
+test lindex-1.1 "end" {
+ lindex {a b c} end-4
+} {}
+
+test lindex-1.1 "end - errors" {
+ catch {lindex {a b c} end-}
+} 1
+
+test lindex-1.1 "end - errors" {
+ catch {lindex {a b c} end-blah}
+} 1
+
+test lindex-1.1 "end - errors" {
+ catch {lindex {a b c} end+1}
+} 1
+
+test lindex-1.1 "int+int, int-int" {
+ lindex {a b c} 0+1
+} b
+
+test lindex-1.1 "int+int, int-int" {
+ lindex {a b c} 0+4
+} {}
+
+test lindex-1.1 "int+int, int-int" {
+ lindex {a b c} 3-1
+} c
+
+test lindex-1.1 "int+int, int-int" {
+ lindex {a b c} 1--1
+} c
+
+test lindex-1.1 "int+int, int-int" {
+ set l {a b c}
+ lindex $l [lsearch $l b]-1
+} a
+
+test lindex-1.1 "int+int - errors" {
+ catch {lindex {a b c} 5+blah}
+} 1
+
+test lindex-1.1 "int+int - errors" {
+ catch {lindex {a b c} 5-blah}
+} 1
+
+test lindex-1.1 "int+int - errors" {
+ catch {lindex {a b c} blah-2}
+} 1
+
+test lindex-1.1 "unary plus" {
+ lindex {a b c} +2
+} c
testreport