File: 11-direct_xs.t

package info (click to toggle)
libb-hooks-endofscope-perl 0.13-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 268 kB
  • ctags: 16
  • sloc: perl: 320; makefile: 7
file content (33 lines) | stat: -rw-r--r-- 533 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use strict;
use warnings;
use Test::More;

BEGIN {
  eval { require B::Hooks::EndOfScope::XS }
    or plan skip_all => "XS functionality not available";

  B::Hooks::EndOfScope::XS->import();
}

BEGIN {
    ok(exists &on_scope_end, 'on_scope_end imported');
    is(prototype('on_scope_end'), '&', '.. and has the right prototype');
}

our $i;

sub foo {
    BEGIN {
        on_scope_end { $i = 42 };
    };

    is($i, 42, 'value still set at runtime');
}

BEGIN {
    is($i, 42, 'value set at compiletime')
}

foo();

done_testing;