Ready for 0.01
[p5sagit/B-Hooks-EndOfScope-WithFallback.git] / t / 00-basic.t
CommitLineData
58b07c77 1use strict;
2use warnings;
4befcbc3 3use Test::More;
58b07c77 4
4befcbc3 5BEGIN { use_ok('B::Hooks::EndOfScope::WithFallback') }
58b07c77 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();
4befcbc3 31
32done_testing;