File Coverage

blib/lib/Test/BDD/Cucumber/Util.pm
Criterion Covered Total %
statement 12 14 85.7
branch n/a
condition n/a
subroutine 4 4 100.0
pod 2 2 100.0
total 18 20 90.0


line stmt bran cond sub pod time code
1             package Test::BDD::Cucumber::Util;
2             $Test::BDD::Cucumber::Util::VERSION = '0.84';
3 13     13   97 use strict;
  13         32  
  13         408  
4 13     13   65 use warnings;
  13         42  
  13         2666  
5              
6             =head1 NAME
7              
8             Test::BDD::Cucumber::Util - Some functions used throughout the code
9              
10             =head1 VERSION
11              
12             version 0.84
13              
14             =head1 DESCRIPTION
15              
16             Some functions used throughout the code
17              
18             =head1 FUNCTIONS
19              
20             =head2 bs_quote
21              
22             =head2 bs_unquote
23              
24             C "makes safe" strings with backslashed characters in it, so other
25             operations can be done on them. C goes the other way.
26              
27             $string = "foo \ ";
28             $string = bs_quote( $string );
29             $string =~ s/<([^>]+)>/"$1"/g;
30             $string = bs_unquote( $string );
31             $string eq 'foo "baz"';
32              
33             =cut
34              
35             my $marker_start = ';;;TEST_BDD_TEMP_MARKER_OPEN;;;';
36             my $marker_end = ';;;TEST_BDD_TEMP_MARKER_END;;;';
37              
38             sub bs_quote {
39 496     496 1 994 my $string = shift;
40 496         1231 $string =~ s/\\(.)/${marker_start} . ord($1) . ${marker_end}/ge;
  0         0  
41 496         1132 return $string;
42             }
43              
44             sub bs_unquote {
45 496     496 1 845 my $string = shift;
46 496         2121 $string =~ s/$marker_start(\d+)$marker_end/chr($1)/ge;
  0         0  
47 496         1738 return $string;
48             }
49              
50             =head1 AUTHOR
51              
52             Peter Sergeant C
53              
54             =head1 LICENSE
55              
56             Copyright 2019-2023, Erik Huelsmann
57             Copyright 2011-2019, Peter Sergeant; Licensed under the same terms as Perl
58              
59             =cut
60              
61             1;