diff options
Diffstat (limited to 'tests/lset.test')
| -rw-r--r-- | tests/lset.test | 129 |
1 files changed, 32 insertions, 97 deletions
diff --git a/tests/lset.test b/tests/lset.test index 72d68ec..cc1c00b 100644 --- a/tests/lset.test +++ b/tests/lset.test @@ -6,19 +6,16 @@ # built-in commands. Sourcing this file into Tcl runs the tests and # generates output for errors. No output means no errors were found. # -# Copyright © 2001 Kevin B. Kenny. All rights reserved. +# 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. -if {"::tcltest" ni [namespace children]} { - package require tcltest 2.5 +if {[lsearch [namespace children] ::tcltest] == -1} { + package require tcltest namespace import -force ::tcltest::* } -::tcltest::loadTestedCommands -catch [list package require -exact tcl::test [info patchlevel]] - proc failTrace {name1 name2 op} { error "trace failed" } @@ -32,7 +29,7 @@ trace add variable noWrite write failTrace test lset-1.1 {lset, not compiled, arg count} testevalex { list [catch {testevalex lset} msg] $msg -} "1 {wrong \# args: should be \"lset listVar ?index? ?index ...? value\"}" +} "1 {wrong \# args: should be \"lset listVar ?index? ?index...? value\"}" test lset-1.2 {lset, not compiled, no such var} testevalex { list [catch {testevalex {lset noSuchVar 0 {}}} msg] $msg } "1 {can't read \"noSuchVar\": no such variable}" @@ -97,31 +94,25 @@ test lset-4.3 {lset, not compiled, 3 args, index out of range} testevalex { list [catch { testevalex {lset a [list -1] w} } msg] $msg -} {1 {index "-1" out of range}} +} {1 {list index out of range}} test lset-4.4 {lset, not compiled, 3 args, index out of range} testevalex { set a {x y z} list [catch { - testevalex {lset a [list 4] w} - } msg] $msg -} {1 {index "4" out of range}} -test lset-4.5a {lset, not compiled, 3 args, index out of range} testevalex { - set a {x y z} - list [catch { - testevalex {lset a [list end--2] w} + testevalex {lset a [list 3] w} } msg] $msg -} {1 {index "end--2" out of range}} -test lset-4.5b {lset, not compiled, 3 args, index out of range} testevalex { +} {1 {list index out of range}} +test lset-4.5 {lset, not compiled, 3 args, index out of range} testevalex { set a {x y z} list [catch { - testevalex {lset a [list end+2] w} + testevalex {lset a [list end--1] w} } msg] $msg -} {1 {index "end+2" out of range}} +} {1 {list index out of range}} test lset-4.6 {lset, not compiled, 3 args, index out of range} testevalex { set a {x y z} list [catch { testevalex {lset a [list end-3] w} } msg] $msg -} {1 {index "end-3" out of range}} +} {1 {list index out of range}} test lset-4.7 {lset, not compiled, 3 args, not a list} testevalex { set a "x \{" list [catch { @@ -139,31 +130,25 @@ test lset-4.9 {lset, not compiled, 3 args, index out of range} testevalex { list [catch { testevalex {lset a -1 w} } msg] $msg -} {1 {index "-1" out of range}} +} {1 {list index out of range}} test lset-4.10 {lset, not compiled, 3 args, index out of range} testevalex { set a {x y z} list [catch { - testevalex {lset a 4 w} + testevalex {lset a 3 w} } msg] $msg -} {1 {index "4" out of range}} -test lset-4.11a {lset, not compiled, 3 args, index out of range} testevalex { - set a {x y z} - list [catch { - testevalex {lset a end--2 w} - } msg] $msg -} {1 {index "end--2" out of range}} +} {1 {list index out of range}} test lset-4.11 {lset, not compiled, 3 args, index out of range} testevalex { set a {x y z} list [catch { - testevalex {lset a end+2 w} + testevalex {lset a end--1 w} } msg] $msg -} {1 {index "end+2" out of range}} +} {1 {list index out of range}} test lset-4.12 {lset, not compiled, 3 args, index out of range} testevalex { set a {x y z} list [catch { testevalex {lset a end-3 w} } msg] $msg -} {1 {index "end-3" out of range}} +} {1 {list index out of range}} test lset-5.1 {lset, not compiled, 3 args, can't set variable} testevalex { list [catch { @@ -281,43 +266,35 @@ test lset-8.4 {lset, not compiled, bad second index} testevalex { test lset-8.5 {lset, not compiled, second index out of range} testevalex { set a {{b c} {d e} {f g}} list [catch {testevalex {lset a 2 -1 h}} msg] $msg -} {1 {index "-1" out of range}} +} {1 {list index out of range}} test lset-8.6 {lset, not compiled, second index out of range} testevalex { set a {{b c} {d e} {f g}} list [catch {testevalex {lset a {2 -1} h}} msg] $msg -} {1 {index "-1" out of range}} +} {1 {list index out of range}} test lset-8.7 {lset, not compiled, second index out of range} testevalex { set a {{b c} {d e} {f g}} - list [catch {testevalex {lset a 2 3 h}} msg] $msg -} {1 {index "3" out of range}} + list [catch {testevalex {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} testevalex { set a {{b c} {d e} {f g}} - list [catch {testevalex {lset a {2 3} h}} msg] $msg -} {1 {index "3" out of range}} -test lset-8.9a {lset, not compiled, second index out of range} testevalex { - set a {{b c} {d e} {f g}} - list [catch {testevalex {lset a 2 end--2 h}} msg] $msg -} {1 {index "end--2" out of range}} -test lset-8.9b {lset, not compiled, second index out of range} testevalex { - set a {{b c} {d e} {f g}} - list [catch {testevalex {lset a 2 end+2 h}} msg] $msg -} {1 {index "end+2" out of range}} -test lset-8.10a {lset, not compiled, second index out of range} testevalex { + list [catch {testevalex {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} testevalex { set a {{b c} {d e} {f g}} - list [catch {testevalex {lset a {2 end--2} h}} msg] $msg -} {1 {index "end--2" out of range}} -test lset-8.10b {lset, not compiled, second index out of range} testevalex { + list [catch {testevalex {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} testevalex { set a {{b c} {d e} {f g}} - list [catch {testevalex {lset a {2 end+2} h}} msg] $msg -} {1 {index "end+2" out of range}} + list [catch {testevalex {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} testevalex { set a {{b c} {d e} {f g}} list [catch {testevalex {lset a 2 end-2 h}} msg] $msg -} {1 {index "end-2" out of range}} +} {1 {list index out of range}} test lset-8.12 {lset, not compiled, second index out of range} testevalex { set a {{b c} {d e} {f g}} list [catch {testevalex {lset a {2 end-2} h}} msg] $msg -} {1 {index "end-2" out of range}} +} {1 {list index out of range}} test lset-9.1 {lset, not compiled, entire variable} testevalex { set a x @@ -412,7 +389,7 @@ test lset-14.2 {lset, not compiled, flat args, is string rep preserved?} testeva } "{ { 1 2 } { 3 4 } } { 3 4 }" testConstraint testobj [llength [info commands testobj]] -test lset-15.1 {lset: shared internalrep [Bug 1677512]} -setup { +test lset-15.1 {lset: shared intrep [Bug 1677512]} -setup { teststringobj set 1 {{1 2} 3} testobj convert 1 list testobj duplicate 1 2 @@ -428,48 +405,6 @@ test lset-15.1 {lset: shared internalrep [Bug 1677512]} -setup { unset -nocomplain x l } -result 1 -test lset-16.1 {lset - grow a variable} testevalex { - set x {} - testevalex {lset x 0 {test 1}} - testevalex {lset x 1 {test 2}} - set x -} {{test 1} {test 2}} -test lset-16.2 {lset - multiple created sublists} testevalex { - set x {} - testevalex {lset x 0 0 {test 1}} -} {{{test 1}}} -test lset-16.3 {lset - sublists 3 deep} testevalex { - set x {} - testevalex {lset x 0 0 0 {test 1}} -} {{{{test 1}}}} -test lset-16.4 {lset - append to inner list} testevalex { - set x {test 1} - testevalex {lset x 1 1 2} - testevalex {lset x 1 2 3} - testevalex {lset x 1 2 1 4} -} {test {1 2 {3 4}}} - -test lset-16.5 {lset - grow a variable} testevalex { - set x {} - testevalex {lset x end+1 {test 1}} - testevalex {lset x end+1 {test 2}} - set x -} {{test 1} {test 2}} -test lset-16.6 {lset - multiple created sublists} testevalex { - set x {} - testevalex {lset x end+1 end+1 {test 1}} -} {{{test 1}}} -test lset-16.7 {lset - sublists 3 deep} testevalex { - set x {} - testevalex {lset x end+1 end+1 end+1 {test 1}} -} {{{{test 1}}}} -test lset-16.8 {lset - append to inner list} testevalex { - set x {test 1} - testevalex {lset x end end+1 2} - testevalex {lset x end end+1 3} - testevalex {lset x end end end+1 4} -} {test {1 2 {3 4}}} - catch {unset noRead} catch {unset noWrite} catch {rename failTrace {}} |
