File Coverage

blib/lib/Test/DBD/PO/Defaults.pm
Criterion Covered Total %
statement 23 30 76.6
branch 0 2 0.0
condition n/a
subroutine 8 9 88.8
pod 2 2 100.0
total 33 43 76.7


line stmt bran cond sub pod time code
1             package Test::DBD::PO::Defaults;
2            
3 27     27   134564 use strict;
  27         62  
  27         1064  
4 27     27   150 use warnings;
  27         53  
  27         1523  
5            
6             #use Carp qw(confess); $SIG{__DIE__} = sub {confess @_};
7            
8             our $VERSION = '2.05';
9            
10 27     27   26257 use parent qw(Exporter);
  27         10032  
  27         278  
11             our @EXPORT_OK = qw(
12             $TRACE
13             $DROP_TABLE
14            
15             $UNTAINT_FILENAME_PATTERN
16             $PATH
17             $PATH_P
18             $PATH_M
19             $SEPARATOR
20             $EOL
21            
22             $TABLE_0X
23             $TABLE_11
24             $TABLE_12
25             $TABLE_13
26             $TABLE_14
27             $TABLE_15
28             $TABLE_2X
29             $TABLE_2P
30             $TABLE_2M
31            
32             $FILE_LOCALE_PO_01
33             $FILE_LOCALE_PO_02
34             $FILE_TEXT_PO
35             $FILE_0X
36             $FILE_11
37             $FILE_12
38             $FILE_13
39             $FILE_14
40             $FILE_15
41             $FILE_2X
42             $FILE_2P
43             $FILE_2M
44            
45             trace_file_name
46             run_example
47             );
48            
49 27     27   2694 use Carp qw(croak);
  27         60  
  27         1814  
50 27     27   14066 use English qw(-no_match_vars $OS_ERROR $EVAL_ERROR $INPUT_RECORD_SEPARATOR);
  27         73413  
  27         177  
51 27     27   5644 use Cwd qw(getcwd);
  27         56  
  27         1802  
52 27     27   38446 use Socket qw($LF $CRLF);
  27         137932  
  27         43737  
53            
54             our $TRACE = 1;
55             our $DROP_TABLE = 1;
56            
57             our $UNTAINT_FILENAME_PATTERN = qr{\A (
58             (?:
59             (?: [A-Z] : )
60             | //
61             )?
62             [0-9A-Z_\-/\. ]+
63             ) \z}xmsi;
64             our ($PATH) = getcwd() =~ $UNTAINT_FILENAME_PATTERN;
65             $PATH =~ s{\\}{/}xmsg;
66             our $PATH_P = "$PATH/example/LocaleData/de/LC_MESSAGES";
67             our $PATH_M = "$PATH/example/LocaleData/de/LC_MESSAGES";
68             our $SEPARATOR = $LF;
69             our $EOL = $CRLF;
70            
71             my $TABLE_LOCALE_PO_01 = 'locale_po_01.po';
72             my $TABLE_LOCALE_PO_02 = 'locale_po_02.po';
73             my $TABLE_TEXT_PO = 'text_po.po';
74             our $TABLE_0X = 'dbd_po_test.po';
75             our $TABLE_11 = 'dbd_po_crash.po';
76             our $TABLE_12 = 'dbd_po_more_tables_?.po';
77             our $TABLE_13 = 'dbd_po_charset_?.po';
78             our $TABLE_14 = 'dbd_po_quote.po';
79             our $TABLE_15 = 'dbd_po_header_msgstr_hash.po';
80             our $TABLE_2X = 'table_de.po';
81             our $TABLE_2P = 'table_plural.po';
82             our $TABLE_2M = 'table_plural.mo';
83            
84             our $FILE_LOCALE_PO_01 = "$PATH/$TABLE_LOCALE_PO_01";
85             our $FILE_LOCALE_PO_02 = "$PATH/$TABLE_LOCALE_PO_02";
86             our $FILE_TEXT_PO = "$PATH/$TABLE_TEXT_PO";
87             our $FILE_0X = "$PATH/$TABLE_0X";
88             our $FILE_11 = "$PATH/$TABLE_11";
89             our $FILE_12 = "$PATH/$TABLE_12";
90             our $FILE_13 = "$PATH/$TABLE_13";
91             our $FILE_14 = "$PATH/$TABLE_14";
92             our $FILE_15 = "$PATH/$TABLE_15";
93             our $FILE_2X = "$PATH/$TABLE_2X";
94             our $FILE_2P = "$PATH_P/$TABLE_2P";
95             our $FILE_2M = "$PATH_M/$TABLE_2M";
96            
97             sub trace_file_name {
98 1     1 1 41 my ($number) = (caller 0)[1] =~ m{\b (\d\d) \w+ \. t}xms;
99            
100 1         202 return "$PATH/trace_$number.txt";
101             }
102            
103             sub run_example {
104 0     0 1   my $file_name = shift;
105            
106 0 0         open my $file, '<', "$PATH/example/$file_name"
107             or croak $OS_ERROR;
108 0           local $INPUT_RECORD_SEPARATOR = ();
109 0           my ($content) = <$file> =~ m{\A (.*) \z}xms; # untaint
110 0           () = close $file;
111 0           () = eval $content; ## no critic (ProhibitStringyEval)
112            
113 0           return $EVAL_ERROR;
114             }
115            
116             1;
117            
118             __END__