symbols.PL

filter: Statementstmt 100% 39 / 39 Branchbran 60.0% 6 / 10 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 85.9% 49 / 57 CC 1 SCAR 0.0
CC
1
Cov
88%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« 1003.xs ↑ Summary blib/lib/POSIX/1003/Symbols.pm »
1 #!/usr/bin/env perl
2 #
3 # produce the table which knows which constant/function is provided
4 # by which module. This produces a new POSIX/1003/Symbols.pm
5  
6 2 ▶use blib;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use POSIX::1003 qw(posix_1003_modules posix_1003_names);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use POSIX::1003::Symbols;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶my $symbols = $INC{'POSIX/1003/Symbols.pm'}
Branch: 1 branch
BranchTrueFalseTotal
my $symbols = $INC{"POSIX/1003/Symbols.pm"} or die "cannot find filename for POSIX::1003::Symbols" 2 0 2
12 or die "cannot find filename for POSIX::1003::Symbols";
13 #warn "writing $symbols";
14  
15 2 ▶-w $symbols || chmod 0644, $symbols
Branch: 1 branch
BranchTrueFalseTotal
-w $symbols or chmod 0644, $symbols or die "cannot make $symbols writable: $!" 2 0 2
Condition33%1/3
-w $symbols or chmod 0644, $symbols
l!l&&r!l&&!r
200
MC/DC0%0/2
-w $symbols or chmod 0644, $symbols
-w $symbols chmod 0644, $symbols
Truth table33%1/3
A or B
A= -w $symbolsB= chmod 0644, $symbols
ABresult
1X1
011
000
16 or die "cannot make $symbols writable: $!";
17  
18 2 ▶open SYMBOLS, '>', $symbols
Branch: 1 branch
BranchTrueFalseTotal
open SYMBOLS, ">", $symbols or die "cannot write to ${symbols}: $!" 2 0 2
19 or die "cannot write to $symbols: $!";
20  
21 2 my $now = localtime;
22  
23 2 print SYMBOLS <<_HEAD;
24 # Warning: generated during module installation
25 # by $0
26 # at $now
27 # do not edit this file by hand!
28  
29 package POSIX::1003;
30  
31 our %EXPORT_TAGS = (
32 _HEAD
33  
34 2 my %subsets;
35 2 foreach my $mod (posix_1003_modules)
36 42 { my $tag = POSIX::1003::_mod2tag($mod);
37 42 my $names = posix_1003_names ":$tag";
38  
39 42 my $et = \%{$mod.'::EXPORT_TAGS'};
40 42 push @{$subsets{$tag}}, keys %$et;
41  
42 42 my @names = sort {lc $a cmp lc $b} keys %$names;
43 42 local $" = "\n ";
44 42 print SYMBOLS "$tag => [ qw(\n @names\n ) ],\n"
45 }
46 2 print SYMBOLS ");\n\n# shorter aliases:\n";
47  
48 2 my @all_tags = POSIX::1003::_tags();
49 2 foreach my $tag (sort @all_tags)
50 72 { my ($mod) = POSIX::1003::_tag2mods($tag);
51 72 my $long = POSIX::1003::_mod2tag($mod);
52 72 ▶ printf SYMBOLS "\$EXPORT_TAGS%-10s = \$EXPORT_TAGS{$long};\n", "{$tag}"
Branch: 1 branch
BranchTrueFalseTotal
if $long ne $tag 30 42 72
53 if $long ne $tag;
54 }
55 2 print SYMBOLS "\n\n# sub-set exports:\n";
56  
57 2 my %generic_export = map +($_ => 1), qw/functions tables constants actions/;
58  
59 2 foreach my $tag (sort keys %subsets)
60 { printf SYMBOLS "\$SUBSET%-10s = '$tag';\n", "{$_}"
61 42 for grep !$generic_export{$_}, @{$subsets{$tag}};
62 }
63  
64 2 print SYMBOLS <<_TAIL;
65  
66 1;
67 _TAIL
68  
69 2 ▶close SYMBOLS
Branch: 1 branch
BranchTrueFalseTotal
close SYMBOLS or die "write errors to ${symbols}: $!" 2 0 2
70 or die "write errors to $symbols: $!";
« 1003.xs ↑ Summary blib/lib/POSIX/1003/Symbols.pm »