os/persistentdata/persistentstorage/sqlite3api/TEST/TCL/tcldistribution/tests/set-old.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, unset, array
sl@0
     2
#
sl@0
     3
# This file includes the original set of tests for Tcl's set command.
sl@0
     4
# Since the set command is now compiled, a new set of tests covering
sl@0
     5
# the new implementation is in the file "set.test". Sourcing this file
sl@0
     6
# into Tcl runs the tests and generates output for errors.
sl@0
     7
# No output means no errors were found.
sl@0
     8
#
sl@0
     9
# Copyright (c) 1991-1993 The Regents of the University of California.
sl@0
    10
# Copyright (c) 1994-1997 Sun Microsystems, Inc.
sl@0
    11
# Copyright (c) 1998-1999 by Scriptics Corporation.
sl@0
    12
#
sl@0
    13
# See the file "license.terms" for information on usage and redistribution
sl@0
    14
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
sl@0
    15
#
sl@0
    16
# RCS: @(#) $Id: set-old.test,v 1.16.2.1 2003/03/27 21:46:32 msofer Exp $
sl@0
    17
sl@0
    18
if {[lsearch [namespace children] ::tcltest] == -1} {
sl@0
    19
    package require tcltest
sl@0
    20
    namespace import -force ::tcltest::*
sl@0
    21
}
sl@0
    22
sl@0
    23
proc ignore args {}
sl@0
    24
sl@0
    25
# Simple variable operations.
sl@0
    26
sl@0
    27
catch {unset a}
sl@0
    28
test set-old-1.1 {basic variable setting and unsetting} {
sl@0
    29
    set a 22
sl@0
    30
} 22
sl@0
    31
test set-old-1.2 {basic variable setting and unsetting} {
sl@0
    32
    set a 123
sl@0
    33
    set a
sl@0
    34
} 123
sl@0
    35
test set-old-1.3 {basic variable setting and unsetting} {
sl@0
    36
    set a xxx
sl@0
    37
    format %s $a
sl@0
    38
} xxx
sl@0
    39
