root/t/run/08-script-from-stdin.t

Revision 22093, 0.8 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 a script read from STDIN, as
8indicated by the C<-> switch.
9
10=end pod
11
12my @examples = map -> Junction $_ { $_.values }, (
13   any('say qq.Hello Pugs.',
14       'say @*ARGS',
15   )
16);
17
18plan +@examples;
19if $*OS eq "browser" {
20  skip_rest "Programs running in browsers don't have access to regular IO.";
21  exit;
22}
23
24diag "Running under $*OS";
25
26my ($redir,$echo) = (">", "echo");
27
28sub nonce () { return (".{$*PID}." ~ ((1..1000).pick) ~ ".tmp") }
29my $tempfile = "temp-ex-output" ~ nonce;
30for @examples -> $ex {
31  my $command = qq[$echo $ex | $*EXECUTABLE_NAME - "Hello Pugs" $redir $tempfile];
32  diag $command;
33  run $command;
34
35  my $expected = "Hello Pugs\n";
36  my $got      = slurp $tempfile;
37
38  is $got, $expected, "Running a script from stdin works";
39  unlink $tempfile;
40}
Note: See TracBrowser for help on using the browser.