From: Ash Berlin Date: Sat, 23 May 2009 18:55:43 +0000 (+0100) Subject: Failing tests for line number issues X-Git-Tag: 0.005003~6^2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9bd5658a784ec13e0f0378450a7982135267ab0c;p=p5sagit%2FDevel-Declare.git Failing tests for line number issues --- diff --git a/t/lines.t b/t/lines.t new file mode 100644 index 0000000..b7c86ac --- /dev/null +++ b/t/lines.t @@ -0,0 +1,52 @@ +use strict; +use warnings; +use Test::More; + +BEGIN { + eval 'use B::Compiling'; + + $@ and plan 'skip_all' => $@ + or plan tests => 5; +} + +my @lines; + + +sub handle_fun { + my $pack = shift; + + push @lines, PL_compiling->line; + + my $offset = Devel::Declare::get_linestr_offset(); + $offset += Devel::Declare::toke_move_past_token($offset); + my $stripped = Devel::Declare::toke_skipspace($offset); + my $linestr = Devel::Declare::get_linestr(); + + push @lines, PL_compiling->line; +} + + +use Devel::Declare; +BEGIN { +sub fun(&) {} + +Devel::Declare->setup_for( + __PACKAGE__, + { fun => { const => \&handle_fun } } +); +} + + +#line 100 +fun +{ }; +my $line = __LINE__; +my $line2 = __LINE__; + +# Reset the line number back to what it actually is +#line 48 +is(@lines, 2, "2 line numbers recorded"); +is $lines[0], 100, "fun starts on line 100"; +is $lines[1], 101, "fun stops on line 101"; +is $line, 102, "next statement on line 102"; +is $line2, 103, "next statement on line 103";