File Coverage

blib/lib/App/RecordStream/Test/Tester.pm
Criterion Covered Total %
statement 33 33 100.0
branch 2 4 50.0
condition n/a
subroutine 8 8 100.0
pod 0 4 0.0
total 43 49 87.7


line stmt bran cond sub pod time code
1             package App::RecordStream::Test::Tester;
2              
3             our $VERSION = "4.0.24";
4              
5 8     8   426664 use strict;
  8         24  
  8         289  
6 8     8   58 use warnings;
  8         21  
  8         364  
7              
8 8     8   3013 use App::RecordStream::Test::OperationHelper;
  8         33  
  8         57  
9              
10             sub new {
11 7     7 0 856 my $class = shift;
12 7         22 my $operation = shift;
13              
14 7         33 my $this = {
15             OPERATION => $operation,
16             };
17              
18 7         24 bless $this, $class;
19 7         27 return $this;
20             }
21              
22             sub no_input_test {
23 3     3 0 144 my $this = shift;
24 3         9 my $args = shift;
25 3         9 my $output = shift;
26              
27             return App::RecordStream::Test::OperationHelper->do_match(
28 3         33 $this->{'OPERATION'},
29             $args,
30             undef,
31             $output,
32             );
33             }
34              
35             sub test_input {
36 16     16 0 742 my $this = shift;
37 16         41 my $args = shift;
38 16         38 my $input = shift;
39 16         38 my $output = shift;
40              
41             return App::RecordStream::Test::OperationHelper->do_match(
42 16         167 $this->{'OPERATION'},
43             $args,
44             ['LINES', split(/\n/, $input)],
45             $output,
46             );
47             }
48              
49             sub test_stdin {
50 14     14 0 393 my $this = shift;
51 14         25 my $args = shift;
52 14         29 my $input = shift;
53 14         27 my $output = shift;
54              
55             # Re-open stdin to the given input
56 14 50       75 close(STDIN) or die "Cannot close STDIN: $!";
57 2 50   2   18 open(STDIN, "<", \$input) or die "Cannot re-open STDIN to string ref: $!";
  2         5  
  2         18  
  14         165  
58              
59             return App::RecordStream::Test::OperationHelper->do_match(
60 14         1399 $this->{'OPERATION'},
61             $args,
62             undef,
63             $output,
64             );
65             }
66              
67             1;