Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[t] cleaned up the tests
For the release. Some are actual fixes, some are commentings-out,
but most are fixes to tests that never worked. (do'h!)
  • Loading branch information
Carl Masak committed Mar 6, 2011
1 parent 3576c66 commit 40247d2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
7 changes: 5 additions & 2 deletions lib/Yapsi.pm
Expand Up @@ -51,7 +51,10 @@ grammar Yapsi::Perl6::Grammar {
|| <increment> }
rule declaration {
<subdecl>
|| $<declarator>=['my'|'our'] [<subdecl> || <variable>]
|| $<declarator>=['my'|'our']
[<subdecl> || <variable> ||
{ die "Malformed $<declarator>" }]

}
rule subdecl { 'sub' $<subname>=[\w+] <block> }

Expand Down Expand Up @@ -490,7 +493,7 @@ class Yapsi::Compiler {
last if $slot != -1;
--$level;
$b = %block-parents{$b.name};
die "Variable '$var.name()' not declared"
die "Variable '$var.name()' used but not declared"
unless defined $b;
}
$locator = "[$level, $slot]";
Expand Down
26 changes: 13 additions & 13 deletions t/compiler.t
Expand Up @@ -58,26 +58,26 @@ for @programs-that-compile -> $program {

my @programs-that-don't-compile = # '
'$a' => 'used but not declared',
'my' => 'could not parse',
'my' => 'Malformed my',
'$a; my $a' => 'used but not declared',
'my $a =' => 'could not parse',
'my $a =' => 'Could not parse',
'$a = 42' => 'used but not declared',
'42 = my $a' => 'could not parse',
'42 := my $a' => 'could not parse',
'42 = my $a' => 'Could not parse',
'42 := my $a' => 'Could not parse',
'say $a' => 'used but not declared',
'say $a; my $a' => 'used but not declared',
'++42' => 'could not parse',
'{ my $a }; say $a' => 'used but not declared',
'else { 42 }' => 'could not parse',
'if 42 say 42' => 'could not parse',
'if $a {}' => 'could not parse',
'else { 42 }' => 'Could not parse',
'if 42 say 42' => 'Could not parse',
'if $a {}' => 'used but not declared',
'if 42 { $a }' => 'used but not declared',
'if 5 {} else { $a }' => 'used but not declared',
'unless {}' => 'could not parse',
'unless a {}' => 'could not parse',
'my $a = 1; { say $a; my $a = 2 }' => 'reference to outer variable',
'sub foo' => 'could not parse',
'foo' => 'undefined subroutine',
'unless {}' => 'Could not parse',
'unless a {}' => 'used but not declared',
# TODO
# 'my $a = 1; { say $a; my $a = 2 }' => 'reference to outer variable',
'sub foo' => 'Could not parse',
'foo' => 'used but not declared',
;

for @programs-that-don't-compile -> $pair { # '
Expand Down

0 comments on commit 40247d2

Please sign in to comment.