test set-old-1.4 {basic variable setting and unsetting} {
sl@0
    40
    set a 44
sl@0
    41
    unset a
sl@0
    42
    list [catch {set a} msg] $msg
sl@0
    43
} {1 {can't read "a": no such variable}}
sl@0
    44
sl@0
    45
# Basic array operations.
sl@0
    46
sl@0
    47
catch {unset a}
sl@0
    48
set a(xyz) 2
sl@0
    49
set a(44) 3
sl@0
    50
set {a(a long name)} test
sl@0
    51
test set-old-2.1 {basic array operations} {
sl@0
    52
    lsort [array names a]
sl@0
    53
} {44 {a long name} xyz}
sl@0
    54
test set-old-2.2 {basic array operations} {
sl@0
    55
    set a(44)
sl@0
    56
} 3
sl@0
    57
test set-old-2.3 {basic array operations} {
sl@0
    58
    set a(xyz)
sl@0
    59
} 2
sl@0
    60
test set-old-2.4 {basic array operations} {
sl@0
    61
    set "a(a long name)"
sl@0
    62
} test
sl@0
    63
test set-old-2.5 {basic array operations} {
sl@0
    64
    list [catch {set a(other)} msg] $msg
sl@0
    65
} {1 {can't read "a(other)": no such element in array}}
sl@0
    66
test set-old-2.6 {basic array operations} {
sl@0
    67
    list [catch {set a} msg] $msg
sl@0
    68
} {1 {can't read "a": variable is array}}
sl@0
    69
test set-old-2.7 {basic array operations} {
sl@0
    70
    format %s $a(44)
sl@0
    71
} 3
sl@0
    72
test set-old-2.8 {basic array operations} {
sl@0
    73
    format %s $a(a long name)
sl@0
    74
} test
sl@0
    75
unset a(44)
sl@0
    76
test set-old-2.9 {basic array operations} {
sl@0
    77
    lsort [array names a]
sl@0
    78
} {{a long name} xyz}
sl@0
    79
test set-old-2.10 {basic array operations} {
sl@0
    80
    catch {unset b}
sl@0
    81
    list [catch {set b(123)} msg] $msg
sl@0
    82
} {1 {can't read "b(123)": no such variable}}
sl@0
    83
test set-old-2.11 {basic array operations} {
sl@0
    84
    catch {unset b}
sl@0
    85
    set b 44
sl@0
    86
    list [catch {set b(123)} msg] $msg
sl@0
    87
} {1 {can't read "b(123)": variable isn't array}}
sl@0
    88
test set-old-2.12 {basic array operations} {
sl@0
    89
    list [catch {set a 14} msg] $msg
sl@0
    90
} {1 {can't set "a": variable is array}}
sl@0
    91
unset a
sl@0
    92
test set-old-2.13 {basic array operations} {
sl@0
    93
    list [catch {set a(xyz)} msg] $msg
sl@0
    94
} {1 {can't read "a(xyz)": no such variable}}
sl@0
    95
sl@0
    96
# Test the set commands, and exercise the corner cases of the code
sl@0
    97
# that parses array references into two parts.
sl@0
    98
sl@0
    99
test set-old-3.1 {set command} {
sl@0
   100
    list [catch {set} msg] $msg
sl@0
   101
} {1 {wrong # args: should be "set varName ?newValue?"}}
sl@0
   102
test set-old-3.2 {set command} {
sl@0
   103
    list [catch {set x y z} msg] $msg
sl@0
   104
} {1 {wrong # args: should be "set varName ?newValue?"}}
sl@0
   105
test set-old-3.3 {set command} {
sl@0
   106
    catch {unset a}
sl@0
   107
    list [catch {set a} msg] $msg
sl@0
   108
} {1 {can't read "a": no such variable}}
sl@0
   109
test set-old-3.4 {set command} {
sl@0
   110
    catch {unset a}
sl@0
   111
    set a(14) 83
sl@0
   112
    list [catch {set a 22} msg] $msg
sl@0
   113
} {1 {can't set "a": variable is array}}
sl@0
   114
sl@0
   115
# Test the corner-cases of parsing array names, using set and unset.
sl@0
   116
sl@0
   117
test set-old-4.1 {parsing array names} {
sl@0
   118
    catch {unset a}
sl@0
   119
    set a(()) 44
sl@0
   120
    list [catch {array names a} msg] $msg
sl@0
   121
} {0 ()}
sl@0
   122
test set-old-4.2 {parsing array names} {
sl@0
   123
    catch {unset a a(abcd}
sl@0
   124
    set a(abcd 33
sl@0
   125
    info exists a(abcd
sl@0
   126
} 1
sl@0
   127
test set-old-4.3 {parsing array names} {
sl@0
   128
    catch {unset a a(abcd}
sl@0
   129
    set a(abcd 33
sl@0
   130
    list [catch {array names a} msg] $msg
sl@0
   131
} {0 {}}
sl@0
   132
test set-old-4.4 {parsing array names} {
sl@0
   133
    catch {unset a abcd)}
sl@0
   134
    set abcd) 33
sl@0
   135
    info exists abcd)
sl@0
   136
} 1
sl@0
   137
test set-old-4.5 {parsing array names} {
sl@0
   138
    set a(bcd yyy
sl@0
   139
    catch {unset a}
sl@0
   140
    list [catch {set a(bcd} msg] $msg
sl@0
   141
} {0 yyy}
sl@0
   142
test set-old-4.6 {parsing array names} {
sl@0
   143
    catch {unset a}
sl@0
   144
    set a 44
sl@0
   145
    list [catch {set a(bcd test} msg] $msg
sl@0
   146
} {0 test}
sl@0
   147
sl@0
   148
# Errors in reading variables
sl@0
   149
sl@0
   150
test set-old-5.1 {errors in reading variables} {
sl@0
   151
    catch {unset a}
sl@0
   152
    list [catch {set a} msg] $msg
sl@0
   153
} {1 {can't read "a": no such variable}}
sl@0
   154
test set-old-5.2 {errors in reading variables} {
sl@0
   155
    catch {unset a}
sl@0
   156
    set a 44
sl@0
   157
    list [catch {set a(18)} msg] $msg
sl@0
   158
} {1 {can't read "a(18)": variable isn't array}}
sl@0
   159
test set-old-5.3 {errors in reading variables} {
sl@0
   160
    catch {unset a}
sl@0
   161
    set a(6) 44
sl@0
   162
    list [catch {set a(18)} msg] $msg
sl@0
   163
} {1 {can't read "a(18)": no such element in array}}
sl@0
   164
test set-old-5.4 {errors in reading variables} {
sl@0
   165
    catch {unset a}
sl@0
   166
    set a(6) 44
sl@0
   167
    list [catch {set a} msg] $msg
sl@0
   168
} {1 {can't read "a": variable is array}}
sl@0
   169
sl@0
   170
# Errors and other special cases in writing variables
sl@0
   171
sl@0
   172
test set-old-6.1 {creating array during write} {
sl@0
   173
    catch {unset a}
sl@0
   174
    trace var a rwu ignore
sl@0
   175
    list [catch {set a(14) 186} msg] $msg [array names a]
sl@0
   176
} {0 186 14}
sl@0
   177
test set-old-6.2 {errors in writing variables} {
sl@0
   178
    catch {unset a}
sl@0
   179
    set a xxx
sl@0
   180
    list [catch {set a(14) 186} msg] $msg
sl@0
   181
} {1 {can't set "a(14)": variable isn't array}}
sl@0
   182
test set-old-6.3 {errors in writing variables} {
sl@0
   183
    catch {unset a}
sl@0
   184
    set a(100) yyy
sl@0
   185
    list [catch {set a 2} msg] $msg
sl@0
   186
} {1 {can't set "a": variable is array}}
sl@0
   187
test set-old-6.4 {expanding variable size} {
sl@0
   188
    catch {unset a}
sl@0
   189
    list [set a short] [set a "longer name"] [set a "even longer name"] \
sl@0
   190
	    [set a "a much much truly longer name"]
sl@0
   191
} {short {longer name} {even longer name} {a much much truly longer name}}
sl@0
   192
sl@0
   193
# Unset command, Tcl_UnsetVar procedures
sl@0
   194
sl@0
   195
test set-old-7.1 {unset command} {
sl@0
   196
    catch {unset a}; catch {unset b}; catch {unset c}; catch {unset d}
sl@0
   197
    set a 44
sl@0
   198
    set b 55
sl@0
   199
    set c 66
sl@0
   200
    set d 77
sl@0
   201
    unset a b c
sl@0
   202
    list [catch {set a(0) 0}] [catch {set b(0) 0}] [catch {set c(0) 0}] \
sl@0
   203
	    [catch {set d(0) 0}]
sl@0
   204
} {0 0 0 1}
sl@0
   205
test set-old-7.2 {unset command} {
sl@0
   206
    list [catch {unset} msg] $msg
sl@0
   207
} {0 {}}
sl@0
   208
# Used to return:
sl@0
   209
#{1 {wrong # args: should be "unset ?-nocomplain? ?--? ?varName varName ...?"}}
sl@0
   210
test set-old-7.3 {unset command} {
sl@0
   211
    catch {unset a}
sl@0
   212
    list [catch {unset a} msg] $msg
sl@0
   213
} {1 {can't unset "a": no such variable}}
sl@0
   214
test set-old-7.4 {unset command} {
sl@0
   215
    catch {unset a}
sl@0
   216
    set a 44
sl@0
   217
    list [catch {unset a(14)} msg] $msg
sl@0
   218
} {1 {can't unset "a(14)": variable isn't array}}
sl@0
   219
test set-old-7.5 {unset command} {
sl@0
   220
    catch {unset a}
sl@0
   221
    set a(0) xx
sl@0
   222
    list [catch {unset a(14)} msg] $msg
sl@0
   223
} {1 {can't unset "a(14)": no such element in array}}
sl@0
   224
test set-old-7.6 {unset command} {
sl@0
   225
    catch {unset a}; catch {unset b}; catch {unset c}
sl@0
   226
    set a foo
sl@0
   227
    set c gorp
sl@0
   228
    list [catch {unset a a a(14)} msg] $msg [info exists c]
sl@0
   229
} {1 {can't unset "a": no such variable} 1}
sl@0
   230
test set-old-7.7 {unsetting globals from within procedures} {
sl@0
   231
    set y 0
sl@0
   232
    proc p1 {} {
sl@0
   233
	global y
sl@0
   234
	set z [p2]
sl@0
   235
	return [list $z [catch {set y} msg] $msg]
sl@0
   236
    }
sl@0
   237
    proc p2 {} {global y; unset y; list [catch {set y} msg] $msg}
sl@0
   238
    p1
sl@0
   239
} {{1 {can't read "y": no such variable}} 1 {can't read "y": no such variable}}
sl@0
   240
test set-old-7.8 {unsetting globals from within procedures} {
sl@0
   241
    set y 0
sl@0
   242
    proc p1 {} {
sl@0
   243
	global y
sl@0
   244
	p2
sl@0
   245
	return [list [catch {set y 44} msg] $msg]
sl@0
   246
    }
sl@0
   247
    proc p2 {} {global y; unset y}
sl@0
   248
    concat [p1] [list [catch {set y} msg] $msg]
sl@0
   249
} {0 44 0 44}
sl@0
   250
test set-old-7.9 {unsetting globals from within procedures} {
sl@0
   251
    set y 0
sl@0
   252
    proc p1 {} {
sl@0
   253
	global y
sl@0
   254
	unset y
sl@0
   255
	return [list [catch {set y 55} msg] $msg]
sl@0
   256
    }
sl@0
   257
    concat [p1] [list [catch {set y} msg] $msg]
sl@0
   258
} {0 55 0 55}
sl@0
   259
test set-old-7.10 {unset command} {
sl@0
   260
    catch {unset a}
sl@0
   261
    set a(14) 22
sl@0
   262
    unset a(14)
sl@0
   263
    list [catch {set a(14)} msg] $msg [catch {array names a} msg2] $msg2
sl@0
   264
} {1 {can't read "a(14)": no such element in array} 0 {}}
sl@0
   265
test set-old-7.11 {unset command} {
sl@0
   266
    catch {unset a}
sl@0
   267
    set a(14) 22
sl@0
   268
    unset a
sl@0
   269
    list [catch {set a(14)} msg] $msg [catch {array names a} msg2] $msg2
sl@0
   270
} {1 {can't read "a(14)": no such variable} 0 {}}
sl@0
   271
test set-old-7.12 {unset command, -nocomplain} {
sl@0
   272
    catch {unset a}
sl@0
   273
    list [info exists a] [catch {unset -nocomplain a}] [info exists a]
sl@0
   274
} {0 0 0}
sl@0
   275
test set-old-7.13 {unset command, -nocomplain} {
sl@0
   276
    set -nocomplain abc
sl@0
   277
    list [info exists -nocomplain] [catch {unset -nocomplain}] \
sl@0
   278
	    [info exists -nocomplain] [catch {unset -- -nocomplain}] \
sl@0
   279
	    [info exists -nocomplain]
sl@0
   280
} {1 0 1 0 0}
sl@0
   281
test set-old-7.14 {unset command, --} {
sl@0
   282
    set -- abc
sl@0
   283
    list [info exists --] [catch {unset --}] \
sl@0
   284
	    [info exists --] [catch {unset -- --}] \
sl@0
   285
	    [info exists --]
sl@0
   286
} {1 0 1 0 0}
sl@0
   287
test set-old-7.15 {unset command, -nocomplain} {
sl@0
   288
    set -nocomplain abc
sl@0
   289
    set -- abc
sl@0
   290
    list [info exists -nocomplain] [catch {unset -- -nocomplain}] \
sl@0
   291
	    [info exists -nocomplain] [info exists --] \
sl@0
   292
	    [catch {unset -- -nocomplain}] [info exists --] \
sl@0
   293
	    [catch {unset -- --}] [info exists --]
sl@0
   294
} {1 0 0 1 1 1 0 0}
sl@0
   295
test set-old-7.16 {unset command, -nocomplain} {
sl@0
   296
    set -nocomplain abc
sl@0
   297
    set var abc
sl@0
   298
    list [info exists bogus] [catch {unset -nocomplain bogus var bogus}] \
sl@0
   299
	    [info exists -nocomplain] [info exists var] \
sl@0
   300
	    [catch {unset -nocomplain -nocomplain}] [info exists -nocomplain]
sl@0
   301
} {0 0 1 0 0 0}
sl@0
   302
test set-old-7.17 {unset command, -nocomplain (no abbreviation)} {
sl@0
   303
    set -nocomp abc
sl@0
   304
    list [info exists -nocomp] [catch {unset -nocomp}] [info exists -nocomp]
sl@0
   305
} {1 0 0}
sl@0
   306
test set-old-7.18 {unset command, -nocomplain (no abbreviation)} {
sl@0
   307
    catch {unset -nocomp}
sl@0
   308
    list [info exists -nocomp] [catch {unset -nocomp}]
sl@0
   309
} {0 1}
sl@0
   310
sl@0
   311
# Array command.
sl@0
   312
sl@0
   313
test set-old-8.1 {array command} {
sl@0
   314
    list [catch {array} msg] $msg
sl@0
   315
} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
sl@0
   316
test set-old-8.2 {array command} {
sl@0
   317
    list [catch {array a} msg] $msg
sl@0
   318
} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
sl@0
   319
test set-old-8.3 {array command} {
sl@0
   320
    catch {unset a}
sl@0
   321
    list [catch {array anymore a b} msg] $msg
sl@0
   322
} {1 {"a" isn't an array}}
sl@0
   323
test set-old-8.4 {array command} {
sl@0
   324
    catch {unset a}
sl@0
   325
    set a 44
sl@0
   326
    list [catch {array anymore a b} msg] $msg
sl@0
   327
} {1 {"a" isn't an array}}
sl@0
   328
test set-old-8.5 {array command} {
sl@0
   329
    proc foo {} {
sl@0
   330
	set a 44
sl@0
   331
	upvar 0 a x
sl@0
   332
	list [catch {array anymore x b} msg] $msg
sl@0
   333
    }
sl@0
   334
    foo
sl@0
   335
} {1 {"x" isn't an array}}
sl@0
   336
test set-old-8.6 {array command} {
sl@0
   337
    catch {unset a}
sl@0
   338
    set a(22) 3
sl@0
   339
    list [catch {array gorp a} msg] $msg
sl@0
   340
} {1 {bad option "gorp": must be anymore, donesearch, exists, get, names, nextelement, set, size, startsearch, statistics, or unset}}
sl@0
   341
test set-old-8.7 {array command, anymore option} {
sl@0
   342
    catch {unset a}
sl@0
   343
    list [catch {array anymore a x} msg] $msg
sl@0
   344
} {1 {"a" isn't an array}}
sl@0
   345
test set-old-8.8 {array command, anymore option, array doesn't exist yet but has compiler-allocated procedure slot} {
sl@0
   346
    proc foo {x} {
sl@0
   347
        if {$x==1} {
sl@0
   348
            return [array anymore a x]
sl@0
   349
        }
sl@0
   350
        set a(x) 123
sl@0
   351
    }
sl@0
   352
    list [catch {foo 1} msg] $msg
sl@0
   353
} {1 {"a" isn't an array}}
sl@0
   354
test set-old-8.9 {array command, donesearch option} {
sl@0
   355
    catch {unset a}
sl@0
   356
    list [catch {array donesearch a x} msg] $msg
sl@0
   357
} {1 {"a" isn't an array}}
sl@0
   358
test set-old-8.10 {array command, donesearch option, array doesn't exist yet but has compiler-allocated procedure slot} {
sl@0
   359
    proc foo {x} {
sl@0
   360
        if {$x==1} {
sl@0
   361
            return [array donesearch a x]
sl@0
   362
        }
sl@0
   363
        set a(x) 123
sl@0
   364
    }
sl@0
   365
    list [catch {foo 1} msg] $msg
sl@0
   366
} {1 {"a" isn't an array}}
sl@0
   367
test set-old-8.11 {array command, exists option} {
sl@0
   368
    list [catch {array exists a b} msg] $msg
sl@0
   369
} {1 {wrong # args: should be "array exists arrayName"}}
sl@0
   370
test set-old-8.12 {array command, exists option} {
sl@0
   371
    catch {unset a}
sl@0
   372
    array exists a
sl@0
   373
} {0}
sl@0
   374
test set-old-8.13 {array command, exists option} {
sl@0
   375
    catch {unset a}
sl@0
   376
    set a(0) 1
sl@0
   377
    array exists a
sl@0
   378
} {1}
sl@0
   379
test set-old-8.14 {array command, exists option, array doesn't exist yet but has compiler-allocated procedure slot} {
sl@0
   380
    proc foo {x} {
sl@0
   381
        if {$x==1} {
sl@0
   382
            return [array exists a]
sl@0
   383
        }
sl@0
   384
        set a(x) 123
sl@0
   385
    }
sl@0
   386
    list [catch {foo 1} msg] $msg
sl@0
   387
} {0 0}
sl@0
   388
test set-old-8.15 {array command, get option} {
sl@0
   389
    list [catch {array get} msg] $msg
sl@0
   390
} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
sl@0
   391
test set-old-8.16 {array command, get option} {
sl@0
   392
    list [catch {array get a b c} msg] $msg
sl@0
   393
} {1 {wrong # args: should be "array get arrayName ?pattern?"}}
sl@0
   394
test set-old-8.17 {array command, get option} {
sl@0
   395
    catch {unset a}
sl@0
   396
    array get a
sl@0
   397
} {}
sl@0
   398
test set-old-8.18 {array command, get option} {
sl@0
   399
    catch {unset a}
sl@0
   400
    set a(22) 3
sl@0
   401
    set {a(long name)} {}
sl@0
   402
    lsort [array get a]
sl@0
   403
} {{} 22 3 {long name}}
sl@0
   404
test set-old-8.19 {array command, get option (unset variable)} {
sl@0
   405
    catch {unset a}
sl@0
   406
    set a(x) 3
sl@0
   407
    trace var a(y) w ignore
sl@0
   408
    array get a
sl@0
   409
} {x 3}
sl@0
   410
test set-old-8.20 {array command, get option, with pattern} {
sl@0
   411
    catch {unset a}
sl@0
   412
    set a(x1) 3
sl@0
   413
    set a(x2) 4
sl@0
   414
    set a(x3) 5
sl@0
   415
    set a(b1) 24
sl@0
   416
    set a(b2) 25
sl@0
   417
    lsort [array get a x*]
sl@0
   418
} {3 4 5 x1 x2 x3}
sl@0
   419
test set-old-8.21 {array command, get option, array doesn't exist yet but has compiler-allocated procedure slot} {
sl@0
   420
    proc foo {x} {
sl@0
   421
        if {$x==1} {
sl@0
   422
            return [array get a]
sl@0
   423
        }
sl@0
   424
        set a(x) 123
sl@0
   425
    }
sl@0
   426
    list [catch {foo 1} msg] $msg
sl@0
   427
} {0 {}}
sl@0
   428
test set-old-8.22 {array command, names option} {
sl@0
   429
    catch {unset a}
sl@0
   430
    set a(22) 3
sl@0
   431
    list [catch {array names a 4 5} msg] $msg
sl@0
   432
} {1 {bad option "4": must be -exact, -glob, or -regexp}}
sl@0
   433
test set-old-8.23 {array command, names option} {
sl@0
   434
    catch {unset a}
sl@0
   435
    array names a
sl@0
   436
} {}
sl@0
   437
test set-old-8.24 {array command, names option} {
sl@0
   438
    catch {unset a}
sl@0
   439
    set a(22) 3; set a(Textual_name) 44; set "a(name with spaces)" xxx
sl@0
   440
    list [catch {lsort [array names a]} msg] $msg
sl@0
   441
} {0 {22 Textual_name {name with spaces}}}
sl@0
   442
test set-old-8.25 {array command, names option} {
sl@0
   443
    catch {unset a}
sl@0
   444
    set a(22) 3; set a(33) 44;
sl@0
   445
    trace var a(xxx) w ignore
sl@0
   446
    list [catch {lsort [array names a]} msg] $msg
sl@0
   447
} {0 {22 33}}
sl@0
   448
test set-old-8.26 {array command, names option} {
sl@0
   449
    catch {unset a}
sl@0
   450
    set a(22) 3; set a(33) 44;
sl@0
   451
    trace var a(xxx) w ignore
sl@0
   452
    set a(xxx) value
sl@0
   453
    list [catch {lsort [array names a]} msg] $msg
sl@0
   454
} {0 {22 33 xxx}}
sl@0
   455
test set-old-8.27 {array command, names option} {
sl@0
   456
    catch {unset a}
sl@0
   457
    set a(axy) 3
sl@0
   458
    set a(bxy) 44
sl@0
   459
    set a(no) yes
sl@0
   460
    set a(xxx) value
sl@0
   461
    list [lsort [array names a *xy]] [lsort [array names a]]
sl@0
   462
} {{axy bxy} {axy bxy no xxx}}
sl@0
   463
test set-old-8.28 {array command, names option, array doesn't exist yet but has compiler-allocated procedure slot} {
sl@0
   464
    proc foo {x} {
sl@0
   465
        if {$x==1} {
sl@0
   466
            return [array names a]
sl@0
   467
        }
sl@0
   468
        set a(x) 123
sl@0
   469
    }
sl@0
   470
    list [catch {foo 1} msg] $msg
sl@0
   471
} {0 {}}
sl@0
   472
test set-old-8.29 {array command, nextelement option} {
sl@0
   473
    list [catch {array nextelement a} msg] $msg
sl@0
   474
} {1 {wrong # args: should be "array nextelement arrayName searchId"}}
sl@0
   475
test set-old-8.30 {array command, nextelement option} {
sl@0
   476
    catch {unset a}
sl@0
   477
    list [catch {array nextelement a b} msg] $msg
sl@0
   478
} {1 {"a" isn't an array}}
sl@0
   479
test set-old-8.31 {array command, nextelement option, array doesn't exist yet but has compiler-allocated procedure slot} {
sl@0
   480
    proc foo {x} {
sl@0
   481
        if {$x==1} {
sl@0
   482
            return [array nextelement a b]
sl@0
   483
        }
sl@0
   484
        set a(x) 123
sl@0
   485
    }
sl@0
   486
    list [catch {foo 1} msg] $msg
sl@0
   487
} {1 {"a" isn't an array}}
sl@0
   488
test set-old-8.32 {array command, set option} {
sl@0
   489
    list [catch {array set a} msg] $msg
sl@0
   490
} {1 {wrong # args: should be "array set arrayName list"}}
sl@0
   491
test set-old-8.33 {array command, set option} {
sl@0
   492
    list [catch {array set a 1 2} msg] $msg
sl@0
   493
} {1 {wrong # args: should be "array set arrayName list"}}
sl@0
   494
test set-old-8.34 {array command, set option} {
sl@0
   495
    list [catch {array set a "a \{ c"} msg] $msg
sl@0
   496
} {1 {unmatched open brace in list}}
sl@0
   497
test set-old-8.35 {array command, set option} {
sl@0
   498
    catch {unset a}
sl@0
   499
    set a 44
sl@0
   500
    list [catch {array set a {a b c d}} msg] $msg
sl@0
   501
} {1 {can't set "a(a)": variable isn't array}}
sl@0
   502
test set-old-8.36 {array command, set option} {
sl@0
   503
    catch {unset a}
sl@0
   504
    set a(xx) yy
sl@0
   505
    array set a {b c d e}
sl@0
   506
    lsort [array get a]
sl@0
   507
} {b c d e xx yy}
sl@0
   508
test set-old-8.37 {array command, set option, array doesn't exist yet but has compiler-allocated procedure slot} {
sl@0
   509
    proc foo {x} {
sl@0
   510
        if {$x==1} {
sl@0
   511
            return [array set a {x 0}]
sl@0
   512
        }
sl@0
   513
        set a(x)
sl@0
   514
    }
sl@0
   515
    list [catch {foo 1} msg] $msg
sl@0
   516
} {0 {}}
sl@0
   517
test set-old-8.38 {array command, set option} {
sl@0
   518
    catch {unset aVaRnAmE}
sl@0
   519
    array set aVaRnAmE {}
sl@0
   520
    list [info exists aVaRnAmE] [catch {set aVaRnAmE} msg] $msg
sl@0
   521
} {1 1 {can't read "aVaRnAmE": variable is array}}
sl@0
   522
test set-old-8.38.1 {array command, set scalar} {
sl@0
   523
    catch {unset aVaRnAmE}
sl@0
   524
    set aVaRnAmE 1
sl@0
   525
    list [catch {array set aVaRnAmE {}} msg] $msg
sl@0
   526
} {1 {can't array set "aVaRnAmE": variable isn't array}}
sl@0
   527
test set-old-8.38.2 {array command, set alias} {
sl@0
   528
    catch {unset aVaRnAmE}
sl@0
   529
    upvar 0 aVaRnAmE anAliAs
sl@0
   530
    array set anAliAs {}
sl@0
   531
    list [array exists aVaRnAmE] [catch {set anAliAs} msg] $msg
sl@0
   532
} {1 1 {can't read "anAliAs": variable is array}}
sl@0
   533
test set-old-8.38.3 {array command, set element alias} {
sl@0
   534
    catch {unset aVaRnAmE}
sl@0
   535
    list [catch {upvar 0 aVaRnAmE(elem) elemAliAs}] \
sl@0
   536
	    [catch {array set elemAliAs {}} msg] $msg
sl@0
   537
} {0 1 {can't array set "elemAliAs": variable isn't array}}
sl@0
   538
test set-old-8.38.4 {array command, empty set with populated array} {
sl@0
   539
    catch {unset aVaRnAmE}
sl@0
   540
    array set aVaRnAmE [list e1 v1 e2 v2]
sl@0
   541
    array set aVaRnAmE {}
sl@0
   542
    array set aVaRnAmE [list e3 v3]
sl@0
   543
    list [lsort [array names aVaRnAmE]] [catch {set aVaRnAmE(e2)} msg] $msg
sl@0
   544
} {{e1 e2 e3} 0 v2}
sl@0
   545
test set-old-8.38.5 {array command, set with non-existent namespace} {
sl@0
   546
    list [catch {array set bogusnamespace::var {}} msg] $msg
sl@0
   547
} {1 {can't set "bogusnamespace::var": parent namespace doesn't exist}}
sl@0
   548
test set-old-8.38.6 {array command, set with non-existent namespace} {
sl@0
   549
    list [catch {array set bogusnamespace::var {a b}} msg] $msg
sl@0
   550
} {1 {can't set "bogusnamespace::var": parent namespace doesn't exist}}
sl@0
   551
test set-old-8.38.7 {array command, set with non-existent namespace} {
sl@0
   552
    list [catch {array set bogusnamespace::var(0) {a b}} msg] $msg
sl@0
   553
} {1 {can't set "bogusnamespace::var(0)": variable isn't array}}
sl@0
   554
test set-old-8.39 {array command, size option} {
sl@0
   555
    catch {unset a}
sl@0
   556
    array size a
sl@0
   557
} {0}
sl@0
   558
test set-old-8.40 {array command, size option} {
sl@0
   559
    list [catch {array size a 4} msg] $msg
sl@0
   560
} {1 {wrong # args: should be "array size arrayName"}}
sl@0
   561
test set-old-8.41 {array command, size option} {
sl@0
   562
    catch {unset a}
sl@0
   563
    array size a
sl@0
   564
} {0}
sl@0
   565
test set-old-8.42 {array command, size option} {
sl@0
   566
    catch {unset a}
sl@0
   567
    set a(22) 3; set a(Textual_name) 44; set "a(name with spaces)" xxx
sl@0
   568
    list [catch {array size a} msg] $msg
sl@0
   569
} {0 3}
sl@0
   570
test set-old-8.43 {array command, size option} {
sl@0
   571
    catch {unset a}
sl@0
   572
    set a(22) 3; set a(xx) 44; set a(y) xxx
sl@0
   573
    unset a(22) a(y) a(xx)
sl@0
   574
    list [catch {array size a} msg] $msg
sl@0
   575
} {0 0}
sl@0
   576
test set-old-8.44 {array command, size option} {
sl@0
   577
    catch {unset a}
sl@0
   578
    set a(22) 3;
sl@0
   579
    trace var a(33) rwu ignore
sl@0
   580
    list [catch {array size a} msg] $msg
sl@0
   581
} {0 1}
sl@0
   582
test set-old-8.45 {array command, size option, array doesn't exist yet but has compiler-allocated procedure slot} {
sl@0
   583
    proc foo {x} {
sl@0
   584
        if {$x==1} {
sl@0
   585
            return [array size a]
sl@0
   586
        }
sl@0
   587
        set a(x) 123
sl@0
   588
    }
sl@0
   589
    list [catch {foo 1} msg] $msg
sl@0
   590
} {0 0}
sl@0
   591
test set-old-8.46 {array command, startsearch option} {
sl@0
   592
    list [catch {array startsearch a b} msg] $msg
sl@0
   593
} {1 {wrong # args: should be "array startsearch arrayName"}}
sl@0
   594
test set-old-8.47 {array command, startsearch option} {
sl@0
   595
    catch {unset a}
sl@0
   596
    list [catch {array startsearch a} msg] $msg
sl@0
   597
} {1 {"a" isn't an array}}
sl@0
   598
test set-old-8.48 {array command, startsearch option, array doesn't exist yet but has compiler-allocated procedure slot} {
sl@0
   599
    catch {rename p ""}
sl@0
   600
    proc p {x} {
sl@0
   601
        if {$x==1} {
sl@0
   602
            return [array startsearch a]
sl@0
   603
        }
sl@0
   604
        set a(x) 123
sl@0
   605
    }
sl@0
   606
    list [catch {p 1} msg] $msg
sl@0
   607
} {1 {"a" isn't an array}}
sl@0
   608
test set-old-8.49 {array command, statistics option} {
sl@0
   609
    catch {unset a}
sl@0
   610
    set a(abc) 1
sl@0
   611
    set a(def) 2
sl@0
   612
    set a(ghi) 3
sl@0
   613
    set a(jkl) 4
sl@0
   614
    set a(mno) 5
sl@0
   615
    set a(pqr) 6
sl@0
   616
    set a(stu) 7
sl@0
   617
    set a(vwx) 8
sl@0
   618
    set a(yz) 9
sl@0
   619
    array statistics a
sl@0
   620
} "9 entries in table, 4 buckets
sl@0
   621
number of buckets with 0 entries: 0
sl@0
   622
number of buckets with 1 entries: 0
sl@0
   623
number of buckets with 2 entries: 3
sl@0
   624
number of buckets with 3 entries: 1
sl@0
   625
number of buckets with 4 entries: 0
sl@0
   626
number of buckets with 5 entries: 0
sl@0
   627
number of buckets with 6 entries: 0
sl@0
   628
number of buckets with 7 entries: 0
sl@0
   629
number of buckets with 8 entries: 0
sl@0
   630
number of buckets with 9 entries: 0
sl@0
   631
number of buckets with 10 or more entries: 0
sl@0
   632
average search distance for entry: 1.7"
sl@0
   633
test set-old-8.50 {array command, array names -exact on glob pattern} {
sl@0
   634
    catch {unset a}
sl@0
   635
    set a(1*2) 1
sl@0
   636
    list [catch {array names a -exact 1*2} msg] $msg
sl@0
   637
} {0 1*2}
sl@0
   638
test set-old-8.51 {array command, array names -glob on glob pattern} {
sl@0
   639
    catch {unset a}
sl@0
   640
    set a(1*2) 1
sl@0
   641
    set a(12) 1
sl@0
   642
    set a(11) 1
sl@0
   643
    list [catch {lsort [array names a -glob 1*2]} msg] $msg
sl@0
   644
} {0 {1*2 12}}
sl@0
   645
test set-old-8.52 {array command, array names -regexp on regexp pattern} {
sl@0
   646
    catch {unset a}
sl@0
   647
    set a(1*2) 1
sl@0
   648
    set a(12) 1
sl@0
   649
    set a(11) 1
sl@0
   650
    list [catch {lsort [array names a -regexp ^1]} msg] $msg
sl@0
   651
} {0 {1*2 11 12}}
sl@0
   652
test set-old-8.53 {array command, array names -regexp} {
sl@0
   653
    catch {unset a}
sl@0
   654
    set a(-glob) 1
sl@0
   655
    set a(-regexp) 1
sl@0
   656
    set a(-exact) 1
sl@0
   657
    list [catch {array names a -regexp} msg] $msg
sl@0
   658
} {0 -regexp}
sl@0
   659
test set-old-8.54 {array command, array names -exact} {
sl@0
   660
    catch {unset a}
sl@0
   661
    set a(-glob) 1
sl@0
   662
    set a(-regexp) 1
sl@0
   663
    set a(-exact) 1
sl@0
   664
    list [catch {array names a -exact} msg] $msg
sl@0
   665
} {0 -exact}
sl@0
   666
test set-old-8.55 {array command, array names -glob} {
sl@0
   667
    catch {unset a}
sl@0
   668
    set a(-glob) 1
sl@0
   669
    set a(-regexp) 1
sl@0
   670
    set a(-exact) 1
sl@0
   671
    list [catch {array names a -glob} msg] $msg
sl@0
   672
} {0 -glob}
sl@0
   673
test set-old-8.56 {array command, array statistics on a non-array} {
sl@0
   674
	catch {unset a}
sl@0
   675
	list [catch {array statistics a} msg] $msg
sl@0
   676
} [list 1 "\"a\" isn't an array"]
sl@0
   677
sl@0
   678
test set-old-9.1 {ids for array enumeration} {
sl@0
   679
    catch {unset a}
sl@0
   680
    set a(a) 1
sl@0
   681
    list [array star a] [array star a] [array done a s-1-a; array star a] \
sl@0
   682
	    [array done a s-2-a; array d a s-3-a; array start a]
sl@0
   683
} {s-1-a s-2-a s-3-a s-1-a}
sl@0
   684
test set-old-9.2 {array enumeration} {
sl@0
   685
    catch {unset a}
sl@0
   686
    set a(a) 1
sl@0
   687
    set a(b) 1
sl@0
   688
    set a(c) 1
sl@0
   689
    set x [array startsearch a]
sl@0
   690
    lsort [list [array nextelement a $x] [array ne a $x] [array next a $x] \
sl@0
   691
	    [array next a $x] [array next a $x]]
sl@0
   692
} {{} {} a b c}
sl@0
   693
test set-old-9.3 {array enumeration} {
sl@0
   694
    catch {unset a}
sl@0
   695
    set a(a) 1
sl@0
   696
    set a(b) 1
sl@0
   697
    set a(c) 1
sl@0
   698
    set x [array startsearch a]
sl@0
   699
    set y [array startsearch a]
sl@0
   700
    set z [array startsearch a]
sl@0
   701
    lsort [list [array nextelement a $x] [array ne a $x] \
sl@0
   702
	    [array next a $y] [array next a $z] [array next a $y] \
sl@0
   703
	    [array next a $z] [array next a $y] [array next a $z] \
sl@0
   704
	    [array next a $y] [array next a $z] [array next a $x] \
sl@0
   705
	    [array next a $x]]
sl@0
   706
} {{} {} {} a a a b b b c c c}
sl@0
   707
test set-old-9.4 {array enumeration: stopping searches} {
sl@0
   708
    catch {unset a}
sl@0
   709
    set a(a) 1
sl@0
   710
    set a(b) 1
sl@0
   711
    set a(c) 1
sl@0
   712
    set x [array startsearch a]
sl@0
   713
    set y [array startsearch a]
sl@0
   714
    set z [array startsearch a]
sl@0
   715
    lsort [list [array next a $x] [array next a $x] [array next a $y] \
sl@0
   716
	    [array done a $z; array next a $x] \
sl@0
   717
	    [array done a $x; array next a $y] [array next a $y]]
sl@0
   718
} {a a b b c c}
sl@0
   719
test set-old-9.5 {array enumeration: stopping searches} {
sl@0
   720
    catch {unset a}
sl@0
   721
    set a(a) 1
sl@0
   722
    set x [array startsearch a]
sl@0
   723
    array done a $x
sl@0
   724
    list [catch {array next a $x} msg] $msg
sl@0
   725
} {1 {couldn't find search "s-1-a"}}
sl@0
   726
test set-old-9.6 {array enumeration: searches automatically stopped} {
sl@0
   727
    catch {unset a}
sl@0
   728
    set a(a) 1
sl@0
   729
    set x [array startsearch a]
sl@0
   730
    set y [array startsearch a]
sl@0
   731
    set a(b) 1
sl@0
   732
    list [catch {array next a $x} msg] $msg \
sl@0
   733
	    [catch {array next a $y} msg2] $msg2
sl@0
   734
} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
sl@0
   735
test set-old-9.7 {array enumeration: searches automatically stopped} {
sl@0
   736
    catch {unset a}
sl@0
   737
    set a(a) 1
sl@0
   738
    set x [array startsearch a]
sl@0
   739
    set y [array startsearch a]
sl@0
   740
    set a(a) 2
sl@0
   741
    list [catch {array next a $x} msg] $msg \
sl@0
   742
	    [catch {array next a $y} msg2] $msg2
sl@0
   743
} {0 a 0 a}
sl@0
   744
test set-old-9.8 {array enumeration: searches automatically stopped} {
sl@0
   745
    catch {unset a}
sl@0
   746
    set a(a) 1
sl@0
   747
    set a(c) 2
sl@0
   748
    set x [array startsearch a]
sl@0
   749
    set y [array startsearch a]
sl@0
   750
    catch {unset a(c)}
sl@0
   751
    list [catch {array next a $x} msg] $msg \
sl@0
   752
	    [catch {array next a $y} msg2] $msg2
sl@0
   753
} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
sl@0
   754
test set-old-9.9 {array enumeration: searches automatically stopped} {
sl@0
   755
    catch {unset a}
sl@0
   756
    set a(a) 1
sl@0
   757
    set x [array startsearch a]
sl@0
   758
    set y [array startsearch a]
sl@0
   759
    catch {unset a(c)}
sl@0
   760
    list [catch {array next a $x} msg] $msg \
sl@0
   761
	    [catch {array next a $y} msg2] $msg2
sl@0
   762
} {0 a 0 a}
sl@0
   763
test set-old-9.10 {array enumeration: searches automatically stopped} {
sl@0
   764
    catch {unset a}
sl@0
   765
    set a(a) 1
sl@0
   766
    set x [array startsearch a]
sl@0
   767
    set y [array startsearch a]
sl@0
   768
    trace var a(b) r {}
sl@0
   769
    list [catch {array next a $x} msg] $msg \
sl@0
   770
	    [catch {array next a $y} msg2] $msg2
sl@0
   771
} {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
sl@0
   772
test set-old-9.11 {array enumeration: searches automatically stopped} {
sl@0
   773
    catch {unset a}
sl@0
   774
    set a(a) 1
sl@0
   775
    set x [array startsearch a]
sl@0
   776
    set y [array startsearch a]
sl@0
   777
    trace var a(a) r {}
sl@0
   778
    list [catch {array next a $x} msg] $msg \
sl@0
   779
	    [catch {array next a $y} msg2] $msg2
sl@0
   780
} {0 a 0 a}
sl@0
   781
test set-old-9.12 {array enumeration with traced undefined elements} {
sl@0
   782
    catch {unset a}
sl@0
   783
    set a(a) 1
sl@0
   784
    trace var a(b) r {}
sl@0
   785
    set x [array startsearch a]
sl@0
   786
    lsort [list [array next a $x] [array next a $x]]
sl@0
   787
} {{} a}
sl@0
   788
sl@0
   789
test set-old-10.1 {array enumeration errors} {
sl@0
   790
    list [catch {array start} msg] $msg
sl@0
   791
} {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
sl@0
   792
test set-old-10.2 {array enumeration errors} {
sl@0
   793
    list [catch {array start a b} msg] $msg
sl@0
   794
} {1 {wrong # args: should be "array startsearch arrayName"}}
sl@0
   795
test set-old-10.3 {array enumeration errors} {
sl@0
   796
    catch {unset a}
sl@0
   797
    list [catch {array start a} msg] $msg
sl@0
   798
} {1 {"a" isn't an array}}
sl@0
   799
test set-old-10.4 {array enumeration errors} {
sl@0
   800
    catch {unset a}
sl@0
   801
    set a(a) 1
sl@0
   802
    set x [array startsearch a]
sl@0
   803
    list [catch {array next a} msg] $msg
sl@0
   804
} {1 {wrong # args: should be "array nextelement arrayName searchId"}}
sl@0
   805
test set-old-10.5 {array enumeration errors} {
sl@0
   806
    catch {unset a}
sl@0
   807
    set a(a) 1
sl@0
   808
    set x [array startsearch a]
sl@0
   809
    list [catch {array next a b c} msg] $msg
sl@0
   810
} {1 {wrong # args: should be "array nextelement arrayName searchId"}}
sl@0
   811
test set-old-10.6 {array enumeration errors} {
sl@0
   812
    catch {unset a}
sl@0
   813
    set a(a) 1
sl@0
   814
    set x [array startsearch a]
sl@0
   815
    list [catch {array next a a-1-a} msg] $msg
sl@0
   816
} {1 {illegal search identifier "a-1-a"}}
sl@0
   817
test set-old-10.7 {array enumeration errors} {
sl@0
   818
    catch {unset a}
sl@0
   819
    set a(a) 1
sl@0
   820
    set x [array startsearch a]
sl@0
   821
    list [catch {array next a sx1-a} msg] $msg
sl@0
   822
} {1 {illegal search identifier "sx1-a"}}
sl@0
   823
test set-old-10.8 {array enumeration errors} {
sl@0
   824
    catch {unset a}
sl@0
   825
    set a(a) 1
sl@0
   826
    set x [array startsearch a]
sl@0
   827
    list [catch {array next a s--a} msg] $msg
sl@0
   828
} {1 {illegal search identifier "s--a"}}
sl@0
   829
test set-old-10.9 {array enumeration errors} {
sl@0
   830
    catch {unset a}
sl@0
   831
    set a(a) 1
sl@0
   832
    set x [array startsearch a]
sl@0
   833
    list [catch {array next a s-1-b} msg] $msg
sl@0
   834
} {1 {search identifier "s-1-b" isn't for variable "a"}}
sl@0
   835
test set-old-10.10 {array enumeration errors} {
sl@0
   836
    catch {unset a}
sl@0
   837
    set a(a) 1
sl@0
   838
    set x [array startsearch a]
sl@0
   839
    list [catch {array next a s-1ba} msg] $msg
sl@0
   840
} {1 {illegal search identifier "s-1ba"}}
sl@0
   841
test set-old-10.11 {array enumeration errors} {
sl@0
   842
    catch {unset a}
sl@0
   843
    set a(a) 1
sl@0
   844
    set x [array startsearch a]
sl@0
   845
    list [catch {array next a s-2-a} msg] $msg
sl@0
   846
} {1 {couldn't find search "s-2-a"}}
sl@0
   847
test set-old-10.12 {array enumeration errors} {
sl@0
   848
    list [catch {array done a} msg] $msg
sl@0
   849
} {1 {wrong # args: should be "array donesearch arrayName searchId"}}
sl@0
   850
test set-old-10.13 {array enumeration errors} {
sl@0
   851
    list [catch {array done a b c} msg] $msg
sl@0
   852
} {1 {wrong # args: should be "array donesearch arrayName searchId"}}
sl@0
   853
test set-old-10.14 {array enumeration errors} {
sl@0
   854
    list [catch {array done a b} msg] $msg
sl@0
   855
} {1 {illegal search identifier "b"}}
sl@0
   856
test set-old-10.15 {array enumeration errors} {
sl@0
   857
    list [catch {array anymore a} msg] $msg
sl@0
   858
} {1 {wrong # args: should be "array anymore arrayName searchId"}}
sl@0
   859
test set-old-10.16 {array enumeration errors} {
sl@0
   860
    list [catch {array any a b c} msg] $msg
sl@0
   861
} {1 {wrong # args: should be "array anymore arrayName searchId"}}
sl@0
   862
test set-old-10.17 {array enumeration errors} {
sl@0
   863
    catch {unset a}
sl@0
   864
    set a(0) 44
sl@0
   865
    list [catch {array any a bogus} msg] $msg
sl@0
   866
} {1 {illegal search identifier "bogus"}}
sl@0
   867
sl@0
   868
# Array enumeration with "anymore" option
sl@0
   869
sl@0
   870
test set-old-11.1 {array anymore option} {
sl@0
   871
    catch {unset a}
sl@0
   872
    set a(a) 1
sl@0
   873
    set a(b) 2
sl@0
   874
    set a(c) 3
sl@0
   875
    array startsearch a
sl@0
   876
    lsort [list [array anymore a s-1-a] [array next a s-1-a] \
sl@0
   877
	    [array anymore a s-1-a] [array next a s-1-a] \
sl@0
   878
	    [array anymore a s-1-a] [array next a s-1-a] \
sl@0
   879
	    [array anymore a s-1-a] [array next a s-1-a]]
sl@0
   880
} {{} 0 1 1 1 a b c}
sl@0
   881
test set-old-11.2 {array anymore option} {
sl@0
   882
    catch {unset a}
sl@0
   883
    set a(a) 1
sl@0
   884
    set a(b) 2
sl@0
   885
    set a(c) 3
sl@0
   886
    array startsearch a
sl@0
   887
    lsort [list [array next a s-1-a] [array next a s-1-a] \
sl@0
   888
	    [array anymore a s-1-a] [array next a s-1-a] \
sl@0
   889
	    [array next a s-1-a] [array anymore a s-1-a]]
sl@0
   890
} {{} 0 1 a b c}
sl@0
   891
sl@0
   892
# Special check to see that the value of a variable is handled correctly
sl@0
   893
# if it is returned as the result of a procedure (must not free the variable
sl@0
   894
# string while deleting the call frame).  Errors will only be detected if
sl@0
   895
# a memory consistency checker such as Purify is being used.
sl@0
   896
sl@0
   897
test set-old-12.1 {cleanup on procedure return} {
sl@0
   898
    proc foo {} {
sl@0
   899
	set x 12345
sl@0
   900
    }
sl@0
   901
    foo
sl@0
   902
} 12345
sl@0
   903
test set-old-12.2 {cleanup on procedure return} {
sl@0
   904
    proc foo {} {
sl@0
   905
	set x(1) 23456
sl@0
   906
    }
sl@0
   907
    foo
sl@0
   908
} 23456
sl@0
   909
sl@0
   910
# Must delete variables when done, since these arrays get used as
sl@0
   911
# scalars by other tests.
sl@0
   912
catch {unset a}
sl@0
   913
catch {unset b}
sl@0
   914
catch {unset c}
sl@0
   915
catch {unset aVaRnAmE}
sl@0
   916
sl@0
   917
# cleanup
sl@0
   918
::tcltest::cleanupTests
sl@0
   919
return