Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
rewrite dash-p.t to use Test::Util
hangs on MoarVM due to RT #121720
  • Loading branch information
moritz committed Apr 23, 2014
1 parent 3a83c5f commit 3c5b51b
Showing 1 changed file with 22 additions and 39 deletions.
61 changes: 22 additions & 39 deletions S19-command-line-options/03-dash-p.t
Expand Up @@ -2,6 +2,11 @@ use v6;

use Test;

use lib 't/spec/packages';
use Test::Util;

plan 2;

=begin pod
Test C<-p> implementation
Expand All @@ -18,44 +23,22 @@ switch, and wraps the whole script in

# L<S19/Reference/"Act like sed.">

my @examples = (
'-p',
'-p "-e1;"',
'-pe ";"',
'-pe ""',
'-p "-e1;" "-e1;"',
'"-e1;" -p "-e1;"',
is_run(
'1', # program
"foo\n", # input
{
out => "foo\n", # expected
},
'-p -e 1 works like cat',
:compiler-args['-p'],
);

plan +@examples;

diag "Running under $*OS";

my ($redir_in,$redir_out) = ("<", ">");

my $str = "
foo
bar
";

sub nonce () { return (".{$*PID}." ~ (1..1000).pick) }
my ($in_fn, $out_fn) = <temp-ex-input temp-ext-output> >>~>> nonce;
my $h = open("$in_fn", :w);
$h.print($str);
$h.close();

for @examples -> $ex {
my $command = "$*EXECUTABLE_NAME $ex $redir_in $in_fn $redir_out $out_fn";
diag $command;
run $command;

my $expected = $str;
my $got = slurp $out_fn;
unlink $out_fn;

is $got, $expected, "$ex works like cat";
}

unlink $in_fn;

# vim: ft=perl6
is_run(
's:g/o/a/', # program
"foo\nbar\n", # input
{
out => "faa\nbar\n",
},
'-p works in combination with s:g///',
:compiler-args['-p'],
);

0 comments on commit 3c5b51b

Please sign in to comment.