|
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 | |
|---|
| 1 | use v6; |
|---|
| 2 | |
|---|
| 3 | use Test; |
|---|
| 4 | |
|---|
| 5 | =begin pod |
|---|
| 6 | |
|---|
| 7 | Test evaluation a script read from STDIN, as |
|---|
| 8 | indicated by the C<-> switch. |
|---|
| 9 | |
|---|
| 10 | =end pod |
|---|
| 11 | |
|---|
| 12 | my @examples = map -> Junction $_ { $_.values }, ( |
|---|
| 13 | any('say qq.Hello Pugs.', |
|---|
| 14 | 'say @*ARGS', |
|---|
| 15 | ) |
|---|
| 16 | ); |
|---|
| 17 | |
|---|
| 18 | plan +@examples; |
|---|
| 19 | if $*OS eq "browser" { |
|---|
| 20 | skip_rest "Programs running in browsers don't have access to regular IO."; |
|---|
| 21 | exit; |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | diag "Running under $*OS"; |
|---|
| 25 | |
|---|
| 26 | my ($redir,$echo) = (">", "echo"); |
|---|
| 27 | |
|---|
| 28 | sub nonce () { return (".{$*PID}." ~ ((1..1000).pick) ~ ".tmp") } |
|---|
| 29 | my $tempfile = "temp-ex-output" ~ nonce; |
|---|
| 30 | for @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 | } |
|---|