File Coverage

lib/POSIX/1003/Properties.pm
Criterion Covered Total %
statement 25 30 83.3
branch 1 6 16.6
condition 1 2 50.0
subroutine 9 11 81.8
pod 3 3 100.0
total 39 52 75.0


line stmt bran cond sub pod time code
1             # Copyrights 2011-2020 by [Mark Overmeer].
2             # For other contributors see ChangeLog.
3             # See the manual pages for details on the licensing terms.
4             # Pod stripped from pm file by OODoc 2.02.
5             # This code is part of distribution POSIX-1003. Meta-POD processed with
6             # OODoc into POD and HTML manual-pages. See README.md
7             # Copyright Mark Overmeer. Licensed under the same terms as Perl itself.
8              
9             package POSIX::1003::Properties;
10 3     3   74389 use vars '$VERSION';
  3         14  
  3         171  
11             $VERSION = '1.02';
12              
13 3     3   17 use base 'POSIX::1003::Module';
  3         4  
  3         589  
14              
15 3     3   19 use warnings;
  3         5  
  3         72  
16 3     3   12 use strict;
  3         6  
  3         83  
17              
18 3     3   14 use Carp 'croak';
  3         5  
  3         427  
19              
20             my @constants;
21             my @functions = qw/property property_names/;
22              
23             our %EXPORT_TAGS =
24             ( constants => \@constants
25             , functions => \@functions
26             , tables => [ '%property' ]
27             );
28              
29             my $property;
30             our %property;
31              
32             BEGIN {
33 3     3   247 $property = property_table;
34 3         124 push @constants, keys %$property;
35 3         34 tie %property, 'POSIX::1003::ReadOnlyTable', $property;
36             }
37              
38             sub property($);
39              
40              
41             sub exampleValue($)
42 0     0 1 0 { my ($class, $name) = @_;
43 0 0       0 $name =~ m/^_POSIX/ or return;
44 0         0 my $val = property $name;
45 0 0       0 defined $val ? $val : 'undef';
46             }
47              
48              
49             sub property($)
50 104   50 104 1 2087 { my $key = shift // return;
51 104 50       313 $key =~ /^_POSIX/
52             or croak "pass the constant name as string";
53              
54 104         226 $property->{$key};
55             }
56              
57             sub _create_constant($)
58 1     1   4 { my ($class, $name) = @_;
59 1         7 my $value = $property->{$name};
60 1     0   9 sub() {$value};
  0         0  
61             }
62              
63              
64 1     1 1 1559 sub property_names() { keys %$property }
65              
66              
67             1;