tagged release 0.6.4
[parrot.git] / languages / tcl / t / cmd_lset.t
blobb1ae319c632a2dc30b90ec196da651f43a5581d0
1 #!perl
3 # Copyright (C) 2006-2007, The Perl Foundation.
4 # $Id$
6 # the following lines re-execute this as a tcl script
7 # the \ at the end of these lines makes them a comment in tcl \
8 use lib qw(languages/tcl/lib tcl/lib lib ../lib ../../lib); # \
9 use Tcl::Test; #\
10 __DATA__
12 source lib/test_more.tcl
13 plan 12
15 eval_is {
16   set a a
17   lset a b
18   set a
19 } b {two arg replace, check variable replacement}
21 eval_is {
22   set a a
23   lset a {} b
24 } b {three arg replace}
27 eval_is {
28   set a "a b c"
29   lset a 1 c
30 } {a c c} {one index}
32 eval_is {
33   set a "a {b c} d"
34   lset a 1 0 c
35 } {a {c c} d} {multiple indices}
37 eval_is {
38   set a "a b c d"
39   lset a end e
40 } {a b c e} {end}
42 eval_is {lset} \
43   {wrong # args: should be "lset listVar index ?index...? value"} \
44   {too few args}
46 eval_is {lset a} \
47   {wrong # args: should be "lset listVar index ?index...? value"} \
48   {too few args}
50 eval_is {lset frob b} \
51   {can't read "frob": no such variable} \
52   {bad variable}
54 eval_is {
55   set a b
56   lset a 3 b
57 } {list index out of range} \
58   {list index out of range}
60 eval_is {
61   set a "a b c d"
62   lset a end--1 e
63 } {list index out of range} \
64   {list index out of range}
66 eval_is {
67   set a "a b c d"
68   lset a -1 e
69 } {list index out of range} \
70   {list index out of range}
72 eval_is {
73   set a b
74   lset a 3.2 b
75 } {bad index "3.2": must be integer?[+-]integer? or end?[+-]integer?} \
76   {float index}