Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 71 lines (51 sloc) 1.574 kb
d13c85b7 » rocket
2009-06-13 Moved test to the corresponding spec folder and added smartlinks.
1 use v6;
2
3 use Test;
4
5 =begin pod
6
7 Test evaluation of multiple C<-e> switches.
8
9 Multiple C<-e> switches are supposed to work just
10 like C<join "\n"> concatenation .
11
12 =end pod
13
14 # L<S19/Reference/"Execute a single-line program.">
15
16 my @examples = (
17 '-e print -e qq.Hello -e Pugs.',
18 '-e print -we qq.Hello -e Pugs.',
19 '-e print -wle qq.Hello -e Pugs.',
20 '-e print -weqq.Hello -e Pugs.',
21 '-e print -e qq.Hel. -e ";print" -e qq.lo. -e ";print" -e "qq.\nPugs."',
22 '-e print -e qq.Hel. -w -e ";print" -e qq.lo. -w -e ";print" -e "qq.\nPugs."',
23 );
24
25 plan +@examples +1;
26 if $*OS eq "browser" {
27 skip_rest "Programs running in browsers don't have access to regular IO.";
28 exit;
29 }
30
31 diag "Running under $*OS";
32
33 my $redir = ">";
34
35 if $*OS eq any <MSWin32 mingw msys cygwin> {
36 $redir = '>';
37 };
38
39 sub nonce () { return (".{$*PID}." ~ (1..1000).pick) }
40 my $out_fn = "temp-ex-output" ~ nonce;
41
42 for @examples -> $ex {
43 my $command = "$*EXECUTABLE_NAME $ex $redir $out_fn";
44 diag $command;
45 run $command;
46
47 my $expected = "Hello\nPugs";
48 my $got = slurp $out_fn;
49
50 is $got, $expected, "Multiple -e switches work and append the script";
51 }
52
53 my $command = qq[$*EXECUTABLE_NAME -e @ARGS.perl.say -e "" Hello Pugs $redir $out_fn];
54 diag $command;
55 run $command;
56
57 my @expected = <Hello Pugs>;
58 my $got = slurp $out_fn;
59 $got .= chomp;
60 if (substr($got,0,1) ~~ "\\") {
61 $got = substr($got,1);
62 };
63
64 my @got = eval $got;
65 # fail "FIXME platform specific";
66 # ??? Worksforme on win32 (CORION)
67 is @got, @expected, "-e '' does not eat a following argument";
68
69 unlink $out_fn;
7f29bc53 » kyle
2009-08-08 [t/spec] Add vim: lines everywhere.
70
71 # vim: ft=perl6
Something went wrong with that request. Please try again.