Created
July 7, 2016 19:32
-
-
Save zoffixznet/672e8bb4de280e012765a3875786ca02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/S19-command-line/repl.t b/S19-command-line/repl.t | |
index 14a2507..5a95236 100644 | |
--- a/S19-command-line/repl.t | |
+++ b/S19-command-line/repl.t | |
@@ -1,5 +1,9 @@ | |
use v6; | |
+use lib <t/spec/packages>; | |
+ | |
use Test; | |
+use Test::Util; | |
+ | |
plan 4; | |
# Sanity check that the repl is working at all. | |
@@ -10,14 +14,11 @@ is shell($cmd).exitcode, 42, 'exit(42) in executed REPL got run'; | |
{ | |
# RT #119339 | |
- subtest { plan 2; | |
- my $proc = run $*EXECUTABLE, :in, :out, :err; | |
- $proc.in.print: "say 069\nexit\n"; | |
- like $proc.out.slurp-rest, /'69'/, 'stdout contains the number'; | |
- like $proc.err.slurp-rest, /'Potential difficulties:' | |
+ is_run_repl "say 069\nexit\n", { | |
+ out => /'69'/, | |
+ err => /'Potential difficulties:' | |
.* "Leading 0 is not allowed. For octals, use '0o' prefix," | |
- .* 'but note that 69 is not a valid octal number' | |
- /, 'stderr contains correct warning'; | |
+ .* 'but note that 69 is not a valid octal number'/ | |
}, 'prefix 0 on invalid octal warns in REPL'; | |
subtest { plan 2; | |
diff --git a/packages/Test/Util.pm b/packages/Test/Util.pm | |
index 493161c..432aa2a 100644 | |
--- a/packages/Test/Util.pm | |
+++ b/packages/Test/Util.pm | |
@@ -127,6 +127,16 @@ sub get_out( Str $code, Str $input?, :@args, :@compiler-args) is export { | |
return %out; | |
} | |
+sub is_run_repl ($code, %wanted, $desc) is export { | |
+ my $proc = run $*EXECUTABLE, :in, :out, :err; | |
+ $proc.in.print: $code; | |
+ subtest { | |
+ plan +(%wanted<out err>:v); | |
+ like $proc.out.slurp-rest, $_, 'stdout is correct' with %wanted<out>; | |
+ like $proc.err.slurp-rest, $_, 'stderr is correct' with %wanted<err>; | |
+ }, $desc; | |
+} | |
+ | |
=begin pod | |
=head1 NAME |
Author
zoffixznet
commented
Jul 7, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment