Start with a copy of B::H::EOS 0.09
[p5sagit/B-Hooks-EndOfScope-WithFallback.git] / t / basic.t
CommitLineData
58b07c77 1use strict;
2use warnings;
3use Test::More tests => 6;
4
5BEGIN { use_ok('B::Hooks::EndOfScope') }
6
7BEGIN {
8 ok(exists &on_scope_end, 'on_scope_end imported');
9 is(prototype('on_scope_end'), '&', '.. and has the right prototype');
10}
11
12our ($i, $called);
13
14BEGIN { $i = 0 }
15
16sub foo {
17 BEGIN {
18 on_scope_end { $called = 1; $i = 42 };
19 on_scope_end { $i = 1 };
20 };
21
22 is($i, 1, 'value still set at runtime');
23}
24
25BEGIN {
26 ok($called, 'first callback invoked');
27 is($i, 1, '.. but the second is invoked later')
28}
29
30foo();