This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test XS registration of state subs
[perl5.git] / ext / XS-APItest / t / lexsub.t
CommitLineData
0be5d18d
FC
1use Test::More tests => 4;
2use XS::APItest;
3
4
5sub fribbler { 2*shift }
6{
7 BEGIN { lexical_import fribbler => sub { 3*shift } }
8 is fribbler(15), 45, 'lexical subs via pad_add_name';
9}
10is fribbler(15), 30, 'XS-allocated lexical subs falling out of scope';
11
12{
13 BEGIN { lexical_import fribbler => sub { 3*shift } }
14 is fribbler(15), 45, 'lexical subs via pad_add_name';
15 no warnings;
16 use feature 'lexical_subs';
17 our sub fribbler;
18 is fribbler(15), 30, 'our sub overrides XS-registered lexical sub';
19}