xref: /openbsd-src/gnu/usr.bin/perl/t/lib/proxy_constant_subs.t (revision b8851fcc53cbe24fd20b090f26dd149e353f6174)
1850e2753Smillertmy @symbols;
2850e2753SmillertBEGIN {
3*b8851fccSafresh1    chdir 't' if -d 't';
4898184e3Ssthen    require './test.pl';
5898184e3Ssthen    skip_all_without_dynamic_extension($_) foreach qw(B Fcntl);
643003dfeSmillert    # S_IFMT is a real subroutine, and acts as control
7850e2753Smillert    # SEEK_SET is a proxy constant subroutine.
843003dfeSmillert    @symbols = qw(S_IFMT SEEK_SET);
9850e2753Smillert}
10850e2753Smillert
11850e2753Smillertuse strict;
12850e2753Smillertuse warnings;
13b39c5158Smillertplan(4 * @symbols);
14850e2753Smillertuse B qw(svref_2object GVf_IMPORTED_CV);
1543003dfeSmillertuse Fcntl @symbols;
16850e2753Smillert
17850e2753Smillert# GVf_IMPORTED_CV should not be set on the original, but should be set on the
18850e2753Smillert# imported GV.
19850e2753Smillert
20850e2753Smillertforeach my $symbol (@symbols) {
21850e2753Smillert    my ($ps, $ms);
22850e2753Smillert    {
23850e2753Smillert	no strict 'refs';
2443003dfeSmillert	$ps = svref_2object(\*{"Fcntl::$symbol"});
25850e2753Smillert	$ms = svref_2object(\*{"::$symbol"});
26850e2753Smillert    }
27898184e3Ssthen    object_ok($ps, 'B::GV');
28850e2753Smillert    is($ps->GvFLAGS() & GVf_IMPORTED_CV, 0,
29850e2753Smillert       "GVf_IMPORTED_CV not set on original");
30898184e3Ssthen    object_ok($ms, 'B::GV');
31850e2753Smillert    is($ms->GvFLAGS() & GVf_IMPORTED_CV, GVf_IMPORTED_CV,
32850e2753Smillert       "GVf_IMPORTED_CV set on imported GV");
33850e2753Smillert}
34