Skip to content

Commit

Permalink
Test octal warnings in REPL
Browse files Browse the repository at this point in the history
RT#119339

- 0-prefixed number must warn about usin 0o prefix
- This warning must not suggest the user uses invalid octal, e.g. 0o9
- 0o prefix on valid octal must work in REPL
  • Loading branch information
zoffixznet committed Jul 7, 2016
1 parent e669003 commit 7dce301
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion S19-command-line/repl.t
@@ -1,9 +1,39 @@
use v6;
use Test;
plan 1;
plan 4;

# Sanity check that the repl is working at all.
my $cmd = $*DISTRO.is-win
?? "echo exit(42) | $*EXECUTABLE 1>&2"
!! "echo 'exit(42)' | $*EXECUTABLE >/dev/null 2>&1";
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:'
.* "Leading 0 is not allowed. For octals, use '0o' prefix,"
.* 'but note that 69 is not a valid octal number'
/, 'stderr contains correct warning';
}, 'prefix 0 on invalid octal warns in REPL';

subtest { plan 2;
my $proc = run $*EXECUTABLE, :in, :out, :err;
$proc.in.print: "say 067\nexit\n";
like $proc.out.slurp-rest, /'67'/, 'stdout contains the number';
like $proc.err.slurp-rest, /'Potential difficulties:'
.* 'Leading 0 does not indicate octal in Perl 6.'
.* 'Please use 0o67 if you mean that.'
/, 'stderr contains correct warning';
}, 'prefix 0 on valid octal warns in REPL';

subtest { plan 2;
my $proc = run $*EXECUTABLE, :in, :out, :err;
$proc.in.print: "say 0o67\nexit\n";
like $proc.out.slurp-rest, /'55'/, 'stdout contains the number';
is $proc.err.slurp-rest, '', 'stderr is empty';
}, 'prefix 0o on valid octal works fine in REPL';
}

0 comments on commit 7dce301

Please sign in to comment.