[25] | 1 | # This file is a -*- tcl -*- test script |
---|
| 2 | |
---|
| 3 | # Commands covered: lset |
---|
| 4 | # |
---|
| 5 | # This file contains a collection of tests for one or more of the Tcl |
---|
| 6 | # built-in commands. Sourcing this file into Tcl runs the tests and |
---|
| 7 | # generates output for errors. No output means no errors were found. |
---|
| 8 | # |
---|
| 9 | # Copyright (c) 2001 by Kevin B. Kenny. All rights reserved. |
---|
| 10 | # |
---|
| 11 | # See the file "license.terms" for information on usage and redistribution |
---|
| 12 | # of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
| 13 | # |
---|
| 14 | # RCS: @(#) $Id$ |
---|
| 15 | |
---|
| 16 | if {[lsearch [namespace children] ::tcltest] == -1} { |
---|
| 17 | package require tcltest |
---|
| 18 | namespace import -force ::tcltest::* |
---|
| 19 | } |
---|
| 20 | |
---|
| 21 | proc failTrace {name1 name2 op} { |
---|
| 22 | error "trace failed" |
---|
| 23 | } |
---|
| 24 | |
---|
| 25 | testConstraint testevalex [llength [info commands testevalex]] |
---|
| 26 | |
---|
| 27 | set noRead {} |
---|
| 28 | trace add variable noRead read failTrace |
---|
| 29 | set noWrite {a b c} |
---|
| 30 | trace add variable noWrite write failTrace |
---|
| 31 | |
---|
| 32 | test lset-1.1 {lset, not compiled, arg count} testevalex { |
---|
| 33 | list [catch {testevalex lset} msg] $msg |
---|
| 34 | } "1 {wrong \# args: should be \"lset listVar index ?index...? value\"}" |
---|
| 35 | test lset-1.2 {lset, not compiled, no such var} testevalex { |
---|
| 36 | list [catch {testevalex {lset noSuchVar 0 {}}} msg] $msg |
---|
| 37 | } "1 {can't read \"noSuchVar\": no such variable}" |
---|
| 38 | test lset-1.3 {lset, not compiled, var not readable} testevalex { |
---|
| 39 | list [catch {testevalex {lset noRead 0 {}}} msg] $msg |
---|
| 40 | } "1 {can't read \"noRead\": trace failed}" |
---|
| 41 | |
---|
| 42 | test lset-2.1 {lset, not compiled, 3 args, second arg a plain index} testevalex { |
---|
| 43 | set x {0 1 2} |
---|
| 44 | list [testevalex {lset x 0 3}] $x |
---|
| 45 | } {{3 1 2} {3 1 2}} |
---|
| 46 | test lset-2.2 {lset, not compiled, 3 args, second arg neither index nor list} testevalex { |
---|
| 47 | set x {0 1 2} |
---|
| 48 | list [catch { |
---|
| 49 | testevalex {lset x {{bad}1} 3} |
---|
| 50 | } msg] $msg |
---|
| 51 | } {1 {bad index "{bad}1": must be integer?[+-]integer? or end?[+-]integer?}} |
---|
| 52 | |
---|
| 53 | test lset-3.1 {lset, not compiled, 3 args, data duplicated} testevalex { |
---|
| 54 | set x {0 1 2} |
---|
| 55 | list [testevalex {lset x 0 $x}] $x |
---|
| 56 | } {{{0 1 2} 1 2} {{0 1 2} 1 2}} |
---|
| 57 | test lset-3.2 {lset, not compiled, 3 args, data duplicated} testevalex { |
---|
| 58 | set x {0 1} |
---|
| 59 | set y $x |
---|
| 60 | list [testevalex {lset x 0 2}] $x $y |
---|
| 61 | } {{2 1} {2 1} {0 1}} |
---|
| 62 | test lset-3.3 {lset, not compiled, 3 args, data duplicated} testevalex { |
---|
| 63 | set x {0 1} |
---|
| 64 | set y $x |
---|
| 65 | list [testevalex {lset x 0 $x}] $x $y |
---|
| 66 | } {{{0 1} 1} {{0 1} 1} {0 1}} |
---|
| 67 | test lset-3.4 {lset, not compiled, 3 args, data duplicated} testevalex { |
---|
| 68 | set x {0 1 2} |
---|
| 69 | list [testevalex {lset x [list 0] $x}] $x |
---|
| 70 | } {{{0 1 2} 1 2} {{0 1 2} 1 2}} |
---|
| 71 | test lset-3.5 {lset, not compiled, 3 args, data duplicated} testevalex { |
---|
| 72 | set x {0 1} |
---|
| 73 | set y $x |
---|
| 74 | list [testevalex {lset x [list 0] 2}] $x $y |
---|
| 75 | } {{2 1} {2 1} {0 1}} |
---|
| 76 | test lset-3.6 {lset, not compiled, 3 args, data duplicated} testevalex { |
---|
| 77 | set x {0 1} |
---|
| 78 | set y $x |
---|
| 79 | list [testevalex {lset x [list 0] $x}] $x $y |
---|
| 80 | } {{{0 1} 1} {{0 1} 1} {0 1}} |
---|
| 81 | |
---|
| 82 | test lset-4.1 {lset, not compiled, 3 args, not a list} testevalex { |
---|
| 83 | set a "x \{" |
---|
| 84 | list [catch { |
---|
| 85 | testevalex {lset a [list 0] y} |
---|
| 86 | } msg] $msg |
---|
| 87 | } {1 {unmatched open brace in list}} |
---|
| 88 | test lset-4.2 {lset, not compiled, 3 args, bad index} testevalex { |
---|
| 89 | set a {x y z} |
---|
| 90 | list [catch { |
---|
| 91 | testevalex {lset a [list 2a2] w} |
---|
| 92 | } msg] $msg |
---|
| 93 | } {1 {bad index "2a2": must be integer?[+-]integer? or end?[+-]integer?}} |
---|
| 94 | test lset-4.3 {lset, not compiled, 3 args, index out of range} testevalex { |
---|
| 95 | set a {x y z} |
---|
| 96 | list [catch { |
---|
| 97 | testevalex {lset a [list -1] w} |
---|
| 98 | } msg] $msg |
---|
| 99 | } {1 {list index out of range}} |
---|
| 100 | test lset-4.4 {lset, not compiled, 3 args, index out of range} testevalex { |
---|
| 101 | set a {x y z} |
---|
| 102 | list [catch { |
---|
| 103 | testevalex {lset a [list 3] w} |
---|
| 104 | } msg] $msg |
---|
| 105 | } {1 {list index out of range}} |
---|
| 106 | test lset-4.5 {lset, not compiled, 3 args, index out of range} testevalex { |
---|
| 107 | set a {x y z} |
---|
| 108 | list [catch { |
---|
| 109 | testevalex {lset a [list end--1] w} |
---|
| 110 | } msg] $msg |
---|
| 111 | } {1 {list index out of range}} |
---|
| 112 | test lset-4.6 {lset, not compiled, 3 args, index out of range} testevalex { |
---|
| 113 | set a {x y z} |
---|
| 114 | list [catch { |
---|
| 115 | testevalex {lset a [list end-3] w} |
---|
| 116 | } msg] $msg |
---|
| 117 | } {1 {list index out of range}} |
---|
| 118 | test lset-4.7 {lset, not compiled, 3 args, not a list} testevalex { |
---|
| 119 | set a "x \{" |
---|
| 120 | list [catch { |
---|
| 121 | testevalex {lset a 0 y} |
---|
| 122 | } msg] $msg |
---|
| 123 | } {1 {unmatched open brace in list}} |
---|
| 124 | test lset-4.8 {lset, not compiled, 3 args, bad index} testevalex { |
---|
| 125 | set a {x y z} |
---|
| 126 | list [catch { |
---|
| 127 | testevalex {lset a 2a2 w} |
---|
| 128 | } msg] $msg |
---|
| 129 | } {1 {bad index "2a2": must be integer?[+-]integer? or end?[+-]integer?}} |
---|
| 130 | test lset-4.9 {lset, not compiled, 3 args, index out of range} testevalex { |
---|
| 131 | set a {x y z} |
---|
| 132 | list [catch { |
---|
| 133 | testevalex {lset a -1 w} |
---|
| 134 | } msg] $msg |
---|
| 135 | } {1 {list index out of range}} |
---|
| 136 | test lset-4.10 {lset, not compiled, 3 args, index out of range} testevalex { |
---|
| 137 | set a {x y z} |
---|
| 138 | list [catch { |
---|
| 139 | testevalex {lset a 3 w} |
---|
| 140 | } msg] $msg |
---|
| 141 | } {1 {list index out of range}} |
---|
| 142 | test lset-4.11 {lset, not compiled, 3 args, index out of range} testevalex { |
---|
| 143 | set a {x y z} |
---|
| 144 | list [catch { |
---|
| 145 | testevalex {lset a end--1 w} |
---|
| 146 | } msg] $msg |
---|
| 147 | } {1 {list index out of range}} |
---|
| 148 | test lset-4.12 {lset, not compiled, 3 args, index out of range} testevalex { |
---|
| 149 | set a {x y z} |
---|
| 150 | list [catch { |
---|
| 151 | testevalex {lset a end-3 w} |
---|
| 152 | } msg] $msg |
---|
| 153 | } {1 {list index out of range}} |
---|
| 154 | |
---|
| 155 | test lset-5.1 {lset, not compiled, 3 args, can't set variable} testevalex { |
---|
| 156 | list [catch { |
---|
| 157 | testevalex {lset noWrite 0 d} |
---|
| 158 | } msg] $msg $noWrite |
---|
| 159 | } {1 {can't set "noWrite": trace failed} {d b c}} |
---|
| 160 | test lset-5.2 {lset, not compiled, 3 args, can't set variable} testevalex { |
---|
| 161 | list [catch { |
---|
| 162 | testevalex {lset noWrite [list 0] d} |
---|
| 163 | } msg] $msg $noWrite |
---|
| 164 | } {1 {can't set "noWrite": trace failed} {d b c}} |
---|
| 165 | |
---|
| 166 | test lset-6.1 {lset, not compiled, 3 args, 1-d list basics} testevalex { |
---|
| 167 | set a {x y z} |
---|
| 168 | list [testevalex {lset a 0 a}] $a |
---|
| 169 | } {{a y z} {a y z}} |
---|
| 170 | test lset-6.2 {lset, not compiled, 3 args, 1-d list basics} testevalex { |
---|
| 171 | set a {x y z} |
---|
| 172 | list [testevalex {lset a [list 0] a}] $a |
---|
| 173 | } {{a y z} {a y z}} |
---|
| 174 | test lset-6.3 {lset, not compiled, 1-d list basics} testevalex { |
---|
| 175 | set a {x y z} |
---|
| 176 | list [testevalex {lset a 2 a}] $a |
---|
| 177 | } {{x y a} {x y a}} |
---|
| 178 | test lset-6.4 {lset, not compiled, 1-d list basics} testevalex { |
---|
| 179 | set a {x y z} |
---|
| 180 | list [testevalex {lset a [list 2] a}] $a |
---|
| 181 | } {{x y a} {x y a}} |
---|
| 182 | test lset-6.5 {lset, not compiled, 1-d list basics} testevalex { |
---|
| 183 | set a {x y z} |
---|
| 184 | list [testevalex {lset a end a}] $a |
---|
| 185 | } {{x y a} {x y a}} |
---|
| 186 | test lset-6.6 {lset, not compiled, 1-d list basics} testevalex { |
---|
| 187 | set a {x y z} |
---|
| 188 | list [testevalex {lset a [list end] a}] $a |
---|
| 189 | } {{x y a} {x y a}} |
---|
| 190 | test lset-6.7 {lset, not compiled, 1-d list basics} testevalex { |
---|
| 191 | set a {x y z} |
---|
| 192 | list [testevalex {lset a end-0 a}] $a |
---|
| 193 | } {{x y a} {x y a}} |
---|
| 194 | test lset-6.8 {lset, not compiled, 1-d list basics} testevalex { |
---|
| 195 | set a {x y z} |
---|
| 196 | list [testevalex {lset a [list end-0] a}] $a |
---|
| 197 | } {{x y a} {x y a}} |
---|
| 198 | test lset-6.9 {lset, not compiled, 1-d list basics} testevalex { |
---|
| 199 | set a {x y z} |
---|
| 200 | list [testevalex {lset a end-2 a}] $a |
---|
| 201 | } {{a y z} {a y z}} |
---|
| 202 | test lset-6.10 {lset, not compiled, 1-d list basics} testevalex { |
---|
| 203 | set a {x y z} |
---|
| 204 | list [testevalex {lset a [list end-2] a}] $a |
---|
| 205 | } {{a y z} {a y z}} |
---|
| 206 | |
---|
| 207 | test lset-7.1 {lset, not compiled, data sharing} testevalex { |
---|
| 208 | set a 0 |
---|
| 209 | list [testevalex {lset a $a {gag me}}] $a |
---|
| 210 | } {{{gag me}} {{gag me}}} |
---|
| 211 | test lset-7.2 {lset, not compiled, data sharing} testevalex { |
---|
| 212 | set a [list 0] |
---|
| 213 | list [testevalex {lset a $a {gag me}}] $a |
---|
| 214 | } {{{gag me}} {{gag me}}} |
---|
| 215 | test lset-7.3 {lset, not compiled, data sharing} testevalex { |
---|
| 216 | set a {x y} |
---|
| 217 | list [testevalex {lset a 0 $a}] $a |
---|
| 218 | } {{{x y} y} {{x y} y}} |
---|
| 219 | test lset-7.4 {lset, not compiled, data sharing} testevalex { |
---|
| 220 | set a {x y} |
---|
| 221 | list [testevalex {lset a [list 0] $a}] $a |
---|
| 222 | } {{{x y} y} {{x y} y}} |
---|
| 223 | test lset-7.5 {lset, not compiled, data sharing} testevalex { |
---|
| 224 | set n 0 |
---|
| 225 | set a {x y} |
---|
| 226 | list [testevalex {lset a $n $n}] $a $n |
---|
| 227 | } {{0 y} {0 y} 0} |
---|
| 228 | test lset-7.6 {lset, not compiled, data sharing} testevalex { |
---|
| 229 | set n [list 0] |
---|
| 230 | set a {x y} |
---|
| 231 | list [testevalex {lset a $n $n}] $a $n |
---|
| 232 | } {{0 y} {0 y} 0} |
---|
| 233 | test lset-7.7 {lset, not compiled, data sharing} testevalex { |
---|
| 234 | set n 0 |
---|
| 235 | set a [list $n $n] |
---|
| 236 | list [testevalex {lset a $n 1}] $a $n |
---|
| 237 | } {{1 0} {1 0} 0} |
---|
| 238 | test lset-7.8 {lset, not compiled, data sharing} testevalex { |
---|
| 239 | set n [list 0] |
---|
| 240 | set a [list $n $n] |
---|
| 241 | list [testevalex {lset a $n 1}] $a $n |
---|
| 242 | } {{1 0} {1 0} 0} |
---|
| 243 | test lset-7.9 {lset, not compiled, data sharing} testevalex { |
---|
| 244 | set a 0 |
---|
| 245 | list [testevalex {lset a $a $a}] $a |
---|
| 246 | } {0 0} |
---|
| 247 | test lset-7.10 {lset, not compiled, data sharing} testevalex { |
---|
| 248 | set a [list 0] |
---|
| 249 | list [testevalex {lset a $a $a}] $a |
---|
| 250 | } {0 0} |
---|
| 251 | |
---|
| 252 | test lset-8.1 {lset, not compiled, malformed sublist} testevalex { |
---|
| 253 | set a [list "a \{" b] |
---|
| 254 | list [catch {testevalex {lset a 0 1 c}} msg] $msg |
---|
| 255 | } {1 {unmatched open brace in list}} |
---|
| 256 | test lset-8.2 {lset, not compiled, malformed sublist} testevalex { |
---|
| 257 | set a [list "a \{" b] |
---|
| 258 | list [catch {testevalex {lset a {0 1} c}} msg] $msg |
---|
| 259 | } {1 {unmatched open brace in list}} |
---|
| 260 | test lset-8.3 {lset, not compiled, bad second index} testevalex { |
---|
| 261 | set a {{b c} {d e}} |
---|
| 262 | list [catch {testevalex {lset a 0 2a2 f}} msg] $msg |
---|
| 263 | } {1 {bad index "2a2": must be integer?[+-]integer? or end?[+-]integer?}} |
---|
| 264 | test lset-8.4 {lset, not compiled, bad second index} testevalex { |
---|
| 265 | set a {{b c} {d e}} |
---|
| 266 | list [catch {testevalex {lset a {0 2a2} f}} msg] $msg |
---|
| 267 | } {1 {bad index "2a2": must be integer?[+-]integer? or end?[+-]integer?}} |
---|
| 268 | test lset-8.5 {lset, not compiled, second index out of range} testevalex { |
---|
| 269 | set a {{b c} {d e} {f g}} |
---|
| 270 | list [catch {testevalex {lset a 2 -1 h}} msg] $msg |
---|
| 271 | } {1 {list index out of range}} |
---|
| 272 | test lset-8.6 {lset, not compiled, second index out of range} testevalex { |
---|
| 273 | set a {{b c} {d e} {f g}} |
---|
| 274 | list [catch {testevalex {lset a {2 -1} h}} msg] $msg |
---|
| 275 | } {1 {list index out of range}} |
---|
| 276 | test lset-8.7 {lset, not compiled, second index out of range} testevalex { |
---|
| 277 | set a {{b c} {d e} {f g}} |
---|
| 278 | list [catch {testevalex {lset a 2 2 h}} msg] $msg |
---|
| 279 | } {1 {list index out of range}} |
---|
| 280 | test lset-8.8 {lset, not compiled, second index out of range} testevalex { |
---|
| 281 | set a {{b c} {d e} {f g}} |
---|
| 282 | list [catch {testevalex {lset a {2 2} h}} msg] $msg |
---|
| 283 | } {1 {list index out of range}} |
---|
| 284 | test lset-8.9 {lset, not compiled, second index out of range} testevalex { |
---|
| 285 | set a {{b c} {d e} {f g}} |
---|
| 286 | list [catch {testevalex {lset a 2 end--1 h}} msg] $msg |
---|
| 287 | } {1 {list index out of range}} |
---|
| 288 | test lset-8.10 {lset, not compiled, second index out of range} testevalex { |
---|
| 289 | set a {{b c} {d e} {f g}} |
---|
| 290 | list [catch {testevalex {lset a {2 end--1} h}} msg] $msg |
---|
| 291 | } {1 {list index out of range}} |
---|
| 292 | test lset-8.11 {lset, not compiled, second index out of range} testevalex { |
---|
| 293 | set a {{b c} {d e} {f g}} |
---|
| 294 | list [catch {testevalex {lset a 2 end-2 h}} msg] $msg |
---|
| 295 | } {1 {list index out of range}} |
---|
| 296 | test lset-8.12 {lset, not compiled, second index out of range} testevalex { |
---|
| 297 | set a {{b c} {d e} {f g}} |
---|
| 298 | list [catch {testevalex {lset a {2 end-2} h}} msg] $msg |
---|
| 299 | } {1 {list index out of range}} |
---|
| 300 | |
---|
| 301 | test lset-9.1 {lset, not compiled, entire variable} testevalex { |
---|
| 302 | set a x |
---|
| 303 | list [testevalex {lset a y}] $a |
---|
| 304 | } {y y} |
---|
| 305 | test lset-9.2 {lset, not compiled, entire variable} testevalex { |
---|
| 306 | set a x |
---|
| 307 | list [testevalex {lset a {} y}] $a |
---|
| 308 | } {y y} |
---|
| 309 | |
---|
| 310 | test lset-10.1 {lset, not compiled, shared data} testevalex { |
---|
| 311 | set row {p q} |
---|
| 312 | set a [list $row $row] |
---|
| 313 | list [testevalex {lset a 0 0 x}] $a |
---|
| 314 | } {{{x q} {p q}} {{x q} {p q}}} |
---|
| 315 | test lset-10.2 {lset, not compiled, shared data} testevalex { |
---|
| 316 | set row {p q} |
---|
| 317 | set a [list $row $row] |
---|
| 318 | list [testevalex {lset a {0 0} x}] $a |
---|
| 319 | } {{{x q} {p q}} {{x q} {p q}}} |
---|
| 320 | test lset-10.3 {lset, not compiled, shared data, [Bug 1333036]} testevalex { |
---|
| 321 | set a [list [list p q] [list r s]] |
---|
| 322 | set b $a |
---|
| 323 | list [testevalex {lset b {0 0} x}] $a |
---|
| 324 | } {{{x q} {r s}} {{p q} {r s}}} |
---|
| 325 | |
---|
| 326 | test lset-11.1 {lset, not compiled, 2-d basics} testevalex { |
---|
| 327 | set a {{b c} {d e}} |
---|
| 328 | list [testevalex {lset a 0 0 f}] $a |
---|
| 329 | } {{{f c} {d e}} {{f c} {d e}}} |
---|
| 330 | test lset-11.2 {lset, not compiled, 2-d basics} testevalex { |
---|
| 331 | set a {{b c} {d e}} |
---|
| 332 | list [testevalex {lset a {0 0} f}] $a |
---|
| 333 | } {{{f c} {d e}} {{f c} {d e}}} |
---|
| 334 | test lset-11.3 {lset, not compiled, 2-d basics} testevalex { |
---|
| 335 | set a {{b c} {d e}} |
---|
| 336 | list [testevalex {lset a 0 1 f}] $a |
---|
| 337 | } {{{b f} {d e}} {{b f} {d e}}} |
---|
| 338 | test lset-11.4 {lset, not compiled, 2-d basics} testevalex { |
---|
| 339 | set a {{b c} {d e}} |
---|
| 340 | list [testevalex {lset a {0 1} f}] $a |
---|
| 341 | } {{{b f} {d e}} {{b f} {d e}}} |
---|
| 342 | test lset-11.5 {lset, not compiled, 2-d basics} testevalex { |
---|
| 343 | set a {{b c} {d e}} |
---|
| 344 | list [testevalex {lset a 1 0 f}] $a |
---|
| 345 | } {{{b c} {f e}} {{b c} {f e}}} |
---|
| 346 | test lset-11.6 {lset, not compiled, 2-d basics} testevalex { |
---|
| 347 | set a {{b c} {d e}} |
---|
| 348 | list [testevalex {lset a {1 0} f}] $a |
---|
| 349 | } {{{b c} {f e}} {{b c} {f e}}} |
---|
| 350 | test lset-11.7 {lset, not compiled, 2-d basics} testevalex { |
---|
| 351 | set a {{b c} {d e}} |
---|
| 352 | list [testevalex {lset a 1 1 f}] $a |
---|
| 353 | } {{{b c} {d f}} {{b c} {d f}}} |
---|
| 354 | test lset-11.8 {lset, not compiled, 2-d basics} testevalex { |
---|
| 355 | set a {{b c} {d e}} |
---|
| 356 | list [testevalex {lset a {1 1} f}] $a |
---|
| 357 | } {{{b c} {d f}} {{b c} {d f}}} |
---|
| 358 | |
---|
| 359 | test lset-12.0 {lset, not compiled, typical sharing pattern} testevalex { |
---|
| 360 | set zero 0 |
---|
| 361 | set row [list $zero $zero $zero $zero] |
---|
| 362 | set ident [list $row $row $row $row] |
---|
| 363 | for { set i 0 } { $i < 4 } { incr i } { |
---|
| 364 | testevalex {lset ident $i $i 1} |
---|
| 365 | } |
---|
| 366 | set ident |
---|
| 367 | } {{1 0 0 0} {0 1 0 0} {0 0 1 0} {0 0 0 1}} |
---|
| 368 | |
---|
| 369 | test lset-13.0 {lset, not compiled, shimmering hell} testevalex { |
---|
| 370 | set a 0 |
---|
| 371 | list [testevalex {lset a $a $a $a $a {gag me}}] $a |
---|
| 372 | } {{{{{{gag me}}}}} {{{{{gag me}}}}}} |
---|
| 373 | test lset-13.1 {lset, not compiled, shimmering hell} testevalex { |
---|
| 374 | set a [list 0] |
---|
| 375 | list [testevalex {lset a $a $a $a $a {gag me}}] $a |
---|
| 376 | } {{{{{{gag me}}}}} {{{{{gag me}}}}}} |
---|
| 377 | test lset-13.2 {lset, not compiled, shimmering hell} testevalex { |
---|
| 378 | set a [list 0 0 0 0] |
---|
| 379 | list [testevalex {lset a $a {gag me}}] $a |
---|
| 380 | } {{{{{{gag me}}}} 0 0 0} {{{{{gag me}}}} 0 0 0}} |
---|
| 381 | |
---|
| 382 | test lset-14.1 {lset, not compiled, list args, is string rep preserved?} testevalex { |
---|
| 383 | set a { { 1 2 } { 3 4 } } |
---|
| 384 | catch { testevalex {lset a {1 5} 5} } |
---|
| 385 | list $a [lindex $a 1] |
---|
| 386 | } "{ { 1 2 } { 3 4 } } { 3 4 }" |
---|
| 387 | test lset-14.2 {lset, not compiled, flat args, is string rep preserved?} testevalex { |
---|
| 388 | set a { { 1 2 } { 3 4 } } |
---|
| 389 | catch { testevalex {lset a 1 5 5} } |
---|
| 390 | list $a [lindex $a 1] |
---|
| 391 | } "{ { 1 2 } { 3 4 } } { 3 4 }" |
---|
| 392 | |
---|
| 393 | testConstraint testobj [llength [info commands testobj]] |
---|
| 394 | test lset-15.1 {lset: shared intrep [Bug 1677512]} -setup { |
---|
| 395 | teststringobj set 1 {{1 2} 3} |
---|
| 396 | testobj convert 1 list |
---|
| 397 | testobj duplicate 1 2 |
---|
| 398 | variable x [teststringobj get 1] |
---|
| 399 | variable y [teststringobj get 2] |
---|
| 400 | testobj freeallvars |
---|
| 401 | set l [list $y z] |
---|
| 402 | unset y |
---|
| 403 | } -constraints testobj -body { |
---|
| 404 | lset l 0 0 0 5 |
---|
| 405 | lindex $x 0 0 |
---|
| 406 | } -cleanup { |
---|
| 407 | unset -nocomplain x l |
---|
| 408 | } -result 1 |
---|
| 409 | |
---|
| 410 | catch {unset noRead} |
---|
| 411 | catch {unset noWrite} |
---|
| 412 | catch {rename failTrace {}} |
---|
| 413 | catch {unset ::x} |
---|
| 414 | catch {unset ::y} |
---|
| 415 | |
---|
| 416 | # cleanup |
---|
| 417 | ::tcltest::cleanupTests |
---|
| 418 | return |
---|