fix wrong line number for statement immediately following a function
[p5sagit/Function-Parameters.git] / t / lineno.t
CommitLineData
d5ac8da0 1use warnings;
2use strict;
3
5efe0e0e 4use Test::More tests => 11;
d5ac8da0 5
6use Function::Parameters;
7
8fun actual_location_of_line_with($marker) {
9 seek DATA, 0, 0 or die "seek DATA: $!";
10 my $loc = 0;
11 while (my $line = readline DATA) {
12 $loc++;
13 index($line, $marker) >= 0
14 and return $loc;
15 }
16 undef
17}
18
19fun test_loc($marker) {
20 my $expected = actual_location_of_line_with $marker;
21 defined $expected or die "$marker: something done fucked up";
22 my $got = (caller)[2];
23 is $got, $expected, "location of '$marker'";
24}
25
26fun () {
27 test_loc 'LX simple';
28}->();
29
30test_loc 'LX -- 1';
31
32fun
33 (
34 )
35 {
36 test_loc 'LX creative formatting'; }
37->
38(
39 );
40
41test_loc 'LX -- 2';
42
43fun () {
44 fun () {
45 test_loc 'LX nested';
46 }->()
47}->();
48
49test_loc 'LX -- 3';
50
f15a0819 51{
52 #local $TODO = 'expressions break line numbers???';
d5ac8da0 53
54 0
55 , fun {
56 test_loc 'LX assign';
57 }->()
58 ;
59
60 test_loc 'LX -- 4';
61}
62
f15a0819 63{
64 #local $TODO = 'newlines in prototype/attributes';
db81d362 65
66 fun wtf :(
67
68 )
69 :
70 { test_loc 'LX -- 5 (inner)' }
71
5efe0e0e 72 test_loc 'LX -- 5 (bonus)';
db81d362 73 wtf;
74 test_loc 'LX -- 5 (outer)';
75}
76
d5ac8da0 77__DATA__