This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test preamble: unify chdir 't' if -d 't';
[perl5.git] / t / lib / proxy_constant_subs.t
CommitLineData
1ccdb730
NC
1my @symbols;
2BEGIN {
fa71130c 3 require './test.pl';
273be65c 4 skip_all_without_dynamic_extension($_) foreach qw(B Fcntl);
a5d75221 5 # S_IFMT is a real subroutine, and acts as control
1ccdb730 6 # SEEK_SET is a proxy constant subroutine.
a5d75221 7 @symbols = qw(S_IFMT SEEK_SET);
1ccdb730
NC
8}
9
10use strict;
11use warnings;
eaa79d3d 12plan(4 * @symbols);
1ccdb730 13use B qw(svref_2object GVf_IMPORTED_CV);
a5d75221 14use Fcntl @symbols;
1ccdb730
NC
15
16# GVf_IMPORTED_CV should not be set on the original, but should be set on the
17# imported GV.
18
19foreach my $symbol (@symbols) {
20 my ($ps, $ms);
21 {
22 no strict 'refs';
a5d75221 23 $ps = svref_2object(\*{"Fcntl::$symbol"});
1ccdb730
NC
24 $ms = svref_2object(\*{"::$symbol"});
25 }
bbce3ca6 26 object_ok($ps, 'B::GV');
1ccdb730
NC
27 is($ps->GvFLAGS() & GVf_IMPORTED_CV, 0,
28 "GVf_IMPORTED_CV not set on original");
bbce3ca6 29 object_ok($ms, 'B::GV');
1ccdb730
NC
30 is($ms->GvFLAGS() & GVf_IMPORTED_CV, GVf_IMPORTED_CV,
31 "GVf_IMPORTED_CV set on imported GV");
32}