os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/set.test
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
# Commands covered:  set
sl@0
     2
#
sl@0
     3
# This file contains a collection of tests for one or more of the Tcl
sl@0
     4
# built-in commands.  Sourcing this file into Tcl runs the tests and
sl@0
     5
# generates output for errors.  No output means no errors were found.
sl@0
     6
#
sl@0
     7
# Copyright (c) 1996 Sun Microsystems, Inc.
sl@0
     8
# Copyright (c) 1998-1999 by Scriptics Corporation.
sl@0
     9
#
sl@0
    10
# See the file "license.terms" for information on usage and redistribution
sl@0
    11
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
sl@0
    12
#
sl@0
    13
# RCS: @(#) $Id: set.test,v 1.8 2000/04/10 17:19:04 ericm Exp $
sl@0
    14
sl@0
    15
if {[lsearch [namespace children] ::tcltest] == -1} {
sl@0
    16
    package require tcltest
sl@0
    17
    namespace import -force ::tcltest::*
sl@0
    18
}
sl@0
    19
sl@0
    20
catch {unset x}
sl@0
    21
catch {unset i}
sl@0
    22
sl@0
    23
test set-1.1 {TclCompileSetCmd: missing variable name} {
sl@0
    24
    list [catch {set} msg] $msg
sl@0
    25
} {1 {wrong # args: should be "set varName ?newValue?"}}
sl@0
    26
test set-1.2 {TclCompileSetCmd: simple variable name} {
sl@0
    27
    set i 10
sl@0
    28
    list [set i] $i
sl@0
    29
} {10 10}
sl@0
    30
test set-1.3 {TclCompileSetCmd: error compiling variable name} {
sl@0
    31
    set i 10
sl@0
    32
    catch {set "i"xxx} msg
sl@0
    33
    set msg
sl@0
    34
} {extra characters after close-quote}
sl@0
    35
test set-1.4 {TclCompileSetCmd: simple variable name in quotes} {
sl@0
    36
    set i 17
sl@0
    37
    list [set "i"] $i
sl@0
    38
} {17 17}
sl@0
    39
test set-1.5 {TclCompileSetCmd: simple variable name in braces} {
sl@0
    40
    catch {unset {a simple var}}
sl@0
    41
    set {a simple var} 27
sl@0
    42
    list [set {a simple var}] ${a simple var}
sl@0
    43
} {27 27}
sl@0
    44
test set-1.6 {TclCompileSetCmd: simple array variable name} {
sl@0
    45
    catch {unset a}
sl@0
    46
    set a(foo) 37
sl@0
    47
    list [set a(foo)] $a(foo)
sl@0
    48
} {37 37}
sl@0
    49
test set-1.7 {TclCompileSetCmd: non-simple (computed) variable name} {
sl@0
    50
    set x "i"
sl@0
    51
    set i 77
sl@0
    52
    list [set $x] $i
sl@0
    53
} {77 77}
sl@0
    54
test set-1.8 {TclCompileSetCmd: non-simple (computed) variable name} {
sl@0
    55
    set x "i"
sl@0
    56
    set i 77
sl@0
    57
    list [set [set x] 2] $i
sl@0
    58
} {2 2}
sl@0
    59
sl@0
    60
test set-1.9 {TclCompileSetCmd: 3rd arg => assignment} {
sl@0
    61
    set i "abcdef"
sl@0
    62
    list [set i] $i
sl@0
    63
} {abcdef abcdef}
sl@0
    64
test set-1.10 {TclCompileSetCmd: only two args => just getting value} {
sl@0
    65
    set i {one two}
sl@0
    66
    set i
sl@0
    67
} {one two}
sl@0
    68
sl@0
    69
test set-1.11 {TclCompileSetCmd: simple global name} {
sl@0
    70
    proc p {} {
sl@0
    71
        global i
sl@0
    72
        set i 54
sl@0
    73
        set i
sl@0
    74
    }
sl@0
    75
    p
sl@0
    76
} {54}
sl@0
    77
test set-1.12 {TclCompileSetCmd: simple local name} {
sl@0
    78
    proc p {bar} {
sl@0
    79
        set foo $bar
sl@0
    80
        set foo
sl@0
    81
    }
sl@0
    82
    p 999
sl@0
    83
} {999}
sl@0
    84
test set-1.13 {TclCompileSetCmd: simple but new (unknown) local name} {
sl@0
    85
    proc p {} {
sl@0
    86
        set bar
sl@0
    87
    }
sl@0
    88
    catch {p} msg
sl@0
    89
    set msg
sl@0
    90
} {can't read "bar": no such variable}
sl@0
    91
test set-1.14 {TclCompileSetCmd: simple local name, >255 locals} {
sl@0
    92
    proc 260locals {} {
sl@0
    93
        # create 260 locals (the last ones with index > 255)
sl@0
    94
        set a0 0; set a1 0; set a2 0; set a3 0; set a4 0
sl@0
    95
        set a5 0; set a6 0; set a7 0; set a8 0; set a9 0
sl@0
    96
        set b0 0; set b1 0; set b2 0; set b3 0; set b4 0
sl@0
    97
        set b5 0; set b6 0; set b7 0; set b8 0; set b9 0
sl@0
    98
        set c0 0; set c1 0; set c2 0; set c3 0; set c4 0
sl@0
    99
        set c5 0; set c6 0; set c7 0; set c8 0; set c9 0
sl@0
   100
        set d0 0; set d1 0; set d2 0; set d3 0; set d4 0
sl@0
   101
        set d5 0; set d6 0; set d7 0; set d8 0; set d9 0
sl@0
   102
        set e0 0; set e1 0; set e2 0; set e3 0; set e4 0
sl@0
   103
        set e5 0; set e6 0; set e7 0; set e8 0; set e9 0
sl@0
   104
        set f0 0; set f1 0; set f2 0; set f3 0; set f4 0
sl@0
   105
        set f5 0; set f6 0; set f7 0; set f8 0; set f9 0
sl@0
   106
        set g0 0; set g1 0; set g2 0; set g3 0; set g4 0
sl@0
   107
        set g5 0; set g6 0; set g7 0; set g8 0; set g9 0
sl@0
   108
        set h0 0; set h1 0; set h2 0; set h3 0; set h4 0
sl@0
   109
        set h5 0; set h6 0; set h7 0; set h8 0; set h9 0
sl@0
   110
        set i0 0; set i1 0; set i2 0; set i3 0; set i4 0
sl@0
   111
        set i5 0; set i6 0; set i7 0; set i8 0; set i9 0
sl@0
   112
        set j0 0; set j1 0; set j2 0; set j3 0; set j4 0
sl@0
   113
        set j5 0; set j6 0; set j7 0; set j8 0; set j9 0
sl@0
   114
        set k0 0; set k1 0; set k2 0; set k3 0; set k4 0
sl@0
   115
        set k5 0; set k6 0; set k7 0; set k8 0; set k9 0
sl@0
   116
        set l0 0; set l1 0; set l2 0; set l3 0; set l4 0
sl@0
   117
        set l5 0; set l6 0; set l7 0; set l8 0; set l9 0
sl@0
   118
        set m0 0; set m1 0; set m2 0; set m3 0; set m4 0
sl@0
   119
        set m5 0; set m6 0; set m7 0; set m8 0; set m9 0
sl@0
   120
        set n0 0; set n1 0; set n2 0; set n3 0; set n4 0
sl@0
   121
        set n5 0; set n6 0; set n7 0; set n8 0; set n9 0
sl@0
   122
        set o0 0; set o1 0; set o2 0; set o3 0; set o4 0
sl@0
   123
        set o5 0; set o6 0; set o7 0; set o8 0; set o9 0
sl@0
   124
        set p0 0; set p1 0; set p2 0; set p3 0; set p4 0
sl@0
   125
        set p5 0; set p6 0; set p7 0; set p8 0; set p9 0
sl@0
   126
        set q0 0; set q1 0; set q2 0; set q3 0; set q4 0
sl@0
   127
        set q5 0; set q6 0; set q7 0; set q8 0; set q9 0
sl@0
   128
        set r0 0; set r1 0; set r2 0; set r3 0; set r4 0
sl@0
   129
        set r5 0; set r6 0; set r7 0; set r8 0; set r9 0
sl@0
   130
        set s0 0; set s1 0; set s2 0; set s3 0; set s4 0
sl@0
   131
        set s5 0; set s6 0; set s7 0; set s8 0; set s9 0
sl@0
   132
        set t0 0; set t1 0; set t2 0; set t3 0; set t4 0
sl@0
   133
        set t5 0; set t6 0; set t7 0; set t8 0; set t9 0
sl@0
   134
        set u0 0; set u1 0; set u2 0; set u3 0; set u4 0
sl@0
   135
        set u5 0; set u6 0; set u7 0; set u8 0; set u9 0
sl@0
   136
        set v0 0; set v1 0; set v2 0; set v3 0; set v4 0
sl@0
   137
        set v5 0; set v6 0; set v7 0; set v8 0; set v9 0
sl@0
   138
        set w0 0; set w1 0; set w2 0; set w3 0; set w4 0
sl@0
   139
        set w5 0; set w6 0; set w7 0; set w8 0; set w9 0
sl@0
   140
        set x0 0; set x1 0; set x2 0; set x3 0; set x4 0
sl@0
   141
        set x5 0; set x6 0; set x7 0; set x8 0; set x9 0
sl@0
   142
        set y0 0; set y1 0; set y2 0; set y3 0; set y4 0
sl@0
   143
        set y5 0; set y6 0; set y7 0; set y8 0; set y9 0
sl@0
   144
        set z0 0; set z1 0; set z2 0; set z3 0; set z4 0
sl@0
   145
        set z5 0; set z6 0; set z7 0; set z8 0; set z9 1234
sl@0
   146
    }
sl@0
   147
    260locals
sl@0
   148
} {1234}
sl@0
   149
test set-1.15 {TclCompileSetCmd: variable is array} {
sl@0
   150
    catch {unset a}
sl@0
   151
    set x 27
sl@0
   152
    set x [set a(foo) 11]
sl@0
   153
    catch {unset a}
sl@0
   154
    set x
sl@0
   155
} 11
sl@0
   156
test set-1.16 {TclCompileSetCmd: variable is array, elem substitutions} {
sl@0
   157
    catch {unset a}
sl@0
   158
    set i 5
sl@0
   159
    set x 789
sl@0
   160
    set a(foo5) 27
sl@0
   161
    set x [set a(foo$i)]
sl@0
   162
    catch {unset a}
sl@0
   163
    set x
sl@0
   164
} 27
sl@0
   165
sl@0
   166
test set-1.17 {TclCompileSetCmd: doing assignment, simple int} {
sl@0
   167
    set i 5
sl@0
   168
    set i 123
sl@0
   169
} 123
sl@0
   170
test set-1.18 {TclCompileSetCmd: doing assignment, simple int} {
sl@0
   171
    set i 5
sl@0
   172
    set i -100
sl@0
   173
} -100
sl@0
   174
test set-1.19 {TclCompileSetCmd: doing assignment, simple but not int} {
sl@0
   175
    set i 5
sl@0
   176
    set i 0x12MNOP
sl@0
   177
    set i
sl@0
   178
} {0x12MNOP}
sl@0
   179
test set-1.20 {TclCompileSetCmd: doing assignment, in quotes} {
sl@0
   180
    set i 25
sl@0
   181
    set i "-100"
sl@0
   182
} -100
sl@0
   183
test set-1.21 {TclCompileSetCmd: doing assignment, in braces} {
sl@0
   184
    set i 24
sl@0
   185
    set i {126}
sl@0
   186
} 126
sl@0
   187
test set-1.22 {TclCompileSetCmd: doing assignment, large int} {
sl@0
   188
    set i 5
sl@0
   189
    set i 200000
sl@0
   190
} 200000
sl@0
   191
test set-1.23 {TclCompileSetCmd: doing assignment, formatted int != int} {
sl@0
   192
    set i 25
sl@0
   193
    set i 000012345     ;# an octal literal == 5349 decimal
sl@0
   194
    list $i [incr i]
sl@0
   195
} {000012345 5350}
sl@0
   196
sl@0
   197
test set-1.24 {TclCompileSetCmd: too many arguments} {
sl@0
   198
    set i 10
sl@0
   199
    catch {set i 20 30} msg
sl@0
   200
    set msg
sl@0
   201
} {wrong # args: should be "set varName ?newValue?"}
sl@0
   202
sl@0
   203
test set-1.25 {TclCompileSetCmd: var is array, braced (no subs)} {
sl@0
   204
    # This was a known error in 8.1a* - 8.2.1
sl@0
   205
    catch {unset array}
sl@0
   206
    set {array($foo)} 5
sl@0
   207
} 5
sl@0
   208
test set-1.26 {TclCompileSetCmd: various array constructs} {
sl@0
   209
    # Test all kinds of array constructs that TclCompileSetCmd
sl@0
   210
    # may feel inclined to tamper with.
sl@0
   211
    proc p {} {
sl@0
   212
	set a x
sl@0
   213
	set be(hej) 1					; # hej
sl@0
   214
	set be($a) 1					; # x
sl@0
   215
	set {be($a)} 1					; # $a
sl@0
   216
	set be($a,hej) 1				; # x,hej
sl@0
   217
	set be($a,$a) 5					; # x,x
sl@0
   218
	set be(c($a) 1					; # c(x
sl@0
   219
	set be(\w\w) 1					; # ww
sl@0
   220
	set be(a:$a) [set be(x,$a)]			; # a:x
sl@0
   221
	set be(hej,$be($a,hej),hej) 1			; # hej,1,hej
sl@0
   222
	set be([string range hugge 0 2]) 1		; # hug
sl@0
   223
	set be(a\ a) 1					; # a a
sl@0
   224
	set be($a\ ,[string range hugge 1 3],hej) 1	; # x ,ugg,hej
sl@0
   225
	set be($a,h"ej) 1				; # x,h"ej
sl@0
   226
	set be([string range "a b c" 2 end]) 1		; # b c
sl@0
   227
	set [string range bet 0 1](foo) 1		; # foo
sl@0
   228
	set be([set be(a:$a)][set b\e($a)]) 1		; # 51
sl@0
   229
	return [lsort [array names be]]
sl@0
   230
    }
sl@0
   231
    p
sl@0
   232
} [lsort {hej x $a x,hej x,x c(x ww a:x hej,1,hej hug {a a} {x ,ugg,hej} x,h"ej
sl@0
   233
{b c} foo 51}]; # " just a matching end quote
sl@0
   234
sl@0
   235
test set-2.1 {set command: runtime error, bad variable name} {
sl@0
   236
    list [catch {set {"foo}} msg] $msg $errorInfo
sl@0
   237
} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
sl@0
   238
    while executing
sl@0
   239
"set {"foo}"}}
sl@0
   240
test set-2.2 {set command: runtime error, not array variable} {
sl@0
   241
    catch {unset b}
sl@0
   242
    set b 44
sl@0
   243
    list [catch {set b(123)} msg] $msg
sl@0
   244
} {1 {can't read "b(123)": variable isn't array}}
sl@0
   245
test set-2.3 {set command: runtime error, errors in reading variables} {
sl@0
   246
    catch {unset a}
sl@0
   247
    set a(6) 44
sl@0
   248
    list [catch {set a(18)} msg] $msg
sl@0
   249
} {1 {can't read "a(18)": no such element in array}}
sl@0
   250
test set-2.4 {set command: runtime error, readonly variable} {
sl@0
   251
    proc readonly args {error "variable is read-only"}
sl@0
   252
    set x 123
sl@0
   253
    trace var x w readonly
sl@0
   254
    list [catch {set x 1} msg] $msg $errorInfo
sl@0
   255
} {1 {can't set "x": variable is read-only} {can't set "x": variable is read-only
sl@0
   256
    while executing
sl@0
   257
"set x 1"}}
sl@0
   258
test set-2.5 {set command: runtime error, basic array operations} {
sl@0
   259
    list [catch {set a(other)} msg] $msg
sl@0
   260
} {1 {can't read "a(other)": no such element in array}}
sl@0
   261
test set-2.6 {set command: runtime error, basic array operations} {
sl@0
   262
    list [catch {set a} msg] $msg
sl@0
   263
} {1 {can't read "a": variable is array}}
sl@0
   264
sl@0
   265
# Test the uncompiled version of set
sl@0
   266
sl@0
   267
catch {unset a}
sl@0
   268
catch {unset b}
sl@0
   269
catch {unset i}
sl@0
   270
catch {unset x}
sl@0
   271
sl@0
   272
test set-3.1 {uncompiled set command: missing variable name} {
sl@0
   273
    set z set
sl@0
   274
    list [catch {$z} msg] $msg
sl@0
   275
} {1 {wrong # args: should be "set varName ?newValue?"}}
sl@0
   276
test set-3.2 {uncompiled set command: simple variable name} {
sl@0
   277
    set z set
sl@0
   278
    $z i 10
sl@0
   279
    list [$z i] $i
sl@0
   280
} {10 10}
sl@0
   281
test set-3.3 {uncompiled set command: error compiling variable name} {
sl@0
   282
    set z set
sl@0
   283
    $z i 10
sl@0
   284
    catch {$z "i"xxx} msg
sl@0
   285
    $z msg
sl@0
   286
} {extra characters after close-quote}
sl@0
   287
test set-3.4 {uncompiled set command: simple variable name in quotes} {
sl@0
   288
    set z set
sl@0
   289
    $z i 17
sl@0
   290
    list [$z "i"] $i
sl@0
   291
} {17 17}
sl@0
   292
test set-3.5 {uncompiled set command: simple variable name in braces} {
sl@0
   293
    set z set
sl@0
   294
    catch {unset {a simple var}}
sl@0
   295
    $z {a simple var} 27
sl@0
   296
    list [$z {a simple var}] ${a simple var}
sl@0
   297
} {27 27}
sl@0
   298
test set-3.6 {uncompiled set command: simple array variable name} {
sl@0
   299
    set z set
sl@0
   300
    catch {unset a}
sl@0
   301
    $z a(foo) 37
sl@0
   302
    list [$z a(foo)] $a(foo)
sl@0
   303
} {37 37}
sl@0
   304
test set-3.7 {uncompiled set command: non-simple (computed) variable name} {
sl@0
   305
    set z set
sl@0
   306
    $z x "i"
sl@0
   307
    $z i 77
sl@0
   308
    list [$z $x] $i
sl@0
   309
} {77 77}
sl@0
   310
test set-3.8 {uncompiled set command: non-simple (computed) variable name} {
sl@0
   311
    set z set
sl@0
   312
    $z x "i"
sl@0
   313
    $z i 77
sl@0
   314
    list [$z [$z x] 2] $i
sl@0
   315
} {2 2}
sl@0
   316
sl@0
   317
test set-3.9 {uncompiled set command: 3rd arg => assignment} {
sl@0
   318
    set z set
sl@0
   319
    $z i "abcdef"
sl@0
   320
    list [$z i] $i
sl@0
   321
} {abcdef abcdef}
sl@0
   322
test set-3.10 {uncompiled set command: only two args => just getting value} {
sl@0
   323
    set z set
sl@0
   324
    $z i {one two}
sl@0
   325
    $z i
sl@0
   326
} {one two}
sl@0
   327
sl@0
   328
test set-3.11 {uncompiled set command: simple global name} {
sl@0
   329
    proc p {} {
sl@0
   330
	set z set
sl@0
   331
        global i
sl@0
   332
        $z i 54
sl@0
   333
        $z i
sl@0
   334
    }
sl@0
   335
    p
sl@0
   336
} {54}
sl@0
   337
test set-3.12 {uncompiled set command: simple local name} {
sl@0
   338
    proc p {bar} {
sl@0
   339
	set z set
sl@0
   340
        $z foo $bar
sl@0
   341
        $z foo
sl@0
   342
    }
sl@0
   343
    p 999
sl@0
   344
} {999}
sl@0
   345
test set-3.13 {uncompiled set command: simple but new (unknown) local name} {
sl@0
   346
    set z set
sl@0
   347
    proc p {} {
sl@0
   348
	set z set
sl@0
   349
        $z bar
sl@0
   350
    }
sl@0
   351
    catch {p} msg
sl@0
   352
    $z msg
sl@0
   353
} {can't read "bar": no such variable}
sl@0
   354
test set-3.14 {uncompiled set command: simple local name, >255 locals} {
sl@0
   355
    proc 260locals {} {
sl@0
   356
	set z set
sl@0
   357
        # create 260 locals (the last ones with index > 255)
sl@0
   358
        $z a0 0; $z a1 0; $z a2 0; $z a3 0; $z a4 0
sl@0
   359
        $z a5 0; $z a6 0; $z a7 0; $z a8 0; $z a9 0
sl@0
   360
        $z b0 0; $z b1 0; $z b2 0; $z b3 0; $z b4 0
sl@0
   361
        $z b5 0; $z b6 0; $z b7 0; $z b8 0; $z b9 0
sl@0
   362
        $z c0 0; $z c1 0; $z c2 0; $z c3 0; $z c4 0
sl@0
   363
        $z c5 0; $z c6 0; $z c7 0; $z c8 0; $z c9 0
sl@0
   364
        $z d0 0; $z d1 0; $z d2 0; $z d3 0; $z d4 0
sl@0
   365
        $z d5 0; $z d6 0; $z d7 0; $z d8 0; $z d9 0
sl@0
   366
        $z e0 0; $z e1 0; $z e2 0; $z e3 0; $z e4 0
sl@0
   367
        $z e5 0; $z e6 0; $z e7 0; $z e8 0; $z e9 0
sl@0
   368
        $z f0 0; $z f1 0; $z f2 0; $z f3 0; $z f4 0
sl@0
   369
        $z f5 0; $z f6 0; $z f7 0; $z f8 0; $z f9 0
sl@0
   370
        $z g0 0; $z g1 0; $z g2 0; $z g3 0; $z g4 0
sl@0
   371
        $z g5 0; $z g6 0; $z g7 0; $z g8 0; $z g9 0
sl@0
   372
        $z h0 0; $z h1 0; $z h2 0; $z h3 0; $z h4 0
sl@0
   373
        $z h5 0; $z h6 0; $z h7 0; $z h8 0; $z h9 0
sl@0
   374
        $z i0 0; $z i1 0; $z i2 0; $z i3 0; $z i4 0
sl@0
   375
        $z i5 0; $z i6 0; $z i7 0; $z i8 0; $z i9 0
sl@0
   376
        $z j0 0; $z j1 0; $z j2 0; $z j3 0; $z j4 0
sl@0
   377
        $z j5 0; $z j6 0; $z j7 0; $z j8 0; $z j9 0
sl@0
   378
        $z k0 0; $z k1 0; $z k2 0; $z k3 0; $z k4 0
sl@0
   379
        $z k5 0; $z k6 0; $z k7 0; $z k8 0; $z k9 0
sl@0
   380
        $z l0 0; $z l1 0; $z l2 0; $z l3 0; $z l4 0
sl@0
   381
        $z l5 0; $z l6 0; $z l7 0; $z l8 0; $z l9 0
sl@0
   382
        $z m0 0; $z m1 0; $z m2 0; $z m3 0; $z m4 0
sl@0
   383
        $z m5 0; $z m6 0; $z m7 0; $z m8 0; $z m9 0
sl@0
   384
        $z n0 0; $z n1 0; $z n2 0; $z n3 0; $z n4 0
sl@0
   385
        $z n5 0; $z n6 0; $z n7 0; $z n8 0; $z n9 0
sl@0
   386
        $z o0 0; $z o1 0; $z o2 0; $z o3 0; $z o4 0
sl@0
   387
        $z o5 0; $z o6 0; $z o7 0; $z o8 0; $z o9 0
sl@0
   388
        $z p0 0; $z p1 0; $z p2 0; $z p3 0; $z p4 0
sl@0
   389
        $z p5 0; $z p6 0; $z p7 0; $z p8 0; $z p9 0
sl@0
   390
        $z q0 0; $z q1 0; $z q2 0; $z q3 0; $z q4 0
sl@0
   391
        $z q5 0; $z q6 0; $z q7 0; $z q8 0; $z q9 0
sl@0
   392
        $z r0 0; $z r1 0; $z r2 0; $z r3 0; $z r4 0
sl@0
   393
        $z r5 0; $z r6 0; $z r7 0; $z r8 0; $z r9 0
sl@0
   394
        $z s0 0; $z s1 0; $z s2 0; $z s3 0; $z s4 0
sl@0
   395
        $z s5 0; $z s6 0; $z s7 0; $z s8 0; $z s9 0
sl@0
   396
        $z t0 0; $z t1 0; $z t2 0; $z t3 0; $z t4 0
sl@0
   397
        $z t5 0; $z t6 0; $z t7 0; $z t8 0; $z t9 0
sl@0
   398
        $z u0 0; $z u1 0; $z u2 0; $z u3 0; $z u4 0
sl@0
   399
        $z u5 0; $z u6 0; $z u7 0; $z u8 0; $z u9 0
sl@0
   400
        $z v0 0; $z v1 0; $z v2 0; $z v3 0; $z v4 0
sl@0
   401
        $z v5 0; $z v6 0; $z v7 0; $z v8 0; $z v9 0
sl@0
   402
        $z w0 0; $z w1 0; $z w2 0; $z w3 0; $z w4 0
sl@0
   403
        $z w5 0; $z w6 0; $z w7 0; $z w8 0; $z w9 0
sl@0
   404
        $z x0 0; $z x1 0; $z x2 0; $z x3 0; $z x4 0
sl@0
   405
        $z x5 0; $z x6 0; $z x7 0; $z x8 0; $z x9 0
sl@0
   406
        $z y0 0; $z y1 0; $z y2 0; $z y3 0; $z y4 0
sl@0
   407
        $z y5 0; $z y6 0; $z y7 0; $z y8 0; $z y9 0
sl@0
   408
        $z z0 0; $z z1 0; $z z2 0; $z z3 0; $z z4 0
sl@0
   409
        $z z5 0; $z z6 0; $z z7 0; $z z8 0; $z z9 1234
sl@0
   410
    }
sl@0
   411
    260locals
sl@0
   412
} {1234}
sl@0
   413
test set-3.15 {uncompiled set command: variable is array} {
sl@0
   414
    set z set
sl@0
   415
    catch {unset a}
sl@0
   416
    $z x 27
sl@0
   417
    $z x [$z a(foo) 11]
sl@0
   418
    catch {unset a}
sl@0
   419
    $z x
sl@0
   420
} 11
sl@0
   421
test set-3.16 {uncompiled set command: variable is array, elem substitutions} {
sl@0
   422
    set z set
sl@0
   423
    catch {unset a}
sl@0
   424
    $z i 5
sl@0
   425
    $z x 789
sl@0
   426
    $z a(foo5) 27
sl@0
   427
    $z x [$z a(foo$i)]
sl@0
   428
    catch {unset a}
sl@0
   429
    $z x
sl@0
   430
} 27
sl@0
   431
sl@0
   432
test set-3.17 {uncompiled set command: doing assignment, simple int} {
sl@0
   433
    set z set
sl@0
   434
    $z i 5
sl@0
   435
    $z i 123
sl@0
   436
} 123
sl@0
   437
test set-3.18 {uncompiled set command: doing assignment, simple int} {
sl@0
   438
    set z set
sl@0
   439
    $z i 5
sl@0
   440
    $z i -100
sl@0
   441
} -100
sl@0
   442
test set-3.19 {uncompiled set command: doing assignment, simple but not int} {
sl@0
   443
    set z set
sl@0
   444
    $z i 5
sl@0
   445
    $z i 0x12MNOP
sl@0
   446
    $z i
sl@0
   447
} {0x12MNOP}
sl@0
   448
test set-3.20 {uncompiled set command: doing assignment, in quotes} {
sl@0
   449
    set z set
sl@0
   450
    $z i 25
sl@0
   451
    $z i "-100"
sl@0
   452
} -100
sl@0
   453
test set-3.21 {uncompiled set command: doing assignment, in braces} {
sl@0
   454
    set z set
sl@0
   455
    $z i 24
sl@0
   456
    $z i {126}
sl@0
   457
} 126
sl@0
   458
test set-3.22 {uncompiled set command: doing assignment, large int} {
sl@0
   459
    set z set
sl@0
   460
    $z i 5
sl@0
   461
    $z i 200000
sl@0
   462
} 200000
sl@0
   463
test set-3.23 {uncompiled set command: doing assignment, formatted int != int} {
sl@0
   464
    set z set
sl@0
   465
    $z i 25
sl@0
   466
    $z i 000012345     ;# an octal literal == 5349 decimal
sl@0
   467
    list $i [incr i]
sl@0
   468
} {000012345 5350}
sl@0
   469
sl@0
   470
test set-3.24 {uncompiled set command: too many arguments} {
sl@0
   471
    set z set
sl@0
   472
    $z i 10
sl@0
   473
    catch {$z i 20 30} msg
sl@0
   474
    $z msg
sl@0
   475
} {wrong # args: should be "set varName ?newValue?"}
sl@0
   476
sl@0
   477
test set-4.1 {uncompiled set command: runtime error, bad variable name} {
sl@0
   478
    set z set
sl@0
   479
    list [catch {$z {"foo}} msg] $msg $errorInfo
sl@0
   480
} {1 {can't read ""foo": no such variable} {can't read ""foo": no such variable
sl@0
   481
    while executing
sl@0
   482
"$z {"foo}"}}
sl@0
   483
test set-4.2 {uncompiled set command: runtime error, not array variable} {
sl@0
   484
    set z set
sl@0
   485
    catch {unset b}
sl@0
   486
    $z b 44
sl@0
   487
    list [catch {$z b(123)} msg] $msg
sl@0
   488
} {1 {can't read "b(123)": variable isn't array}}
sl@0
   489
test set-4.3 {uncompiled set command: runtime error, errors in reading variables} {
sl@0
   490
     set z set
sl@0
   491
   catch {unset a}
sl@0
   492
    $z a(6) 44
sl@0
   493
    list [catch {$z a(18)} msg] $msg
sl@0
   494
} {1 {can't read "a(18)": no such element in array}}
sl@0
   495
test set-4.4 {uncompiled set command: runtime error, readonly variable} {
sl@0
   496
    set z set
sl@0
   497
    proc readonly args {error "variable is read-only"}
sl@0
   498
    $z x 123
sl@0
   499
    trace var x w readonly
sl@0
   500
    list [catch {$z x 1} msg] $msg $errorInfo
sl@0
   501
} {1 {can't set "x": variable is read-only} {can't set "x": variable is read-only
sl@0
   502
    while executing
sl@0
   503
"$z x 1"}}
sl@0
   504
test set-4.5 {uncompiled set command: runtime error, basic array operations} {
sl@0
   505
    set z set
sl@0
   506
    list [catch {$z a(other)} msg] $msg
sl@0
   507
} {1 {can't read "a(other)": no such element in array}}
sl@0
   508
test set-4.6 {set command: runtime error, basic array operations} {
sl@0
   509
    set z set
sl@0
   510
    list [catch {$z a} msg] $msg
sl@0
   511
} {1 {can't read "a": variable is array}}
sl@0
   512
sl@0
   513
# cleanup
sl@0
   514
catch {unset a}
sl@0
   515
catch {unset b}
sl@0
   516
catch {unset i}
sl@0
   517
catch {unset x}
sl@0
   518
catch {unset z}
sl@0
   519
::tcltest::cleanupTests
sl@0
   520
return