tagged release 0.6.4
[parrot.git] / languages / tcl / t / cmd_subst.t
blob8065f71ff4d147892751cce644b8e1a3f91c928f
1 #!perl
3 # Copyright (C) 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 14
15 eval_is {subst} \
16   {wrong # args: should be "subst ?-nobackslashes? ?-nocommands? ?-novariables? string"} \
17   {too few args}
19 eval_is {subst foo bar} \
20   {bad switch "foo": must be -nobackslashes, -nocommands, or -novariables} \
21   {too many args}
23 set foo ba
24 is [subst                {{$foo}}]   {{ba}} {subst: variable}
25 is [subst -nobackslashes {{$foo}}]   {{ba}} {subst -nobackslashes: variable}
26 is [subst -nocommands    {{$foo}}]   {{ba}} {subst -nocommands: variable}
27 is [subst -novariables   {{$foo}}] {{$foo}} {subst -novariables: variable}
29 is [subst                {{[set foo]}}] {{ba}} {subst: command}
30 is [subst -nobackslashes {{[set foo]}}] {{ba}} {subst -nobackslashes: command}
31 is [subst -nocommands    {{[set foo]}}] {{[set foo]}} {subst -nocommands: command}
32 is [subst -novariables   {{[set foo]}}] {{ba}} {subst -novariables: command}
34 is [subst {{\$foo \[set foo]}}]          {{$foo [set foo]}} {subst: backslash}
35 is [subst -nobackslashes {{\$foo \[set foo]}}]  {{\ba \ba}} {subst -nobackslashes: backslash}
36 is [subst -nocommands    {{\$foo}}]                {{$foo}} {subst -nobackslashes: backslash}
37 is [subst -novariables   {{\[set foo]}}]      {{[set foo]}} {subst -nobackslashes: backslash}