Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test that BEGIN happens indeed at parse time
  • Loading branch information
moritz committed Oct 20, 2011
1 parent b6a2dde commit cc1b81e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion S04-phasers/begin.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 8;
plan 9;

# the boundary between run time and compile time is hard to implement right.
# Some of those tests might look trivial, but nearly all of them are based
Expand Down Expand Up @@ -49,3 +49,18 @@ plan 8;
BEGIN { $code = sub { 'returnvalue' } }
is $code(), 'returnvalue', 'Can execute an anonymous sub return from BEGIN';
}

{
my $tracker = '';
try {
eval q[
BEGIN { $tracker = "begin" }
$tracker = "run";
# syntax error (two terms in a row):
1 1
];
}
is $tracker, 'begin',
'BEGIN block was executed before a parse error happened later in the file';

}

0 comments on commit cc1b81e

Please sign in to comment.