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 13     13   199 use v5.14;
  13         56  
2 13     13   72 use warnings;
  13         28  
  13         2745  
3              
4             package Test::BDD::Cucumber::Util 0.86;
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.86
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 502     502 1 943 my $string = shift;
41 502         1213 $string =~ s/\\(.)/${marker_start} . ord($1) . ${marker_end}/ge;
  0         0  
42 502         1168 return $string;
43             }
44              
45             sub bs_unquote {
46 502     502 1 823 my $string = shift;
47 502         2145 $string =~ s/$marker_start(\d+)$marker_end/chr($1)/ge;
  0         0  
48 502         1569 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;