Make the tests pass with warnings enabled.
[p5sagit/Devel-BeginLift.git] / t / constcalc.t
CommitLineData
00aef8ff 1BEGIN { our @warnings; $SIG{__WARN__} = sub { push(@warnings, $_[0]); } }
2
3use Devel::BeginLift 'foo';
4
5use vars qw($int);
6
7BEGIN { $int = 1 }
8
9sub foo { warn "foo: $_[0]\n"; $int++; 4; }
10
11sub bar { warn "bar: $_[0]\n"; $int; }
12
13warn "yep\n";
14
15warn foo("foo")."\n";
16
17warn bar("bar")."\n";
18
19no Devel::BeginLift;
20
9fb21988 21foo('');
00aef8ff 22
23END {
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}