File Coverage

blib/lib/Test/BDD/Cucumber/Util.pm
Criterion Covered Total %
statement 11 13 84.6
branch n/a
condition n/a
subroutine 4 4 100.0
pod 2 2 100.0
total 17 19 89.4


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