tagged release 0.6.4
[parrot.git] / languages / tcl / t / cmd_linsert.t
blobce85dbd7bdd06fdbb3b77bf8418930f5fabd69e2
1 #!perl
3 # Copyright (C) 2004-2006, 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 10
15 is [linsert [list] 0 a]  a {insert beginning empty list}
16 is [linsert [list] 20 a] a {insert beyond end of empty list}
17 is [linsert [list a] end b] {a b} {insert beyond end of single list}
18 is [linsert [list a c] end-1 b] {a b c} {insert middle double list}
20 is [linsert list 0 new] {new list} {insert at beginning of list}
22 is [linsert [list a b] end [list c d]] {a b {c d}} {insert, sub list}
23 is [linsert [list a b] end c d] {a b c d} {insert, multiple elements}
25 eval_is {linsert} \
26   {wrong # args: should be "linsert list index element ?element ...?"} \
27   {too few args}
29 eval_is {linsert a} \
30   {wrong # args: should be "linsert list index element ?element ...?"} \
31   {too few args}
33 eval_is {
34   linsert [list a c] q b]
35 } {bad index "q": must be integer?[+-]integer? or end?[+-]integer?} \
36   {insert bad index}