root/t/run/01-multiple-e.t

Revision 22093, 1.5 kB (checked in by lwall, 4 months ago)

[t] more system, require, does, defer, label cleanup

  • Property svn:mime-type set to text/plain; charset=UTF-8
  • Property svn:eol-style set to native
Line 
1use v6;
2
3use Test;
4
5=begin pod
6
7Test evaluation of multiple C<-e> switches.
8
9Multiple C<-e> switches are supposed to work just
10like C<join "\n"> concatenation .
11
12=end pod
13
14my @examples = (
15 '-e print -e qq.Hello -e Pugs.',
16 '-e print -we qq.Hello -e Pugs.',
17 '-e print -wle qq.Hello -e Pugs.',
18 '-e print -weqq.Hello -e Pugs.',
19 '-e print -e qq.Hel. -e ";print" -e qq.lo. -e ";print" -e "qq.\nPugs."',
20 '-e print -e qq.Hel. -w -e ";print" -e qq.lo. -w -e ";print" -e "qq.\nPugs."',
21);
22
23plan +@examples +1;
24if $*OS eq "browser" {
25  skip_rest "Programs running in browsers don't have access to regular IO.";
26  exit;
27}
28
29diag "Running under $*OS";
30
31my $redir = ">";
32
33if $*OS eq any <MSWin32 mingw msys cygwin> {
34  $redir = '>';
35};
36
37sub nonce () { return (".{$*PID}." ~ (1..1000).pick) }
38my $out_fn = "temp-ex-output" ~ nonce;
39
40for @examples -> $ex {
41  my $command = "$*EXECUTABLE_NAME $ex $redir $out_fn";
42  diag $command;
43  run $command;
44
45  my $expected = "Hello\nPugs";
46  my $got      = slurp $out_fn;
47
48  is $got, $expected, "Multiple -e switches work and append the script";
49}
50
51my $command = qq[$*EXECUTABLE_NAME -e @ARGS.perl.say -e "" Hello Pugs $redir $out_fn];
52diag $command;
53run $command;
54
55my @expected = <Hello Pugs>;
56my $got      = slurp $out_fn;
57$got .= chomp;
58if (substr($got,0,1) ~~ "\\") {
59  $got = substr($got,1);
60};
61
62my @got      = eval $got;
63# fail "FIXME platform specific";
64# ??? Worksforme on win32 (CORION)
65is @got, @expected, "-e '' does not eat a following argument";
66
67unlink $out_fn;
Note: See TracBrowser for help on using the browser.