home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / tests / set-old.test < prev    next >
Encoding:
Text File  |  1997-08-15  |  21.6 KB  |  680 lines  |  [TEXT/ALFA]

  1. # Commands covered:  set, unset, array
  2. #
  3. # This file includes the original set of tests for Tcl's set command.
  4. # Since the set command is now compiled, a new set of tests covering
  5. # the new implementation is in the file "set.test". Sourcing this file
  6. # into Tcl runs the tests and generates output for errors.
  7. # No output means no errors were found.
  8. #
  9. # Copyright (c) 1991-1993 The Regents of the University of California.
  10. # Copyright (c) 1994-1996 Sun Microsystems, Inc.
  11. #
  12. # See the file "license.terms" for information on usage and redistribution
  13. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  14. #
  15. # SCCS: @(#) set-old.test 1.20 97/07/25 17:45:55
  16.  
  17. if {[string compare test [info procs test]] == 1} then {source defs}
  18.  
  19. proc ignore args {}
  20.  
  21. # Simple variable operations.
  22.  
  23. catch {unset a}
  24. test set-old-1.1 {basic variable setting and unsetting} {
  25.     set a 22
  26. } 22
  27. test set-old-1.2 {basic variable setting and unsetting} {
  28.     set a 123
  29.     set a
  30. } 123
  31. test set-old-1.3 {basic variable setting and unsetting} {
  32.     set a xxx
  33.     format %s $a
  34. } xxx
  35. test set-old-1.4 {basic variable setting and unsetting} {
  36.     set a 44
  37.     unset a
  38.     list [catch {set a} msg] $msg
  39. } {1 {can't read "a": no such variable}}
  40.  
  41. # Basic array operations.
  42.  
  43. catch {unset a}
  44. set a(xyz) 2
  45. set a(44) 3
  46. set {a(a long name)} test
  47. test set-old-2.1 {basic array operations} {
  48.     lsort [array names a]
  49. } {44 {a long name} xyz}
  50. test set-old-2.2 {basic array operations} {
  51.     set a(44)
  52. } 3
  53. test set-old-2.3 {basic array operations} {
  54.     set a(xyz)
  55. } 2
  56. test set-old-2.4 {basic array operations} {
  57.     set "a(a long name)"
  58. } test
  59. test set-old-2.5 {basic array operations} {
  60.     list [catch {set a(other)} msg] $msg
  61. } {1 {can't read "a(other)": no such element in array}}
  62. test set-old-2.6 {basic array operations} {
  63.     list [catch {set a} msg] $msg
  64. } {1 {can't read "a": variable is array}}
  65. test set-old-2.7 {basic array operations} {
  66.     format %s $a(44)
  67. } 3
  68. test set-old-2.8 {basic array operations} {
  69.     format %s $a(a long name)
  70. } test
  71. unset a(44)
  72. test set-old-2.9 {basic array operations} {
  73.     lsort [array names a]
  74. } {{a long name} xyz}
  75. test set-old-2.10 {basic array operations} {
  76.     catch {unset b}
  77.     list [catch {set b(123)} msg] $msg
  78. } {1 {can't read "b(123)": no such variable}}
  79. test set-old-2.11 {basic array operations} {
  80.     catch {unset b}
  81.     set b 44
  82.     list [catch {set b(123)} msg] $msg
  83. } {1 {can't read "b(123)": variable isn't array}}
  84. test set-old-2.12 {basic array operations} {
  85.     list [catch {set a 14} msg] $msg
  86. } {1 {can't set "a": variable is array}}
  87. unset a
  88. test set-old-2.13 {basic array operations} {
  89.     list [catch {set a(xyz)} msg] $msg
  90. } {1 {can't read "a(xyz)": no such variable}}
  91.  
  92. # Test the set commands, and exercise the corner cases of the code
  93. # that parses array references into two parts.
  94.  
  95. test set-old-3.1 {set command} {
  96.     list [catch {set} msg] $msg
  97. } {1 {wrong # args: should be "set varName ?newValue?"}}
  98. test set-old-3.2 {set command} {
  99.     list [catch {set x y z} msg] $msg
  100. } {1 {wrong # args: should be "set varName ?newValue?"}}
  101. test set-old-3.3 {set command} {
  102.     catch {unset a}
  103.     list [catch {set a} msg] $msg
  104. } {1 {can't read "a": no such variable}}
  105. test set-old-3.4 {set command} {
  106.     catch {unset a}
  107.     set a(14) 83
  108.     list [catch {set a 22} msg] $msg
  109. } {1 {can't set "a": variable is array}}
  110.  
  111. # Test the corner-cases of parsing array names, using set and unset.
  112.  
  113. test set-old-4.1 {parsing array names} {
  114.     catch {unset a}
  115.     set a(()) 44
  116.     list [catch {array names a} msg] $msg
  117. } {0 ()}
  118. test set-old-4.2 {parsing array names} {
  119.     catch {unset a a(abcd}
  120.     set a(abcd 33
  121.     info exists a(abcd
  122. } 1
  123. test set-old-4.3 {parsing array names} {
  124.     catch {unset a a(abcd}
  125.     set a(abcd 33
  126.     list [catch {array names a} msg] $msg
  127. } {0 {}}
  128. test set-old-4.4 {parsing array names} {
  129.     catch {unset a abcd)}
  130.     set abcd) 33
  131.     info exists abcd)
  132. } 1
  133. test set-old-4.5 {parsing array names} {
  134.     set a(bcd yyy
  135.     catch {unset a}
  136.     list [catch {set a(bcd} msg] $msg
  137. } {0 yyy}
  138. test set-old-4.6 {parsing array names} {
  139.     catch {unset a}
  140.     set a 44
  141.     list [catch {set a(bcd test} msg] $msg
  142. } {0 test}
  143.  
  144. # Errors in reading variables
  145.  
  146. test set-old-5.1 {errors in reading variables} {
  147.     catch {unset a}
  148.     list [catch {set a} msg] $msg
  149. } {1 {can't read "a": no such variable}}
  150. test set-old-5.2 {errors in reading variables} {
  151.     catch {unset a}
  152.     set a 44
  153.     list [catch {set a(18)} msg] $msg
  154. } {1 {can't read "a(18)": variable isn't array}}
  155. test set-old-5.3 {errors in reading variables} {
  156.     catch {unset a}
  157.     set a(6) 44
  158.     list [catch {set a(18)} msg] $msg
  159. } {1 {can't read "a(18)": no such element in array}}
  160. test set-old-5.4 {errors in reading variables} {
  161.     catch {unset a}
  162.     set a(6) 44
  163.     list [catch {set a} msg] $msg
  164. } {1 {can't read "a": variable is array}}
  165.  
  166. # Errors and other special cases in writing variables
  167.  
  168. test set-old-6.1 {creating array during write} {
  169.     catch {unset a}
  170.     trace var a rwu ignore
  171.     list [catch {set a(14) 186} msg] $msg [array names a]
  172. } {0 186 14}
  173. test set-old-6.2 {errors in writing variables} {
  174.     catch {unset a}
  175.     set a xxx
  176.     list [catch {set a(14) 186} msg] $msg
  177. } {1 {can't set "a(14)": variable isn't array}}
  178. test set-old-6.3 {errors in writing variables} {
  179.     catch {unset a}
  180.     set a(100) yyy
  181.     list [catch {set a 2} msg] $msg
  182. } {1 {can't set "a": variable is array}}
  183. test set-old-6.4 {expanding variable size} {
  184.     catch {unset a}
  185.     list [set a short] [set a "longer name"] [set a "even longer name"] \
  186.         [set a "a much much truly longer name"]
  187. } {short {longer name} {even longer name} {a much much truly longer name}}
  188.  
  189. # Unset command, Tcl_UnsetVar procedures
  190.  
  191. test set-old-7.1 {unset command} {
  192.     catch {unset a}; catch {unset b}; catch {unset c}; catch {unset d}
  193.     set a 44
  194.     set b 55
  195.     set c 66
  196.     set d 77
  197.     unset a b c
  198.     list [catch {set a(0) 0}] [catch {set b(0) 0}] [catch {set c(0) 0}] \
  199.         [catch {set d(0) 0}]
  200. } {0 0 0 1}
  201. test set-old-7.2 {unset command} {
  202.     list [catch {unset} msg] $msg
  203. } {1 {wrong # args: should be "unset varName ?varName ...?"}}
  204. test set-old-7.3 {unset command} {
  205.     catch {unset a}
  206.     list [catch {unset a} msg] $msg
  207. } {1 {can't unset "a": no such variable}}
  208. test set-old-7.4 {unset command} {
  209.     catch {unset a}
  210.     set a 44
  211.     list [catch {unset a(14)} msg] $msg
  212. } {1 {can't unset "a(14)": variable isn't array}}
  213. test set-old-7.5 {unset command} {
  214.     catch {unset a}
  215.     set a(0) xx
  216.     list [catch {unset a(14)} msg] $msg
  217. } {1 {can't unset "a(14)": no such element in array}}
  218. test set-old-7.6 {unset command} {
  219.     catch {unset a}; catch {unset b}; catch {unset c}
  220.     set a foo
  221.     set c gorp
  222.     list [catch {unset a a a(14)} msg] $msg [info exists c]
  223. } {1 {can't unset "a": no such variable} 1}
  224. test set-old-7.7 {unsetting globals from within procedures} {
  225.     set y 0
  226.     proc p1 {} {
  227.     global y
  228.     set z [p2]
  229.     return [list $z [catch {set y} msg] $msg]
  230.     }
  231.     proc p2 {} {global y; unset y; list [catch {set y} msg] $msg}
  232.     p1
  233. } {{1 {can't read "y": no such variable}} 1 {can't read "y": no such variable}}
  234. test set-old-7.8 {unsetting globals from within procedures} {
  235.     set y 0
  236.     proc p1 {} {
  237.     global y
  238.     p2
  239.     return [list [catch {set y 44} msg] $msg]
  240.     }
  241.     proc p2 {} {global y; unset y}
  242.     concat [p1] [list [catch {set y} msg] $msg]
  243. } {0 44 0 44}
  244. test set-old-7.9 {unsetting globals from within procedures} {
  245.     set y 0
  246.     proc p1 {} {
  247.     global y
  248.     unset y
  249.     return [list [catch {set y 55} msg] $msg]
  250.     }
  251.     concat [p1] [list [catch {set y} msg] $msg]
  252. } {0 55 0 55}
  253. test set-old-7.10 {unset command} {
  254.     catch {unset a}
  255.     set a(14) 22
  256.     unset a(14)
  257.     list [catch {set a(14)} msg] $msg [catch {array names a} msg2] $msg2
  258. } {1 {can't read "a(14)": no such element in array} 0 {}}
  259. test set-old-7.11 {unset command} {
  260.     catch {unset a}
  261.     set a(14) 22
  262.     unset a
  263.     list [catch {set a(14)} msg] $msg [catch {array names a} msg2] $msg2
  264. } {1 {can't read "a(14)": no such variable} 0 {}}
  265.  
  266. # Array command.
  267.  
  268. test set-old-8.1 {array command} {
  269.     list [catch {array} msg] $msg
  270. } {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
  271. test set-old-8.2 {array command} {
  272.     list [catch {array a} msg] $msg
  273. } {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
  274. test set-old-8.3 {array command} {
  275.     catch {unset a}
  276.     list [catch {array anymore a b} msg] $msg
  277. } {1 {"a" isn't an array}}
  278. test set-old-8.4 {array command} {
  279.     catch {unset a}
  280.     set a 44
  281.     list [catch {array anymore a b} msg] $msg
  282. } {1 {"a" isn't an array}}
  283. test set-old-8.5 {array command} {
  284.     proc foo {} {
  285.     set a 44
  286.     upvar 0 a x
  287.     list [catch {array anymore x b} msg] $msg
  288.     }
  289.     foo
  290. } {1 {"x" isn't an array}}
  291. test set-old-8.6 {array command} {
  292.     catch {unset a}
  293.     set a(22) 3
  294.     list [catch {array gorp a} msg] $msg
  295. } {1 {bad option "gorp": must be anymore, donesearch, exists, get, names, nextelement, set, size, or startsearch}}
  296. test set-old-8.7 {array command, anymore option} {
  297.     catch {unset a}
  298.     list [catch {array anymore a x} msg] $msg
  299. } {1 {"a" isn't an array}}
  300. test set-old-8.8 {array command, donesearch option} {
  301.     catch {unset a}
  302.     list [catch {array donesearch a x} msg] $msg
  303. } {1 {"a" isn't an array}}
  304. test set-old-8.9 {array command, exists option} {
  305.     list [catch {array exists a b} msg] $msg
  306. } {1 {wrong # args: should be "array exists arrayName"}}
  307. test set-old-8.10 {array command, exists option} {
  308.     catch {unset a}
  309.     array exists a
  310. } {0}
  311. test set-old-8.11 {array command, exists option} {
  312.     catch {unset a}
  313.     set a(0) 1
  314.     array exists a
  315. } {1}
  316. test set-old-8.12 {array command, get option} {
  317.     list [catch {array get} msg] $msg
  318. } {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
  319. test set-old-8.13 {array command, get option} {
  320.     list [catch {array get a b c} msg] $msg
  321. } {1 {wrong # args: should be "array get arrayName ?pattern?"}}
  322. test set-old-8.14 {array command, get option} {
  323.     catch {unset a}
  324.     array get a
  325. } {}
  326. test set-old-8.15 {array command, get option} {
  327.     catch {unset a}
  328.     set a(22) 3
  329.     set {a(long name)} {}
  330.     array get a
  331. } {22 3 {long name} {}}
  332. test set-old-8.16 {array command, get option (unset variable)} {
  333.     catch {unset a}
  334.     set a(x) 3
  335.     trace var a(y) w ignore
  336.     array get a
  337. } {x 3}
  338. test set-old-8.17 {array command, get option, with pattern} {
  339.     catch {unset a}
  340.     set a(x1) 3
  341.     set a(x2) 4
  342.     set a(x3) 5
  343.     set a(b1) 24
  344.     set a(b2) 25
  345.     array get a x*
  346. } {x1 3 x2 4 x3 5}
  347. test set-old-8.18 {array command, names option} {
  348.     catch {unset a}
  349.     set a(22) 3
  350.     list [catch {array names a 4 5} msg] $msg
  351. } {1 {wrong # args: should be "array names arrayName ?pattern?"}}
  352. test set-old-8.19 {array command, names option} {
  353.     catch {unset a}
  354.     array names a
  355. } {}
  356. test set-old-8.20 {array command, names option} {
  357.     catch {unset a}
  358.     set a(22) 3; set a(Textual_name) 44; set "a(name with spaces)" xxx
  359.     list [catch {lsort [array names a]} msg] $msg
  360. } {0 {22 Textual_name {name with spaces}}}
  361. test set-old-8.21 {array command, names option} {
  362.     catch {unset a}
  363.     set a(22) 3; set a(33) 44;
  364.     trace var a(xxx) w ignore
  365.     list [catch {lsort [array names a]} msg] $msg
  366. } {0 {22 33}}
  367. test set-old-8.22 {array command, names option} {
  368.     catch {unset a}
  369.     set a(22) 3; set a(33) 44;
  370.     trace var a(xxx) w ignore
  371.     set a(xxx) value
  372.     list [catch {lsort [array names a]} msg] $msg
  373. } {0 {22 33 xxx}}
  374. test set-old-8.23 {array command, names option} {
  375.     catch {unset a}
  376.     set a(axy) 3
  377.     set a(bxy) 44
  378.     set a(no) yes
  379.     set a(xxx) value
  380.     list [lsort [array names a *xy]] [lsort [array names a]]
  381. } {{axy bxy} {axy bxy no xxx}}
  382. test set-old-8.24 {array command, nextelement option} {
  383.     list [catch {array nextelement a} msg] $msg
  384. } {1 {wrong # args: should be "array nextelement arrayName searchId"}}
  385. test set-old-8.25 {array command, nextelement option} {
  386.     catch {unset a}
  387.     list [catch {array nextelement a b} msg] $msg
  388. } {1 {"a" isn't an array}}
  389. test set-old-8.26 {array command, set option} {
  390.     list [catch {array set a} msg] $msg
  391. } {1 {wrong # args: should be "array set arrayName list"}}
  392. test set-old-8.27 {array command, set option} {
  393.     list [catch {array set a 1 2} msg] $msg
  394. } {1 {wrong # args: should be "array set arrayName list"}}
  395. test set-old-8.28 {array command, set option} {
  396.     list [catch {array set a "a \{ c"} msg] $msg
  397. } {1 {unmatched open brace in list}}
  398. test set-old-8.29 {array command, set option} {
  399.     catch {unset a}
  400.     set a 44
  401.     list [catch {array set a {a b c d}} msg] $msg
  402. } {1 {can't set "a(a)": variable isn't array}}
  403. test set-old-8.30 {array command, set option} {
  404.     catch {unset a}
  405.     set a(xx) yy
  406.     array set a {b c d e}
  407.     array get a
  408. } {d e xx yy b c}
  409. test set-old-8.31 {array command, size option} {
  410.     list [catch {array size a 4} msg] $msg
  411. } {1 {wrong # args: should be "array size arrayName"}}
  412. test set-old-8.32 {array command, size option} {
  413.     catch {unset a}
  414.     array size a
  415. } {0}
  416. test set-old-8.33 {array command, size option} {
  417.     catch {unset a}
  418.     set a(22) 3; set a(Textual_name) 44; set "a(name with spaces)" xxx
  419.     list [catch {array size a} msg] $msg
  420. } {0 3}
  421. test set-old-8.34 {array command, size option} {
  422.     catch {unset a}
  423.     set a(22) 3; set a(xx) 44; set a(y) xxx
  424.     unset a(22) a(y) a(xx)
  425.     list [catch {array size a} msg] $msg
  426. } {0 0}
  427. test set-old-8.35 {array command, size option} {
  428.     catch {unset a}
  429.     set a(22) 3;
  430.     trace var a(33) rwu ignore
  431.     list [catch {array size a} msg] $msg
  432. } {0 1}
  433. test set-old-8.36 {array command, startsearch option} {
  434.     list [catch {array startsearch a b} msg] $msg
  435. } {1 {wrong # args: should be "array startsearch arrayName"}}
  436. test set-old-8.37 {array command, startsearch option} {
  437.     catch {unset a}
  438.     list [catch {array startsearch a} msg] $msg
  439. } {1 {"a" isn't an array}}
  440.  
  441. test set-old-9.1 {ids for array enumeration} {
  442.     catch {unset a}
  443.     set a(a) 1
  444.     list [array st a] [array st a] [array done a s-1-a; array st a] \
  445.         [array done a s-2-a; array d a s-3-a; array start a]
  446. } {s-1-a s-2-a s-3-a s-1-a}
  447. test set-old-9.2 {array enumeration} {
  448.     catch {unset a}
  449.     set a(a) 1
  450.     set a(b) 1
  451.     set a(c) 1
  452.     set x [array startsearch a]
  453.     list [array nextelement a $x] [array ne a $x] [array next a $x] \
  454.         [array next a $x] [array next a $x]
  455. } {a b c {} {}}
  456. test set-old-9.3 {array enumeration} {
  457.     catch {unset a}
  458.     set a(a) 1
  459.     set a(b) 1
  460.     set a(c) 1
  461.     set x [array startsearch a]
  462.     set y [array startsearch a]
  463.     set z [array startsearch a]
  464.     list [array nextelement a $x] [array ne a $x] \
  465.         [array next a $y] [array next a $z] [array next a $y] \
  466.         [array next a $z] [array next a $y] [array next a $z] \
  467.         [array next a $y] [array next a $z] [array next a $x] \
  468.         [array next a $x]
  469. } {a b a a b b c c {} {} c {}}
  470. test set-old-9.4 {array enumeration: stopping searches} {
  471.     catch {unset a}
  472.     set a(a) 1
  473.     set a(b) 1
  474.     set a(c) 1
  475.     set x [array startsearch a]
  476.     set y [array startsearch a]
  477.     set z [array startsearch a]
  478.     list [array next a $x] [array next a $x] [array next a $y] \
  479.         [array done a $z; array next a $x] \
  480.         [array done a $x; array next a $y] [array next a $y]
  481. } {a b a c b c}
  482. test set-old-9.5 {array enumeration: stopping searches} {
  483.     catch {unset a}
  484.     set a(a) 1
  485.     set x [array startsearch a]
  486.     array done a $x
  487.     list [catch {array next a $x} msg] $msg
  488. } {1 {couldn't find search "s-1-a"}}
  489. test set-old-9.6 {array enumeration: searches automatically stopped} {
  490.     catch {unset a}
  491.     set a(a) 1
  492.     set x [array startsearch a]
  493.     set y [array startsearch a]
  494.     set a(b) 1
  495.     list [catch {array next a $x} msg] $msg \
  496.         [catch {array next a $y} msg2] $msg2
  497. } {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
  498. test set-old-9.7 {array enumeration: searches automatically stopped} {
  499.     catch {unset a}
  500.     set a(a) 1
  501.     set x [array startsearch a]
  502.     set y [array startsearch a]
  503.     set a(a) 2
  504.     list [catch {array next a $x} msg] $msg \
  505.         [catch {array next a $y} msg2] $msg2
  506. } {0 a 0 a}
  507. test set-old-9.8 {array enumeration: searches automatically stopped} {
  508.     catch {unset a}
  509.     set a(a) 1
  510.     set a(c) 2
  511.     set x [array startsearch a]
  512.     set y [array startsearch a]
  513.     catch {unset a(c)}
  514.     list [catch {array next a $x} msg] $msg \
  515.         [catch {array next a $y} msg2] $msg2
  516. } {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
  517. test set-old-9.9 {array enumeration: searches automatically stopped} {
  518.     catch {unset a}
  519.     set a(a) 1
  520.     set x [array startsearch a]
  521.     set y [array startsearch a]
  522.     catch {unset a(c)}
  523.     list [catch {array next a $x} msg] $msg \
  524.         [catch {array next a $y} msg2] $msg2
  525. } {0 a 0 a}
  526. test set-old-9.10 {array enumeration: searches automatically stopped} {
  527.     catch {unset a}
  528.     set a(a) 1
  529.     set x [array startsearch a]
  530.     set y [array startsearch a]
  531.     trace var a(b) r {}
  532.     list [catch {array next a $x} msg] $msg \
  533.         [catch {array next a $y} msg2] $msg2
  534. } {1 {couldn't find search "s-1-a"} 1 {couldn't find search "s-2-a"}}
  535. test set-old-9.11 {array enumeration: searches automatically stopped} {
  536.     catch {unset a}
  537.     set a(a) 1
  538.     set x [array startsearch a]
  539.     set y [array startsearch a]
  540.     trace var a(a) r {}
  541.     list [catch {array next a $x} msg] $msg \
  542.         [catch {array next a $y} msg2] $msg2
  543. } {0 a 0 a}
  544. test set-old-9.12 {array enumeration with traced undefined elements} {
  545.     catch {unset a}
  546.     set a(a) 1
  547.     trace var a(b) r {}
  548.     set x [array startsearch a]
  549.     list [array next a $x] [array next a $x]
  550. } {a {}}
  551.  
  552. test set-old-10.1 {array enumeration errors} {
  553.     list [catch {array start} msg] $msg
  554. } {1 {wrong # args: should be "array option arrayName ?arg ...?"}}
  555. test set-old-10.2 {array enumeration errors} {
  556.     list [catch {array start a b} msg] $msg
  557. } {1 {wrong # args: should be "array startsearch arrayName"}}
  558. test set-old-10.3 {array enumeration errors} {
  559.     catch {unset a}
  560.     list [catch {array start a} msg] $msg
  561. } {1 {"a" isn't an array}}
  562. test set-old-10.4 {array enumeration errors} {
  563.     catch {unset a}
  564.     set a(a) 1
  565.     set x [array startsearch a]
  566.     list [catch {array next a} msg] $msg
  567. } {1 {wrong # args: should be "array nextelement arrayName searchId"}}
  568. test set-old-10.5 {array enumeration errors} {
  569.     catch {unset a}
  570.     set a(a) 1
  571.     set x [array startsearch a]
  572.     list [catch {array next a b c} msg] $msg
  573. } {1 {wrong # args: should be "array nextelement arrayName searchId"}}
  574. test set-old-10.6 {array enumeration errors} {
  575.     catch {unset a}
  576.     set a(a) 1
  577.     set x [array startsearch a]
  578.     list [catch {array next a a-1-a} msg] $msg
  579. } {1 {illegal search identifier "a-1-a"}}
  580. test set-old-10.7 {array enumeration errors} {
  581.     catch {unset a}
  582.     set a(a) 1
  583.     set x [array startsearch a]
  584.     list [catch {array next a sx1-a} msg] $msg
  585. } {1 {illegal search identifier "sx1-a"}}
  586. test set-old-10.8 {array enumeration errors} {
  587.     catch {unset a}
  588.     set a(a) 1
  589.     set x [array startsearch a]
  590.     list [catch {array next a s--a} msg] $msg
  591. } {1 {illegal search identifier "s--a"}}
  592. test set-old-10.9 {array enumeration errors} {
  593.     catch {unset a}
  594.     set a(a) 1
  595.     set x [array startsearch a]
  596.     list [catch {array next a s-1-b} msg] $msg
  597. } {1 {search identifier "s-1-b" isn't for variable "a"}}
  598. test set-old-10.10 {array enumeration errors} {
  599.     catch {unset a}
  600.     set a(a) 1
  601.     set x [array startsearch a]
  602.     list [catch {array next a s-1ba} msg] $msg
  603. } {1 {illegal search identifier "s-1ba"}}
  604. test set-old-10.11 {array enumeration errors} {
  605.     catch {unset a}
  606.     set a(a) 1
  607.     set x [array startsearch a]
  608.     list [catch {array next a s-2-a} msg] $msg
  609. } {1 {couldn't find search "s-2-a"}}
  610. test set-old-10.12 {array enumeration errors} {
  611.     list [catch {array done a} msg] $msg
  612. } {1 {wrong # args: should be "array donesearch arrayName searchId"}}
  613. test set-old-10.13 {array enumeration errors} {
  614.     list [catch {array done a b c} msg] $msg
  615. } {1 {wrong # args: should be "array donesearch arrayName searchId"}}
  616. test set-old-10.14 {array enumeration errors} {
  617.     list [catch {array done a b} msg] $msg
  618. } {1 {illegal search identifier "b"}}
  619. test set-old-10.15 {array enumeration errors} {
  620.     list [catch {array anymore a} msg] $msg
  621. } {1 {wrong # args: should be "array anymore arrayName searchId"}}
  622. test set-old-10.16 {array enumeration errors} {
  623.     list [catch {array any a b c} msg] $msg
  624. } {1 {wrong # args: should be "array anymore arrayName searchId"}}
  625. test set-old-10.17 {array enumeration errors} {
  626.     catch {unset a}
  627.     set a(0) 44
  628.     list [catch {array any a bogus} msg] $msg
  629. } {1 {illegal search identifier "bogus"}}
  630.  
  631. # Array enumeration with "anymore" option
  632.  
  633. test set-old-11.1 {array anymore option} {
  634.     catch {unset a}
  635.     set a(a) 1
  636.     set a(b) 2
  637.     set a(c) 3
  638.     array startsearch a
  639.     list [array anymore a s-1-a] [array next a s-1-a] \
  640.         [array anymore a s-1-a] [array next a s-1-a] \
  641.         [array anymore a s-1-a] [array next a s-1-a] \
  642.         [array anymore a s-1-a] [array next a s-1-a] 
  643. } {1 a 1 b 1 c 0 {}}
  644. test set-old-11.2 {array anymore option} {
  645.     catch {unset a}
  646.     set a(a) 1
  647.     set a(b) 2
  648.     set a(c) 3
  649.     array startsearch a
  650.     list [array next a s-1-a] [array next a s-1-a] \
  651.         [array anymore a s-1-a] [array next a s-1-a] \
  652.         [array next a s-1-a] [array anymore a s-1-a] 
  653. } {a b 1 c {} 0}
  654.  
  655. # Special check to see that the value of a variable is handled correctly
  656. # if it is returned as the result of a procedure (must not free the variable
  657. # string while deleting the call frame).  Errors will only be detected if
  658. # a memory consistency checker such as Purify is being used.
  659.  
  660. test set-old-12.1 {cleanup on procedure return} {
  661.     proc foo {} {
  662.     set x 12345
  663.     }
  664.     foo
  665. } 12345
  666. test set-old-12.2 {cleanup on procedure return} {
  667.     proc foo {} {
  668.     set x(1) 23456
  669.     }
  670.     foo
  671. } 23456
  672.  
  673. # Must delete variables when done, since these arrays get used as
  674. # scalars by other tests.
  675.  
  676. catch {unset a}
  677. catch {unset b}
  678. catch {unset c}
  679. return ""
  680.