File: lines.t

package info (click to toggle)
libdevel-declare-perl 0.006000-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 296 kB
  • ctags: 238
  • sloc: perl: 1,605; ansic: 756; makefile: 25
file content (52 lines) | stat: -rw-r--r-- 962 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
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";