tagged release 0.7.1
[parrot.git] / languages / tcl / t / cmd_lassign.t
blob9c713fe134f804b74e9efdeeee6435d2902aad57
1 #!perl
3 # Copyright (C) 2005-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 7
15 # https://sourceforge.net/tracker/index.php?func=detail&aid=1534628&group_id=10894&atid=110894 {RESOLVED}
16 eval_is {lassign} \
17   {wrong # args: should be "lassign list varName ?varName ...?"} \
18   {no args}
20 eval_is {lassign {a b}} \
21   {wrong # args: should be "lassign list varName ?varName ...?"} \
22   {one args}
24 eval_is {
25   set b [lassign {x y} a]
26   list $a $b
27 } {x y} {singleton with one leftover}
29 eval_is {
30   set b [lassign {x y z} a]
31   list $a $b
32 } {x {y z}} {singleton with two leftovers}
34 eval_is {
35   set c [lassign {x y z} a b]
36   list $a $b $c
37 } {x y z} {double with a leftover}
39 eval_is {
40   set d [lassign {x y z} a b c]
41   list $a $b $c $d
42 } {x y z {}} {triple, no leftovers}
44 eval_is {
45   set e [lassign {x y z} a b c d]
46   list $a $b $c $d $e
47 } {x y z {} {}} {4 variables, not enough values}