Symbols.PL

filter: Statementstmt 100% 23 / 23 Branchbran 62.5% 5 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 90.6% 29 / 32 CC 1 SCAR 0.0
CC
1
Cov
90%
BEGIN
1.0
CRAP 1.0
« const-xs.inc ↑ Summary blib/lib/POSIX/2008/symbols.pl »
1 # This script is automatically executed after 2008.xs has been compiled. It
2 # takes all symbol names from constants.txt and functions.txt that we would
3 # like to provide, checks which of them we actually provide, and makes these
4 # available through @_constants and @_functions in symbols.pl which is loaded
5 # by 2008.pm via "require" to populate @EXPORT_OK. This is to make sure that
6 # "use POSIX::2008 'non_existent_name';" croaks at compile time.
7  
8 1 ▶use File::Spec;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 require XSLoader;
11 1 XSLoader::load('POSIX::2008', '0.29');
12  
13 1 my %names;
14  
15 1 foreach my $type (qw(constants functions)) {
16 2 $names{$type} = do {
17 2 local $/;
18 2 my $file = "${type}.txt";
19 2 ▶ open my $fh, '<', $file or die "Can't open $file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, "<", $file or die "Can't open ${file}: $!" 2 0 2
20 2 [sort split ' ', <$fh>];
21 };
22 }
23  
24 1 my $file = File::Spec->catfile(
25 File::Spec->curdir(), qw(blib lib POSIX 2008 symbols.pl)
26 );
27  
28 1 ▶open my $fh, '>', $file or die "Can't open $file: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $file or die "Can't open ${file}: $!" 1 0 1
29  
30 1 foreach my $type (sort keys %names) {
31 2 print $fh "our \@_${type} = qw(\n";
32 2 foreach my $name (@{$names{$type}}) {
33 1130 ▶ print $fh "$name\n" if defined &{"POSIX::2008::$name"};
Branch: 1 branch
BranchTrueFalseTotal
if defined &{"POSIX::2008::$name";} 994 136 1130
34 }
35 2 print $fh ");\n\n";
36 }
37  
38 1 print $fh "1;\n";
39 1 ▶close $fh or die "Can't write $file: $!";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Can't write ${file}: $!" 1 0 1
« const-xs.inc ↑ Summary blib/lib/POSIX/2008/symbols.pl »