Commit | Line | Data |
d5ac8da0 |
1 | use warnings; |
2 | use strict; |
3 | |
5efe0e0e |
4 | use Test::More tests => 11; |
d5ac8da0 |
5 | |
6 | use Function::Parameters; |
7 | |
8 | fun 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 | |
19 | fun 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 | |
26 | fun () { |
27 | test_loc 'LX simple'; |
28 | }->(); |
29 | |
30 | test_loc 'LX -- 1'; |
31 | |
32 | fun |
33 | ( |
34 | ) |
35 | { |
36 | test_loc 'LX creative formatting'; } |
37 | -> |
38 | ( |
39 | ); |
40 | |
41 | test_loc 'LX -- 2'; |
42 | |
43 | fun () { |
44 | fun () { |
45 | test_loc 'LX nested'; |
46 | }->() |
47 | }->(); |
48 | |
49 | test_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__ |