Commit | Line | Data |
00aef8ff |
1 | BEGIN { our @warnings; $SIG{__WARN__} = sub { push(@warnings, $_[0]); } } |
2 | |
3 | use Devel::BeginLift 'foo'; |
4 | |
5 | use vars qw($int); |
6 | |
7 | BEGIN { $int = 1 } |
8 | |
9 | sub foo { warn "foo: $_[0]\n"; $int++; 4; } |
10 | |
11 | sub bar { warn "bar: $_[0]\n"; $int; } |
12 | |
13 | warn "yep\n"; |
14 | |
15 | warn foo("foo")."\n"; |
16 | |
17 | warn bar("bar")."\n"; |
18 | |
19 | no Devel::BeginLift; |
20 | |
9fb21988 |
21 | foo(''); |
00aef8ff |
22 | |
23 | END { |
24 | use Test::More 'no_plan'; |
25 | our @warnings; |
26 | is(shift(@warnings), "foo: foo\n", "compile-time foo call first"); |
27 | is(shift(@warnings), "yep\n", "manual warning"); |
28 | is(shift(@warnings), "4\n", "const return from compile-time foo"); |
29 | is(shift(@warnings), "bar: bar\n", "bar called at run-time"); |
30 | is(shift(@warnings), "2\n", "\$int was incremented"); |
31 | is(shift(@warnings), "foo: \n", "run-time foo after BeginLift disabled"); |
32 | ok(!@warnings, "no more warnings"); |
33 | } |