summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/lindex.test491
-rw-r--r--tests/lset.test455
-rwxr-xr-xtests/lsetComp.test433
-rw-r--r--tests/obj.test73
-rw-r--r--tests/string.test5
-rw-r--r--tests/stringComp.test5
6 files changed, 1392 insertions, 70 deletions
diff --git a/tests/lindex.test b/tests/lindex.test
index b9500b4..98ca49d 100644
--- a/tests/lindex.test
+++ b/tests/lindex.test
@@ -7,79 +7,466 @@
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
+# Copyright (c) 2001 by Kevin B. Kenny. All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: lindex.test,v 1.8 2001/05/15 14:45:00 msofer Exp $
+# RCS: @(#) $Id: lindex.test,v 1.9 2001/11/14 23:16:35 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
namespace import -force ::tcltest::*
}
-test lindex-1.1 {basic tests} {
- lindex {a b c} 0} a
-test lindex-1.2 {basic tests} {
- lindex {a {b c d} x} 1} {b c d}
-test lindex-1.3 {basic tests} {
- lindex {a b\ c\ d x} 1} {b c d}
-test lindex-1.4 {basic tests} {
- lindex {a b c} 3} {}
-test lindex-1.5 {basic tests} {
- list [catch {lindex {a b c} -1} msg] $msg
-} {0 {}}
-test lindex-1.6 {basic tests} {
- lindex {a b c d} end
-} d
-test lindex-1.7 {basic tests} {
- lindex {a b c d} 100
+set lindex lindex
+set minus -
+
+# Tests of Tcl_LindexObjCmd, NOT COMPILED
+
+test lindex-1.1 {wrong # args} {
+ list [catch {eval $lindex} result] $result
+} "1 {wrong # args: should be \"lindex list ?index...?\"}"
+
+# Indices that are lists or convertible to lists
+
+test lindex-2.1 {empty index list} {
+ set x {}
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {{a b c} {a b c}}
+
+test lindex-2.2 {singleton index list} {
+ set x { 1 }
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {b b}
+
+test lindex-2.3 {multiple indices in list} {
+ set x {1 2}
+ list [eval [list $lindex {{a b c} {d e f}} $x]] \
+ [eval [list $lindex {{a b c} {d e f}} $x]]
+} {f f}
+
+test lindex-2.4 {malformed index list} {
+ set x \{
+ list [catch { eval [list $lindex {a b c} $x] } result] $result
+} {1 bad\ index\ \"\{\":\ must\ be\ integer\ or\ end?-integer?}
+
+# Indices that are integers or convertible to integers
+
+test lindex-3.1 {integer -1} {
+ set x ${minus}1
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {{} {}}
+
+test lindex-3.2 {integer 0} {
+ set x [string range 00 0 0]
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {a a}
+
+test lindex-3.3 {integer 2} {
+ set x [string range 22 0 0]
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {c c}
+
+test lindex-3.4 {integer 3} {
+ set x [string range 33 0 0]
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {{} {}}
+
+test lindex-3.5 {bad octal} {
+ set x 08
+ list [catch { eval [list $lindex {a b c} $x] } result] $result
+} "1 {bad index \"08\": must be integer or end?-integer? (looks like invalid octal number)}"
+
+test lindex-3.6 {bad octal} {
+ set x -09
+ list [catch { eval [list $lindex {a b c} $x] } result] $result
+} "1 {bad index \"-09\": must be integer or end?-integer? (looks like invalid octal number)}"
+
+# Indices relative to end
+
+test lindex-4.1 {index = end} {
+ set x end
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {c c}
+
+test lindex-4.2 {index = end--1} {
+ set x end--1
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {{} {}}
+
+test lindex-4.3 {index = end-0} {
+ set x end-0
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {c c}
+
+test lindex-4.4 {index = end-2} {
+ set x end-2
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {a a}
+
+test lindex-4.5 {index = end-3} {
+ set x end-3
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {{} {}}
+
+test lindex-4.6 {bad octal} {
+ set x end-08
+ list [catch { eval [list $lindex {a b c} $x] } result] $result
+} "1 {bad index \"end-08\": must be integer or end?-integer? (looks like invalid octal number)}"
+
+test lindex-4.7 {bad octal} {
+ set x end--09
+ list [catch { eval [list $lindex {a b c} $x] } result] $result
+} "1 {bad index \"end--09\": must be integer or end?-integer?}"
+
+test lindex-4.8 {bad integer, not octal} {
+ set x end-0a2
+ list [catch { eval [list $lindex {a b c} $x] } result] $result
+} "1 {bad index \"end-0a2\": must be integer or end?-integer?}"
+
+test lindex-4.9 {incomplete end} {
+ set x en
+ list [eval [list $lindex {a b c} $x]] [eval [list $lindex {a b c} $x]]
+} {c c}
+
+test lindex-4.10 {incomplete end-} {
+ set x end-
+ list [catch { eval [list $lindex {a b c} $x] } result] $result
+} "1 {bad index \"end-\": must be integer or end?-integer?}"
+
+test lindex-5.1 {bad second index} {
+ list [catch { eval [list $lindex {a b c} 0 0a2] } result] $result
+} "1 {bad index \"0a2\": must be integer or end?-integer?}"
+
+test lindex-5.2 {good second index} {
+ eval [list $lindex {{a b c} {d e f} {g h i}} 1 2]
+} f
+
+test lindex-5.3 {three indices} {
+ eval [list $lindex {{{a b} {c d}} {{e f} {g h}}} 1 0 1]
+} f
+test lindex-6.1 {error conditions in parsing list} {
+ list [catch {eval [list $lindex "a \{" 2]} msg] $msg
+} {1 {unmatched open brace in list}}
+test lindex-6.2 {error conditions in parsing list} {
+ list [catch {eval [list $lindex {a {b c}d e} 2]} msg] $msg
+} {1 {list element in braces followed by "d" instead of space}}
+test lindex-6.3 {error conditions in parsing list} {
+ list [catch {eval [list $lindex {a "b c"def ghi} 2]} msg] $msg
+} {1 {list element in quotes followed by "def" instead of space}}
+
+test lindex-7.1 {quoted elements} {
+ eval [list $lindex {a "b c" d} 1]
+} {b c}
+test lindex-7.2 {quoted elements} {
+ eval [list $lindex {"{}" b c} 0]
+} {{}}
+test lindex-7.3 {quoted elements} {
+ eval [list $lindex {ab "c d \" x" y} 1]
+} {c d " x}
+test lindex-7.4 {quoted elements} {
+ lindex {a b {c d "e} {f g"}} 2
+} {c d "e}
+
+test lindex-8.1 {data reuse} {
+ set x 0
+ eval [list $lindex $x $x]
+} {0}
+
+test lindex-8.2 {data reuse} {
+ set a 0
+ eval [list $lindex $a $a $a]
+} 0
+test lindex-8.3 {data reuse} {
+ set a 1
+ eval [list $lindex $a $a $a]
} {}
-test lindex-1.8 {basic tests} {
- lindex {a} e
-} a
-test lindex-1.9 {basic tests} {
- lindex {} end
+
+test lindex-8.4 {data reuse} {
+ set x [list 0 0]
+ eval [list $lindex $x $x]
+} {0}
+
+test lindex-8.5 {data reuse} {
+ set x 0
+ eval [list $lindex $x [list $x $x]]
+} {0}
+
+test lindex-8.6 {data reuse} {
+ set x [list 1 1]
+ eval [list $lindex $x $x]
} {}
-test lindex-1.10 {basic tests} {
- lindex {a b c d} 3
-} d
-test lindex-1.11 {Nested list with a backslashed brace} {
- lindex {{a \{}} 0
-} {a \{}
-
-test lindex-2.1 {error conditions} {
- list [catch {lindex msg} msg] $msg
-} {1 {wrong # args: should be "lindex list index"}}
-test lindex-2.2 {error conditions} {
- list [catch {lindex 1 2 3 4} msg] $msg
-} {1 {wrong # args: should be "lindex list index"}}
-test lindex-2.3 {error conditions} {
- list [catch {lindex 1 2a2} msg] $msg
-} {1 {bad index "2a2": must be integer or end?-integer?}}
-test lindex-2.4 {error conditions} {
- list [catch {lindex "a \{" 2} msg] $msg
+
+test lindex-8.7 {data reuse} {
+ set x 1
+ eval [list lindex $x [list $x $x]]
+} {}
+
+#----------------------------------------------------------------------
+
+# Compilation tests for lindex
+
+test lindex-9.1 {wrong # args} {
+ list [catch {lindex} result] $result
+} "1 {wrong # args: should be \"lindex list ?index...?\"}"
+
+# Indices that are lists or convertible to lists
+
+test lindex-10.1 {empty index list} {
+ set x {}
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {{a b c} {a b c}}
+
+test lindex-10.2 {singleton index list} {
+ set x { 1 }
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {b b}
+
+test lindex-10.3 {multiple indices in list} {
+ set x {1 2}
+ catch {
+ list [lindex {{a b c} {d e f}} $x] [lindex {{a b c} {d e f}} $x]
+ } result
+ set result
+} {f f}
+
+test lindex-10.4 {malformed index list} {
+ set x \{
+ list [catch { lindex {a b c} $x } result] $result
+} {1 bad\ index\ \"\{\":\ must\ be\ integer\ or\ end?-integer?}
+
+# Indices that are integers or convertible to integers
+
+test lindex-11.1 {integer -1} {
+ set x ${minus}1
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {{} {}}
+
+test lindex-11.2 {integer 0} {
+ set x [string range 00 0 0]
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {a a}
+
+test lindex-11.3 {integer 2} {
+ set x [string range 22 0 0]
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {c c}
+
+test lindex-11.4 {integer 3} {
+ set x [string range 33 0 0]
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {{} {}}
+
+test lindex-11.5 {bad octal} {
+ set x 08
+ list [catch { lindex {a b c} $x } result] $result
+} "1 {bad index \"08\": must be integer or end?-integer? (looks like invalid octal number)}"
+
+test lindex-11.6 {bad octal} {
+ set x -09
+ list [catch { lindex {a b c} $x } result] $result
+} "1 {bad index \"-09\": must be integer or end?-integer? (looks like invalid octal number)}"
+
+# Indices relative to end
+
+test lindex-12.1 {index = end} {
+ set x end
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {c c}
+
+test lindex-12.2 {index = end--1} {
+ set x end--1
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {{} {}}
+
+test lindex-12.3 {index = end-0} {
+ set x end-0
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {c c}
+
+test lindex-12.4 {index = end-2} {
+ set x end-2
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {a a}
+
+test lindex-12.5 {index = end-3} {
+ set x end-3
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {{} {}}
+
+test lindex-12.6 {bad octal} {
+ set x end-08
+ list [catch { lindex {a b c} $x } result] $result
+} "1 {bad index \"end-08\": must be integer or end?-integer? (looks like invalid octal number)}"
+
+test lindex-12.7 {bad octal} {
+ set x end--09
+ list [catch { lindex {a b c} $x } result] $result
+} "1 {bad index \"end--09\": must be integer or end?-integer?}"
+
+test lindex-12.8 {bad integer, not octal} {
+ set x end-0a2
+ list [catch { lindex {a b c} $x } result] $result
+} "1 {bad index \"end-0a2\": must be integer or end?-integer?}"
+
+test lindex-12.9 {incomplete end} {
+ set x en
+ catch {
+ list [lindex {a b c} $x] [lindex {a b c} $x]
+ } result
+ set result
+} {c c}
+
+test lindex-12.10 {incomplete end-} {
+ set x end-
+ list [catch { lindex {a b c} $x } result] $result
+} "1 {bad index \"end-\": must be integer or end?-integer?}"
+
+test lindex-13.1 {bad second index} {
+ list [catch { lindex {a b c} 0 0a2 } result] $result
+} "1 {bad index \"0a2\": must be integer or end?-integer?}"
+
+test lindex-13.2 {good second index} {
+ catch {
+ lindex {{a b c} {d e f} {g h i}} 1 2
+ } result
+ set result
+} f
+
+test lindex-13.3 {three indices} {
+ catch {
+ lindex {{{a b} {c d}} {{e f} {g h}}} 1 0 1
+ } result
+ set result
+} f
+
+test lindex-14.1 {error conditions in parsing list} {
+ list [catch { lindex "a \{" 2 } msg] $msg
} {1 {unmatched open brace in list}}
-test lindex-2.5 {error conditions} {
- list [catch {lindex {a {b c}d e} 2} msg] $msg
+test lindex-14.2 {error conditions in parsing list} {
+ list [catch { lindex {a {b c}d e} 2 } msg] $msg
} {1 {list element in braces followed by "d" instead of space}}
-test lindex-2.6 {error conditions} {
- list [catch {lindex {a "b c"def ghi} 2} msg] $msg
+test lindex-14.3 {error conditions in parsing list} {
+ list [catch { lindex {a "b c"def ghi} 2 } msg] $msg
} {1 {list element in quotes followed by "def" instead of space}}
-test lindex-3.1 {quoted elements} {
- lindex {a "b c" d} 1
+test lindex-15.1 {quoted elements} {
+ catch {
+ lindex {a "b c" d} 1
+ } result
+ set result
} {b c}
-test lindex-3.2 {quoted elements} {
- lindex {"{}" b c} 0
+test lindex-15.2 {quoted elements} {
+ catch {
+ lindex {"{}" b c} 0
+ } result
+ set result
} {{}}
-test lindex-3.3 {quoted elements} {
- lindex {ab "c d \" x" y} 1
+test lindex-15.3 {quoted elements} {
+ catch {
+ lindex {ab "c d \" x" y} 1
+ } result
+ set result
} {c d " x}
-test lindex-3.4 {quoted elements} {
- lindex {a b {c d "e} {f g"}} 2
+test lindex-15.4 {quoted elements} {
+ catch {
+ lindex {a b {c d "e} {f g"}} 2
+ } result
+ set result
} {c d "e}
+test lindex-16.1 {data reuse} {
+ set x 0
+ catch {
+ lindex $x $x
+ } result
+ set result
+} {0}
+
+test lindex-16.2 {data reuse} {
+ set a 0
+ catch {
+ lindex $a $a $a
+ } result
+ set result
+} 0
+test lindex-16.3 {data reuse} {
+ set a 1
+ catch {
+ lindex $a $a $a
+ } result
+ set result
+} {}
+
+test lindex-16.4 {data reuse} {
+ set x [list 0 0]
+ catch {
+ lindex $x $x
+ } result
+ set result
+} {0}
+
+test lindex-16.5 {data reuse} {
+ set x 0
+ catch {
+ lindex $x [list $x $x]
+ } result
+ set result
+} {0}
+
+test lindex-16.6 {data reuse} {
+ set x [list 1 1]
+ catch {
+ lindex $x $x
+ } result
+ set result
+} {}
+
+test lindex-16.7 {data reuse} {
+ set x 1
+ catch {
+ lindex $x [list $x $x]
+ } result
+ set result
+} {}
+
+catch { unset lindex}
+catch { unset minus }
+
# cleanup
::tcltest::cleanupTests
return
diff --git a/tests/lset.test b/tests/lset.test
new file mode 100644
index 0000000..0e70357
--- /dev/null
+++ b/tests/lset.test
@@ -0,0 +1,455 @@
+# This file is a -*- tcl -*- test script
+
+# Commands covered: lset
+#
+# This file contains a collection of tests for one or more of the Tcl
+# built-in commands. Sourcing this file into Tcl runs the tests and
+# generates output for errors. No output means no errors were found.
+#
+# Copyright (c) 2001 by Kevin B. Kenny. All rights reserved.
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# RCS: @(#) $Id$
+
+if {[lsearch [namespace children] ::tcltest] == -1} {
+ package require tcltest
+ namespace import -force ::tcltest::*
+}
+
+proc failTrace {name1 name2 op} {
+ error "trace failed"
+}
+
+set lset lset
+
+set noRead {}
+trace add variable noRead read failTrace
+set noWrite {a b c}
+trace add variable noWrite write failTrace
+
+test lset-1.1 {lset, not compiled, arg count} {
+ list [catch {eval $lset} msg] $msg
+} "1 {wrong \# args: should be \"lset listVar index ?index...? value\"}"
+
+test lset-1.2 {lset, not compiled, no such var} {
+ list [catch {eval [list $lset noSuchVar 0 {}]} msg] $msg
+} "1 {can't read \"noSuchVar\": no such variable}"
+
+test lset-1.3 {lset, not compiled, var not readable} {
+ list [catch {eval [list $lset noRead 0 {}]} msg] $msg
+} "1 {can't read \"noRead\": trace failed}"
+
+test lset-2.1 {lset, not compiled, 3 args, second arg a plain index} {
+ set x {0 1 2}
+ list [eval [list $lset x 0 3]] $x
+} {{3 1 2} {3 1 2}}
+
+test lset-2.2 {lset, not compiled, 3 args, second arg neither index nor list} {
+ set x {0 1 2}
+ list [catch {
+ eval [list $lset x {{bad}1} 3]
+ } msg] $msg
+} "1 {bad index \"{bad}1\": must be integer or end?-integer?}"
+
+test lset-3.1 {lset, not compiled, 3 args, data duplicated} {
+ set x {0 1 2}
+ list [eval [list $lset x 0 $x]] $x
+} {{{0 1 2} 1 2} {{0 1 2} 1 2}}
+
+test lset-3.2 {lset, not compiled, 3 args, data duplicated} {
+ set x {0 1}
+ set y $x
+ list [eval [list $lset x 0 2]] $x $y
+} {{2 1} {2 1} {0 1}}
+
+test lset-3.3 {lset, not compiled, 3 args, data duplicated} {
+ set x {0 1}
+ set y $x
+ list [eval [list $lset x 0 $x]] $x $y
+} {{{0 1} 1} {{0 1} 1} {0 1}}
+
+test lset-3.4 {lset, not compiled, 3 args, data duplicated} {
+ set x {0 1 2}
+ list [eval [list $lset x [list 0] $x]] $x
+} {{{0 1 2} 1 2} {{0 1 2} 1 2}}
+
+test lset-3.5 {lset, not compiled, 3 args, data duplicated} {
+ set x {0 1}
+ set y $x
+ list [eval [list $lset x [list 0] 2]] $x $y
+} {{2 1} {2 1} {0 1}}
+
+test lset-3.6 {lset, not compiled, 3 args, data duplicated} {
+ set x {0 1}
+ set y $x
+ list [eval [list $lset x [list 0] $x]] $x $y
+} {{{0 1} 1} {{0 1} 1} {0 1}}
+
+test lset-4.1 {lset, not compiled, 3 args, not a list} {
+ set a "x \{"
+ list [catch {
+ eval [list $lset a [list 0] y]
+ } msg] $msg
+} {1 {unmatched open brace in list}}
+
+test lset-4.2 {lset, not compiled, 3 args, bad index} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a [list 2a2] w]
+ } msg] $msg
+} {1 {bad index "2a2": must be integer or end?-integer?}}
+
+test lset-4.3 {lset, not compiled, 3 args, index out of range} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a [list -1] w]
+ } msg] $msg
+} {1 {list index out of range}}
+
+test lset-4.4 {lset, not compiled, 3 args, index out of range} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a [list 3] w]
+ } msg] $msg
+} {1 {list index out of range}}
+
+test lset-4.5 {lset, not compiled, 3 args, index out of range} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a [list end--1] w]
+ } msg] $msg
+} {1 {list index out of range}}
+
+test lset-4.6 {lset, not compiled, 3 args, index out of range} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a [list end-3] w]
+ } msg] $msg
+} {1 {list index out of range}}
+
+test lset-4.7 {lset, not compiled, 3 args, not a list} {
+ set a "x \{"
+ list [catch {
+ eval [list $lset a 0 y]
+ } msg] $msg
+} {1 {unmatched open brace in list}}
+
+test lset-4.8 {lset, not compiled, 3 args, bad index} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a 2a2 w]
+ } msg] $msg
+} {1 {bad index "2a2": must be integer or end?-integer?}}
+
+test lset-4.9 {lset, not compiled, 3 args, index out of range} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a -1 w]
+ } msg] $msg
+} {1 {list index out of range}}
+
+test lset-4.10 {lset, not compiled, 3 args, index out of range} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a 3 w]
+ } msg] $msg
+} {1 {list index out of range}}
+
+test lset-4.11 {lset, not compiled, 3 args, index out of range} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a end--1 w]
+ } msg] $msg
+} {1 {list index out of range}}
+
+test lset-4.12 {lset, not compiled, 3 args, index out of range} {
+ set a {x y z}
+ list [catch {
+ eval [list $lset a end-3 w]
+ } msg] $msg
+} {1 {list index out of range}}
+
+test lset-5.1 {lset, not compiled, 3 args, can't set variable} {
+ list [catch {
+ eval [list $lset noWrite 0 d]
+ } msg] $msg $noWrite
+} {1 {can't set "noWrite": trace failed} {d b c}}
+
+test lset-5.2 {lset, not compiled, 3 args, can't set variable} {
+ list [catch {
+ eval [list $lset noWrite [list 0] d]
+ } msg] $msg $noWrite
+} {1 {can't set "noWrite": trace failed} {d b c}}
+
+test lset-6.1 {lset, not compiled, 3 args, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a 0 a]] $a
+} {{a y z} {a y z}}
+
+test lset-6.2 {lset, not compiled, 3 args, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a [list 0] a]] $a
+} {{a y z} {a y z}}
+
+test lset-6.3 {lset, not compiled, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a 2 a]] $a
+} {{x y a} {x y a}}
+
+test lset-6.4 {lset, not compiled, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a [list 2] a]] $a
+} {{x y a} {x y a}}
+
+test lset-6.5 {lset, not compiled, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a end a]] $a
+} {{x y a} {x y a}}
+
+test lset-6.6 {lset, not compiled, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a [list end] a]] $a
+} {{x y a} {x y a}}
+
+test lset-6.7 {lset, not compiled, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a end-0 a]] $a
+} {{x y a} {x y a}}
+
+test lset-6.8 {lset, not compiled, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a [list end-0] a]] $a
+} {{x y a} {x y a}}
+
+test lset-6.9 {lset, not compiled, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a end-2 a]] $a
+} {{a y z} {a y z}}
+
+test lset-6.10 {lset, not compiled, 1-d list basics} {
+ set a {x y z}
+ list [eval [list $lset a [list end-2] a]] $a
+} {{a y z} {a y z}}
+
+test lset-7.1 {lset, not compiled, data sharing} {
+ set a 0
+ list [eval [list $lset a $a {gag me}]] $a
+} {{{gag me}} {{gag me}}}
+
+test lset-7.2 {lset, not compiled, data sharing} {
+ set a [list 0]
+ list [eval [list $lset a $a {gag me}]] $a
+} {{{gag me}} {{gag me}}}
+
+test lset-7.3 {lset, not compiled, data sharing} {
+ set a {x y}
+ list [eval [list $lset a 0 $a]] $a
+} {{{x y} y} {{x y} y}}
+
+test lset-7.4 {lset, not compiled, data sharing} {
+ set a {x y}
+ list [eval [list $lset a [list 0] $a]] $a
+} {{{x y} y} {{x y} y}}
+
+test lset-7.5 {lset, not compiled, data sharing} {
+ set n 0
+ set a {x y}
+ list [eval [list $lset a $n $n]] $a $n
+} {{0 y} {0 y} 0}
+
+test lset-7.6 {lset, not compiled, data sharing} {
+ set n [list 0]
+ set a {x y}
+ list [eval [list $lset a $n $n]] $a $n
+} {{0 y} {0 y} 0}
+
+test lset-7.7 {lset, not compiled, data sharing} {
+ set n 0
+ set a [list $n $n]
+ list [eval [list $lset a $n 1]] $a $n
+} {{1 0} {1 0} 0}
+
+test lset-7.8 {lset, not compiled, data sharing} {
+ set n [list 0]
+ set a [list $n $n]
+ list [eval [list $lset a $n 1]] $a $n
+} {{1 0} {1 0} 0}
+
+test lset-7.9 {lset, not compiled, data sharing} {
+ set a 0
+ list [eval [list $lset a $a $a]] $a
+} {0 0}
+
+test lset-7.10 {lset, not compiled, data sharing} {
+ set a [list 0]
+ list [eval [list $lset a $a $a]] $a
+} {0 0}
+
+test lset-8.1 {lset, not compiled, malformed sublist} {
+ set a [list "a \{" b]
+ list [catch {eval [list $lset a 0 1 c]} msg] $msg
+} {1 {unmatched open brace in list}}
+
+test lset-8.2 {lset, not compiled, malformed sublist} {
+ set a [list "a \{" b]
+ list [catch {eval [list $lset a {0 1} c]} msg] $msg
+} {1 {unmatched open brace in list}}
+
+test lset-8.3 {lset, not compiled, bad second index} {
+ set a {{b c} {d e}}
+ list [catch {eval [list $lset a 0 2a2 f]} msg] $msg
+} {1 {bad index "2a2": must be integer or end?-integer?}}
+
+test lset-8.4 {lset, not compiled, bad second index} {
+ set a {{b c} {d e}}
+ list [catch {eval [list $lset a {0 2a2} f]} msg] $msg
+} {1 {bad index "2a2": must be integer or end?-integer?}}
+
+test lset-8.5 {lset, not compiled, second index out of range} {
+ set a {{b c} {d e} {f g}}
+ list [catch {eval [list $lset a 2 -1 h]} msg] $msg
+} {1 {list index out of range}}
+
+test lset-8.6 {lset, not compiled, second index out of range} {
+ set a {{b c} {d e} {f g}}
+ list [catch {eval [list $lset a {2 -1} h]} msg] $msg
+} {1 {list index out of range}}
+
+test lset-8.7 {lset, not compiled, second index out of range} {
+ set a {{b c} {d e} {f g}}
+ list [catch {eval [list $lset a 2 2 h]} msg] $msg
+} {1 {list index out of range}}
+
+test lset-8.8 {lset, not compiled, second index out of range} {
+ set a {{b c} {d e} {f g}}
+ list [catch {eval [list $lset a {2 2} h]} msg] $msg
+} {1 {list index out of range}}
+
+test lset-8.9 {lset, not compiled, second index out of range} {
+ set a {{b c} {d e} {f g}}
+ list [catch {eval [list $lset a 2 end--1 h]} msg] $msg
+} {1 {list index out of range}}
+
+test lset-8.10 {lset, not compiled, second index out of range} {
+ set a {{b c} {d e} {f g}}
+ list [catch {eval [list $lset a {2 end--1} h]} msg] $msg
+} {1 {list index out of range}}
+
+test lset-8.11 {lset, not compiled, second index out of range} {
+ set a {{b c} {d e} {f g}}
+ list [catch {eval [list $lset a 2 end-2 h]} msg] $msg
+} {1 {list index out of range}}
+
+test lset-8.12 {lset, not compiled, second index out of range} {
+ set a {{b c} {d e} {f g}}
+ list [catch {eval [list $lset a {2 end-2} h]} msg] $msg
+} {1 {list index out of range}}
+
+test lset-9.1 {lset, not compiled, entire variable} {
+ set a x
+ list [eval [list $lset a y]] $a
+} {y y}
+
+test lset-9.2 {lset, not compiled, entire variable} {
+ set a x
+ list [eval [list $lset a {} y]] $a
+} {y y}
+
+test lset-10.1 {lset, not compiled, shared data} {
+ set row {p q}
+ set a [list $row $row]
+ list [eval [list $lset a 0 0 x]] $a
+} {{{x q} {p q}} {{x q} {p q}}}
+
+test lset-10.2 {lset, not compiled, shared data} {
+ set row {p q}
+ set a [list $row $row]
+ list [eval [list $lset a {0 0} x]] $a
+} {{{x q} {p q}} {{x q} {p q}}}
+
+test lset-11.1 {lset, not compiled, 2-d basics} {
+ set a {{b c} {d e}}
+ list [eval [list $lset a 0 0 f]] $a
+} {{{f c} {d e}} {{f c} {d e}}}
+
+test lset-11.2 {lset, not compiled, 2-d basics} {
+ set a {{b c} {d e}}
+ list [eval [list $lset a {0 0} f]] $a
+} {{{f c} {d e}} {{f c} {d e}}}
+
+test lset-11.3 {lset, not compiled, 2-d basics} {
+ set a {{b c} {d e}}
+ list [eval [list $lset a 0 1 f]] $a
+} {{{b f} {d e}} {{b f} {d e}}}
+
+test lset-11.4 {lset, not compiled, 2-d basics} {
+ set a {{b c} {d e}}
+ list [eval [list $lset a {0 1} f]] $a
+} {{{b f} {d e}} {{b f} {d e}}}
+
+test lset-11.5 {lset, not compiled, 2-d basics} {
+ set a {{b c} {d e}}
+ list [eval [list $lset a 1 0 f]] $a
+} {{{b c} {f e}} {{b c} {f e}}}
+
+test lset-11.6 {lset, not compiled, 2-d basics} {
+ set a {{b c} {d e}}
+ list [eval [list $lset a {1 0} f]] $a
+} {{{b c} {f e}} {{b c} {f e}}}
+
+test lset-11.7 {lset, not compiled, 2-d basics} {
+ set a {{b c} {d e}}
+ list [eval [list $lset a 1 1 f]] $a
+} {{{b c} {d f}} {{b c} {d f}}}
+
+test lset-11.8 {lset, not compiled, 2-d basics} {
+ set a {{b c} {d e}}
+ list [eval [list $lset a {1 1} f]] $a
+} {{{b c} {d f}} {{b c} {d f}}}
+
+test lset-12.0 {lset, not compiled, typical sharing pattern} {
+ set zero 0
+ set row [list $zero $zero $zero $zero]
+ set ident [list $row $row $row $row]
+ for { set i 0 } { $i < 4 } { incr i } {
+ eval [list $lset ident $i $i 1]
+ }
+ set ident
+} {{1 0 0 0} {0 1 0 0} {0 0 1 0} {0 0 0 1}}
+
+test lset-13.0 {lset, not compiled, shimmering hell} {
+ set a 0
+ list [eval [list $lset a $a $a $a $a {gag me}]] $a
+} {{{{{{gag me}}}}} {{{{{gag me}}}}}}
+
+test lset-13.1 {lset, not compiled, shimmering hell} {
+ set a [list 0]
+ list [eval [list $lset a $a $a $a $a {gag me}]] $a
+} {{{{{{gag me}}}}} {{{{{gag me}}}}}}
+
+test lset-13.2 {lset, not compiled, shimmering hell} {
+ set a [list 0 0 0 0]
+ list [eval [list $lset a $a {gag me}]] $a
+} {{{{{{gag me}}}} 0 0 0} {{{{{gag me}}}} 0 0 0}}
+
+test lset-14.1 {lset, not compiled, list args, is string rep preserved?} {
+ set a { { 1 2 } { 3 4 } }
+ catch { eval [list $lset a {1 5} 5] }
+ list $a [lindex $a 1]
+} "{ { 1 2 } { 3 4 } } { 3 4 }"
+
+test lset-14.2 {lset, not compiled, flat args, is string rep preserved?} {
+ set a { { 1 2 } { 3 4 } }
+ catch { eval [list $lset a 1 5 5] }
+ list $a [lindex $a 1]
+} "{ { 1 2 } { 3 4 } } { 3 4 }"
+
+catch {unset noRead}
+catch {unset noWrite}
+catch {rename failTrace {}}
+
+# cleanup
+::tcltest::cleanupTests
+return
diff --git a/tests/lsetComp.test b/tests/lsetComp.test
new file mode 100755
index 0000000..6b9264c
--- /dev/null
+++ b/tests/lsetComp.test
@@ -0,0 +1,433 @@
+# This file is a -*- tcl -*- test script
+
+# Commands covered: lset
+#
+# This file contains a collection of tests for one or more of the Tcl
+# built-in commands. Sourcing this file into Tcl runs the tests and
+# generates output for errors. No output means no errors were found.
+#
+# Copyright (c) 2001 by Kevin B. Kenny. All rights reserved.
+#
+# See the file "license.terms" for information on usage and redistribution
+# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+#
+# RCS: @(#) $Id$
+
+if {[lsearch [namespace children] ::tcltest] == -1} {
+ package require tcltest
+ namespace import -force ::tcltest::*
+}
+
+# Procedure to evaluate a script within a proc, to test compilation
+# functionality
+
+proc evalInProc { script } {
+ proc testProc {} $script
+ set status [catch {
+ testProc
+ } result]
+ rename testProc {}
+ return [list $status $result]
+}
+
+# Tests for the bytecode compilation of the 'lset' command
+
+test lsetComp-1.1 {lset, compiled, wrong \# args} {
+ evalInProc {
+ lset
+ }
+} "1 {wrong \# args: should be \"lset listVar index ?index...? value\"}"
+
+test lsetComp-2.1 {lset, compiled, list of args, not a simple var name} {
+ evalInProc {
+ set y x
+ set x {{1 2} {3 4}}
+ lset $y {1 1} 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-2.2 {lset, compiled, list of args, scalar on stack} {
+ evalInProc {
+ set ::x {{1 2} {3 4}}
+ lset ::x {1 1} 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-2.3 {lset, compiled, list of args, scalar, one-byte offset} {
+ evalInProc {
+ set x {{1 2} {3 4}}
+ lset x {1 1} 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-2.4 {lset, compiled, list of args, scalar, four-byte offset} {
+ evalInProc {
+ set x0 0; set x1 0; set x2 0; set x3 0;
+ set x4 0; set x5 0; set x6 0; set x7 0;
+ set x8 0; set x9 0; set x10 0; set x11 0;
+ set x12 0; set x13 0; set x14 0; set x15 0;
+ set x16 0; set x17 0; set x18 0; set x19 0;
+ set x20 0; set x21 0; set x22 0; set x23 0;
+ set x24 0; set x25 0; set x26 0; set x27 0;
+ set x28 0; set x29 0; set x30 0; set x31 0;
+ set x32 0; set x33 0; set x34 0; set x35 0;
+ set x36 0; set x37 0; set x38 0; set x39 0;
+ set x40 0; set x41 0; set x42 0; set x43 0;
+ set x44 0; set x45 0; set x46 0; set x47 0;
+ set x48 0; set x49 0; set x50 0; set x51 0;
+ set x52 0; set x53 0; set x54 0; set x55 0;
+ set x56 0; set x57 0; set x58 0; set x59 0;
+ set x60 0; set x61 0; set x62 0; set x63 0;
+ set x64 0; set x65 0; set x66 0; set x67 0;
+ set x68 0; set x69 0; set x70 0; set x71 0;
+ set x72 0; set x73 0; set x74 0; set x75 0;
+ set x76 0; set x77 0; set x78 0; set x79 0;
+ set x80 0; set x81 0; set x82 0; set x83 0;
+ set x84 0; set x85 0; set x86 0; set x87 0;
+ set x88 0; set x89 0; set x90 0; set x91 0;
+ set x92 0; set x93 0; set x94 0; set x95 0;
+ set x96 0; set x97 0; set x98 0; set x99 0;
+ set x100 0; set x101 0; set x102 0; set x103 0;
+ set x104 0; set x105 0; set x106 0; set x107 0;
+ set x108 0; set x109 0; set x110 0; set x111 0;
+ set x112 0; set x113 0; set x114 0; set x115 0;
+ set x116 0; set x117 0; set x118 0; set x119 0;
+ set x120 0; set x121 0; set x122 0; set x123 0;
+ set x124 0; set x125 0; set x126 0; set x127 0;
+ set x128 0; set x129 0; set x130 0; set x131 0;
+ set x132 0; set x133 0; set x134 0; set x135 0;
+ set x136 0; set x137 0; set x138 0; set x139 0;
+ set x140 0; set x141 0; set x142 0; set x143 0;
+ set x144 0; set x145 0; set x146 0; set x147 0;
+ set x148 0; set x149 0; set x150 0; set x151 0;
+ set x152 0; set x153 0; set x154 0; set x155 0;
+ set x156 0; set x157 0; set x158 0; set x159 0;
+ set x160 0; set x161 0; set x162 0; set x163 0;
+ set x164 0; set x165 0; set x166 0; set x167 0;
+ set x168 0; set x169 0; set x170 0; set x171 0;
+ set x172 0; set x173 0; set x174 0; set x175 0;
+ set x176 0; set x177 0; set x178 0; set x179 0;
+ set x180 0; set x181 0; set x182 0; set x183 0;
+ set x184 0; set x185 0; set x186 0; set x187 0;
+ set x188 0; set x189 0; set x190 0; set x191 0;
+ set x192 0; set x193 0; set x194 0; set x195 0;
+ set x196 0; set x197 0; set x198 0; set x199 0;
+ set x200 0; set x201 0; set x202 0; set x203 0;
+ set x204 0; set x205 0; set x206 0; set x207 0;
+ set x208 0; set x209 0; set x210 0; set x211 0;
+ set x212 0; set x213 0; set x214 0; set x215 0;
+ set x216 0; set x217 0; set x218 0; set x219 0;
+ set x220 0; set x221 0; set x222 0; set x223 0;
+ set x224 0; set x225 0; set x226 0; set x227 0;
+ set x228 0; set x229 0; set x230 0; set x231 0;
+ set x232 0; set x233 0; set x234 0; set x235 0;
+ set x236 0; set x237 0; set x238 0; set x239 0;
+ set x240 0; set x241 0; set x242 0; set x243 0;
+ set x244 0; set x245 0; set x246 0; set x247 0;
+ set x248 0; set x249 0; set x250 0; set x251 0;
+ set x252 0; set x253 0; set x254 0; set x255 0;
+ set x {{1 2} {3 4}}
+ lset x {1 1} 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-2.5 {lset, compiled, list of args, array on stack} {
+ evalInProc {
+ set ::y(0) {{1 2} {3 4}}
+ lset ::y(0) {1 1} 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-2.6 {lset, compiled, list of args, array, one-byte offset} {
+ evalInProc {
+ set y(0) {{1 2} {3 4}}
+ lset y(0) {1 1} 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-2.7 {lset, compiled, list of args, array, four-byte offset} {
+ evalInProc {
+ set x0 0; set x1 0; set x2 0; set x3 0;
+ set x4 0; set x5 0; set x6 0; set x7 0;
+ set x8 0; set x9 0; set x10 0; set x11 0;
+ set x12 0; set x13 0; set x14 0; set x15 0;
+ set x16 0; set x17 0; set x18 0; set x19 0;
+ set x20 0; set x21 0; set x22 0; set x23 0;
+ set x24 0; set x25 0; set x26 0; set x27 0;
+ set x28 0; set x29 0; set x30 0; set x31 0;
+ set x32 0; set x33 0; set x34 0; set x35 0;
+ set x36 0; set x37 0; set x38 0; set x39 0;
+ set x40 0; set x41 0; set x42 0; set x43 0;
+ set x44 0; set x45 0; set x46 0; set x47 0;
+ set x48 0; set x49 0; set x50 0; set x51 0;
+ set x52 0; set x53 0; set x54 0; set x55 0;
+ set x56 0; set x57 0; set x58 0; set x59 0;
+ set x60 0; set x61 0; set x62 0; set x63 0;
+ set x64 0; set x65 0; set x66 0; set x67 0;
+ set x68 0; set x69 0; set x70 0; set x71 0;
+ set x72 0; set x73 0; set x74 0; set x75 0;
+ set x76 0; set x77 0; set x78 0; set x79 0;
+ set x80 0; set x81 0; set x82 0; set x83 0;
+ set x84 0; set x85 0; set x86 0; set x87 0;
+ set x88 0; set x89 0; set x90 0; set x91 0;
+ set x92 0; set x93 0; set x94 0; set x95 0;
+ set x96 0; set x97 0; set x98 0; set x99 0;
+ set x100 0; set x101 0; set x102 0; set x103 0;
+ set x104 0; set x105 0; set x106 0; set x107 0;
+ set x108 0; set x109 0; set x110 0; set x111 0;
+ set x112 0; set x113 0; set x114 0; set x115 0;
+ set x116 0; set x117 0; set x118 0; set x119 0;
+ set x120 0; set x121 0; set x122 0; set x123 0;
+ set x124 0; set x125 0; set x126 0; set x127 0;
+ set x128 0; set x129 0; set x130 0; set x131 0;
+ set x132 0; set x133 0; set x134 0; set x135 0;
+ set x136 0; set x137 0; set x138 0; set x139 0;
+ set x140 0; set x141 0; set x142 0; set x143 0;
+ set x144 0; set x145 0; set x146 0; set x147 0;
+ set x148 0; set x149 0; set x150 0; set x151 0;
+ set x152 0; set x153 0; set x154 0; set x155 0;
+ set x156 0; set x157 0; set x158 0; set x159 0;
+ set x160 0; set x161 0; set x162 0; set x163 0;
+ set x164 0; set x165 0; set x166 0; set x167 0;
+ set x168 0; set x169 0; set x170 0; set x171 0;
+ set x172 0; set x173 0; set x174 0; set x175 0;
+ set x176 0; set x177 0; set x178 0; set x179 0;
+ set x180 0; set x181 0; set x182 0; set x183 0;
+ set x184 0; set x185 0; set x186 0; set x187 0;
+ set x188 0; set x189 0; set x190 0; set x191 0;
+ set x192 0; set x193 0; set x194 0; set x195 0;
+ set x196 0; set x197 0; set x198 0; set x199 0;
+ set x200 0; set x201 0; set x202 0; set x203 0;
+ set x204 0; set x205 0; set x206 0; set x207 0;
+ set x208 0; set x209 0; set x210 0; set x211 0;
+ set x212 0; set x213 0; set x214 0; set x215 0;
+ set x216 0; set x217 0; set x218 0; set x219 0;
+ set x220 0; set x221 0; set x222 0; set x223 0;
+ set x224 0; set x225 0; set x226 0; set x227 0;
+ set x228 0; set x229 0; set x230 0; set x231 0;
+ set x232 0; set x233 0; set x234 0; set x235 0;
+ set x236 0; set x237 0; set x238 0; set x239 0;
+ set x240 0; set x241 0; set x242 0; set x243 0;
+ set x244 0; set x245 0; set x246 0; set x247 0;
+ set x248 0; set x249 0; set x250 0; set x251 0;
+ set x252 0; set x253 0; set x254 0; set x255 0;
+ set y(0) {{1 2} {3 4}}
+ lset y(0) {1 1} 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-2.8 {lset, compiled, list of args, error } {
+ evalInProc {
+ set x { {1 2} {3 4} }
+ lset x {1 5} 5
+ }
+} "1 {list index out of range}"
+
+test lsetComp-2.9 {lset, compiled, list of args, error - is string preserved} {
+ set ::x { { 1 2 } { 3 4 } }
+ evalInProc {
+ lset ::x { 1 5 } 5
+ }
+ list $::x [lindex $::x 1]
+} "{ { 1 2 } { 3 4 } } { 3 4 }"
+
+test lsetComp-3.1 {lset, compiled, flat args, not a simple var name} {
+ evalInProc {
+ set y x
+ set x {{1 2} {3 4}}
+ lset $y 1 1 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-3.2 {lset, compiled, flat args, scalar on stack} {
+ evalInProc {
+ set ::x {{1 2} {3 4}}
+ lset ::x 1 1 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-3.3 {lset, compiled, flat args, scalar, one-byte offset} {
+ evalInProc {
+ set x {{1 2} {3 4}}
+ lset x 1 1 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-3.4 {lset, compiled, scalar, four-byte offset} {
+ evalInProc {
+ set x0 0; set x1 0; set x2 0; set x3 0;
+ set x4 0; set x5 0; set x6 0; set x7 0;
+ set x8 0; set x9 0; set x10 0; set x11 0;
+ set x12 0; set x13 0; set x14 0; set x15 0;
+ set x16 0; set x17 0; set x18 0; set x19 0;
+ set x20 0; set x21 0; set x22 0; set x23 0;
+ set x24 0; set x25 0; set x26 0; set x27 0;
+ set x28 0; set x29 0; set x30 0; set x31 0;
+ set x32 0; set x33 0; set x34 0; set x35 0;
+ set x36 0; set x37 0; set x38 0; set x39 0;
+ set x40 0; set x41 0; set x42 0; set x43 0;
+ set x44 0; set x45 0; set x46 0; set x47 0;
+ set x48 0; set x49 0; set x50 0; set x51 0;
+ set x52 0; set x53 0; set x54 0; set x55 0;
+ set x56 0; set x57 0; set x58 0; set x59 0;
+ set x60 0; set x61 0; set x62 0; set x63 0;
+ set x64 0; set x65 0; set x66 0; set x67 0;
+ set x68 0; set x69 0; set x70 0; set x71 0;
+ set x72 0; set x73 0; set x74 0; set x75 0;
+ set x76 0; set x77 0; set x78 0; set x79 0;
+ set x80 0; set x81 0; set x82 0; set x83 0;
+ set x84 0; set x85 0; set x86 0; set x87 0;
+ set x88 0; set x89 0; set x90 0; set x91 0;
+ set x92 0; set x93 0; set x94 0; set x95 0;
+ set x96 0; set x97 0; set x98 0; set x99 0;
+ set x100 0; set x101 0; set x102 0; set x103 0;
+ set x104 0; set x105 0; set x106 0; set x107 0;
+ set x108 0; set x109 0; set x110 0; set x111 0;
+ set x112 0; set x113 0; set x114 0; set x115 0;
+ set x116 0; set x117 0; set x118 0; set x119 0;
+ set x120 0; set x121 0; set x122 0; set x123 0;
+ set x124 0; set x125 0; set x126 0; set x127 0;
+ set x128 0; set x129 0; set x130 0; set x131 0;
+ set x132 0; set x133 0; set x134 0; set x135 0;
+ set x136 0; set x137 0; set x138 0; set x139 0;
+ set x140 0; set x141 0; set x142 0; set x143 0;
+ set x144 0; set x145 0; set x146 0; set x147 0;
+ set x148 0; set x149 0; set x150 0; set x151 0;
+ set x152 0; set x153 0; set x154 0; set x155 0;
+ set x156 0; set x157 0; set x158 0; set x159 0;
+ set x160 0; set x161 0; set x162 0; set x163 0;
+ set x164 0; set x165 0; set x166 0; set x167 0;
+ set x168 0; set x169 0; set x170 0; set x171 0;
+ set x172 0; set x173 0; set x174 0; set x175 0;
+ set x176 0; set x177 0; set x178 0; set x179 0;
+ set x180 0; set x181 0; set x182 0; set x183 0;
+ set x184 0; set x185 0; set x186 0; set x187 0;
+ set x188 0; set x189 0; set x190 0; set x191 0;
+ set x192 0; set x193 0; set x194 0; set x195 0;
+ set x196 0; set x197 0; set x198 0; set x199 0;
+ set x200 0; set x201 0; set x202 0; set x203 0;
+ set x204 0; set x205 0; set x206 0; set x207 0;
+ set x208 0; set x209 0; set x210 0; set x211 0;
+ set x212 0; set x213 0; set x214 0; set x215 0;
+ set x216 0; set x217 0; set x218 0; set x219 0;
+ set x220 0; set x221 0; set x222 0; set x223 0;
+ set x224 0; set x225 0; set x226 0; set x227 0;
+ set x228 0; set x229 0; set x230 0; set x231 0;
+ set x232 0; set x233 0; set x234 0; set x235 0;
+ set x236 0; set x237 0; set x238 0; set x239 0;
+ set x240 0; set x241 0; set x242 0; set x243 0;
+ set x244 0; set x245 0; set x246 0; set x247 0;
+ set x248 0; set x249 0; set x250 0; set x251 0;
+ set x252 0; set x253 0; set x254 0; set x255 0;
+ set x {{1 2} {3 4}}
+ lset x 1 1 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-3.5 {lset, compiled, flat args, array on stack} {
+ evalInProc {
+ set ::y(0) {{1 2} {3 4}}
+ lset ::y(0) 1 1 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-3.6 {lset, compiled, flat args, array, one-byte offset} {
+ evalInProc {
+ set y(0) {{1 2} {3 4}}
+ lset y(0) 1 1 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-3.7 {lset, compiled, flat args, array, four-byte offset} {
+ evalInProc {
+ set x0 0; set x1 0; set x2 0; set x3 0;
+ set x4 0; set x5 0; set x6 0; set x7 0;
+ set x8 0; set x9 0; set x10 0; set x11 0;
+ set x12 0; set x13 0; set x14 0; set x15 0;
+ set x16 0; set x17 0; set x18 0; set x19 0;
+ set x20 0; set x21 0; set x22 0; set x23 0;
+ set x24 0; set x25 0; set x26 0; set x27 0;
+ set x28 0; set x29 0; set x30 0; set x31 0;
+ set x32 0; set x33 0; set x34 0; set x35 0;
+ set x36 0; set x37 0; set x38 0; set x39 0;
+ set x40 0; set x41 0; set x42 0; set x43 0;
+ set x44 0; set x45 0; set x46 0; set x47 0;
+ set x48 0; set x49 0; set x50 0; set x51 0;
+ set x52 0; set x53 0; set x54 0; set x55 0;
+ set x56 0; set x57 0; set x58 0; set x59 0;
+ set x60 0; set x61 0; set x62 0; set x63 0;
+ set x64 0; set x65 0; set x66 0; set x67 0;
+ set x68 0; set x69 0; set x70 0; set x71 0;
+ set x72 0; set x73 0; set x74 0; set x75 0;
+ set x76 0; set x77 0; set x78 0; set x79 0;
+ set x80 0; set x81 0; set x82 0; set x83 0;
+ set x84 0; set x85 0; set x86 0; set x87 0;
+ set x88 0; set x89 0; set x90 0; set x91 0;
+ set x92 0; set x93 0; set x94 0; set x95 0;
+ set x96 0; set x97 0; set x98 0; set x99 0;
+ set x100 0; set x101 0; set x102 0; set x103 0;
+ set x104 0; set x105 0; set x106 0; set x107 0;
+ set x108 0; set x109 0; set x110 0; set x111 0;
+ set x112 0; set x113 0; set x114 0; set x115 0;
+ set x116 0; set x117 0; set x118 0; set x119 0;
+ set x120 0; set x121 0; set x122 0; set x123 0;
+ set x124 0; set x125 0; set x126 0; set x127 0;
+ set x128 0; set x129 0; set x130 0; set x131 0;
+ set x132 0; set x133 0; set x134 0; set x135 0;
+ set x136 0; set x137 0; set x138 0; set x139 0;
+ set x140 0; set x141 0; set x142 0; set x143 0;
+ set x144 0; set x145 0; set x146 0; set x147 0;
+ set x148 0; set x149 0; set x150 0; set x151 0;
+ set x152 0; set x153 0; set x154 0; set x155 0;
+ set x156 0; set x157 0; set x158 0; set x159 0;
+ set x160 0; set x161 0; set x162 0; set x163 0;
+ set x164 0; set x165 0; set x166 0; set x167 0;
+ set x168 0; set x169 0; set x170 0; set x171 0;
+ set x172 0; set x173 0; set x174 0; set x175 0;
+ set x176 0; set x177 0; set x178 0; set x179 0;
+ set x180 0; set x181 0; set x182 0; set x183 0;
+ set x184 0; set x185 0; set x186 0; set x187 0;
+ set x188 0; set x189 0; set x190 0; set x191 0;
+ set x192 0; set x193 0; set x194 0; set x195 0;
+ set x196 0; set x197 0; set x198 0; set x199 0;
+ set x200 0; set x201 0; set x202 0; set x203 0;
+ set x204 0; set x205 0; set x206 0; set x207 0;
+ set x208 0; set x209 0; set x210 0; set x211 0;
+ set x212 0; set x213 0; set x214 0; set x215 0;
+ set x216 0; set x217 0; set x218 0; set x219 0;
+ set x220 0; set x221 0; set x222 0; set x223 0;
+ set x224 0; set x225 0; set x226 0; set x227 0;
+ set x228 0; set x229 0; set x230 0; set x231 0;
+ set x232 0; set x233 0; set x234 0; set x235 0;
+ set x236 0; set x237 0; set x238 0; set x239 0;
+ set x240 0; set x241 0; set x242 0; set x243 0;
+ set x244 0; set x245 0; set x246 0; set x247 0;
+ set x248 0; set x249 0; set x250 0; set x251 0;
+ set x252 0; set x253 0; set x254 0; set x255 0;
+ set y(0) {{1 2} {3 4}}
+ lset y(0) 1 1 5
+ }
+} "0 {{1 2} {3 5}}"
+
+test lsetComp-3.8 {lset, compiled, flat args, error } {
+ evalInProc {
+ set x { {1 2} {3 4} }
+ lset x 1 5 5
+ }
+} "1 {list index out of range}"
+
+test lsetComp-3.9 {lset, compiled, flat args, error - is string preserved} {
+ set ::x { { 1 2 } { 3 4 } }
+ evalInProc {
+ lset ::x 1 5 5
+ }
+ list $::x [lindex $::x 1]
+} "{ { 1 2 } { 3 4 } } { 3 4 }"
+
+catch { rename evalInProc {} }
+catch { unset ::x }
+catch { unset ::y }
+
+# cleanup
+::tcltest::cleanupTests
+return
diff --git a/tests/obj.test b/tests/obj.test
index 3fffde8..8512049 100644
--- a/tests/obj.test
+++ b/tests/obj.test
@@ -11,7 +11,7 @@
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: obj.test,v 1.5 2000/04/10 17:19:02 ericm Exp $
+# RCS: @(#) $Id: obj.test,v 1.6 2001/11/14 23:16:36 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -27,7 +27,20 @@ if {[info commands testobj] == {}} {
test obj-1.1 {Tcl_AppendAllObjTypes, and InitTypeTable, Tcl_RegisterObjType} {
set r 1
- foreach {t} {list boolean cmdName bytecode string int double} {
+ foreach {t} {
+ {array search}
+ boolean
+ bytearray
+ bytecode
+ double
+ end-offset
+ index
+ int
+ list
+ nsName
+ procbody
+ string
+ } {
set first [string first $t [testobj types]]
set r [expr {$r && ($first != -1)}]
}
@@ -528,20 +541,52 @@ test obj-30.1 {Ref counting and object deletion, simple types} {
lappend result [testobj refcount 2]
} {{} 1024 1024 int 4 4 0 boolean 3 2}
+
+test obj-31.1 {regenerate string rep of "end"} {
+ testobj freeallvars
+ teststringobj set 1 end
+ testobj convert 1 end-offset
+ testobj invalidateStringRep 1
+} end
+
+test obj-31.2 {regenerate string rep of "end-1"} {
+ testobj freeallvars
+ teststringobj set 1 end-0x1
+ testobj convert 1 end-offset
+ testobj invalidateStringRep 1
+} end-1
+
+test obj-31.3 {regenerate string rep of "end--1"} {
+ testobj freeallvars
+ teststringobj set 1 end--0x1
+ testobj convert 1 end-offset
+ testobj invalidateStringRep 1
+} end--1
+
+test obj-31.4 {regenerate string rep of "end-bigInteger"} {
+ testobj freeallvars
+ teststringobj set 1 end-0x7fffffff
+ testobj convert 1 end-offset
+ testobj invalidateStringRep 1
+} end-2147483647
+
+test obj-31.5 {regenerate string rep of "end--bigInteger"} {
+ testobj freeallvars
+ teststringobj set 1 end--0x7fffffff
+ testobj convert 1 end-offset
+ testobj invalidateStringRep 1
+} end--2147483647
+
+
+test obj-31.6 {regenerate string rep of "end--bigInteger"} {nonPortable} {
+ testobj freeallvars
+ teststringobj set 1 end--0x80000000
+ testobj convert 1 end-offset
+ testobj invalidateStringRep 1
+} end--2147483648
+
testobj freeallvars
# cleanup
::tcltest::cleanupTests
return
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/tests/string.test b/tests/string.test
index b869206..15b88d7 100644
--- a/tests/string.test
+++ b/tests/string.test
@@ -7,11 +7,12 @@
# Copyright (c) 1991-1993 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
+# Copyright (c) 2001 by Kevin B. Kenny. All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: string.test,v 1.29 2001/05/14 08:57:26 dkf Exp $
+# RCS: @(#) $Id: string.test,v 1.30 2001/11/14 23:16:36 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -259,7 +260,7 @@ test string-5.17 {string index, bad integer} {
} {1 {bad index "08": must be integer or end?-integer? (looks like invalid octal number)}}
test string-5.18 {string index, bad integer} {
list [catch {string index "abc" end-00289} msg] $msg
-} {1 {expected integer but got "-00289" (looks like invalid octal number)}}
+} {1 {bad index "end-00289": must be integer or end?-integer? (looks like invalid octal number)}}
test string-5.19 {string index, bytearray object out of bounds} {
string index [binary format I* {0x50515253 0x52}] -1
} {}
diff --git a/tests/stringComp.test b/tests/stringComp.test
index fc2214c..a867a19 100644
--- a/tests/stringComp.test
+++ b/tests/stringComp.test
@@ -10,11 +10,12 @@
# their equivalent number in string.test.
#
# Copyright (c) 2001 by ActiveState Corporation.
+# Copyright (c) 2001 by Kevin B. Kenny. All rights reserved.
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
-# RCS: @(#) $Id: stringComp.test,v 1.3 2001/08/25 00:08:46 hobbs Exp $
+# RCS: @(#) $Id: stringComp.test,v 1.4 2001/11/14 23:16:36 hobbs Exp $
if {[lsearch [namespace children] ::tcltest] == -1} {
package require tcltest
@@ -344,7 +345,7 @@ test string-5.17 {string index, bad integer} {
test string-5.18 {string index, bad integer} {
proc foo {} {string index "abc" end-00289}
list [catch {foo} msg] $msg
-} {1 {expected integer but got "-00289" (looks like invalid octal number)}}
+} {1 {bad index "end-00289": must be integer or end?-integer? (looks like invalid octal number)}}
test string-5.19 {string index, bytearray object out of bounds} {
proc foo {} {string index [binary format I* {0x50515253 0x52}] -1}
foo