1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
|
# 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 © 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
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 {index "5" 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 {index "5" 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
|