Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add a few REPL tests.
  • Loading branch information
peschwa committed Apr 13, 2015
1 parent e28b43d commit 0b1e4f1
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions t/02-rakudo/repl.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 6;
plan 11;

# Sanity check that the repl is working at all.
my $cmd = $*DISTRO.is-win
Expand Down Expand Up @@ -34,17 +34,17 @@ sub feed_repl_with ( @lines ) {
return qqx[$repl-input | $*EXECUTABLE];
}

my @input-lines;
# RT #123187
{
my @input-lines;
@input-lines[0] = 'my int $t=4; $t.say;';
@input-lines[1] = '$t.say';
is feed_repl_with( @input-lines ).lines, (4, 4),
'can use native typed variable on subsequent lines (1)';
}

{
my @input-lines = q:to/END/.split("\n");
@input-lines = q:to/END/.split("\n");
if False {
say ":(";
}
Expand Down Expand Up @@ -72,6 +72,15 @@ sub feed_repl_with ( @lines ) {
is feed_repl_with( @input-lines ).lines, ":)",
"open brace on next line is parsed correctly";

@input-lines = q:to/END/.split("\n");
if False { say ":("; }
else { say ":)"; }
END

#?rakudo todo "indent styles don't parse right"
is feed_repl_with( @input-lines ).lines, ":)",
"cuddled else is parsed correctly";

@input-lines = q:to/END/.split("\n");
if False {
say ":(";
Expand All @@ -84,3 +93,25 @@ sub feed_repl_with ( @lines ) {
is feed_repl_with( @input-lines ).lines, ":)",
"cuddled else is parsed correctly";
}

{
@input-lines = 'say "works"', 'if True;';
#?rakudo todo "statement mod if on the next line"
is feed_repl_with( @input-lines ).lines, "works",
"statement mod if on the next line works";

@input-lines = 'say "works"', 'for 1;';
#?rakudo todo "statement mod for on the next line"
is feed_repl_with( @input-lines ).lines, "works",
"statement mod for on the next line works";

@input-lines = 'sub f { 42 }', 'f()';
#?rakudo todo "block parsing broken"
is feed_repl_with( @input-lines ).lines, "42",
"single-line sub declaration works";

@input-lines = 'sub f {', '42', '}';
#?rakudo todo "block parsing broken"
is feed_repl_with( @input-lines ).lines, "42",
"single-line sub declaration works";
}

0 comments on commit 0b1e4f1

Please sign in to comment.