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.25";
4              
5 8     8   331346 use strict;
  8         72  
  8         158  
6 8     8   30 use warnings;
  8         12  
  8         167  
7              
8 8     8   2618 use App::RecordStream::Test::OperationHelper;
  8         19  
  8         43  
9              
10             sub new {
11 7     7 0 506 my $class = shift;
12 7         18 my $operation = shift;
13              
14 7         20 my $this = {
15             OPERATION => $operation,
16             };
17              
18 7         16 bless $this, $class;
19 7         17 return $this;
20             }
21              
22             sub no_input_test {
23 3     3 0 43 my $this = shift;
24 3         3 my $args = shift;
25 3         4 my $output = shift;
26              
27             return App::RecordStream::Test::OperationHelper->do_match(
28 3         14 $this->{'OPERATION'},
29             $args,
30             undef,
31             $output,
32             );
33             }
34              
35             sub test_input {
36 16     16 0 411 my $this = shift;
37 16         20 my $args = shift;
38 16         19 my $input = shift;
39 16         21 my $output = shift;
40              
41             return App::RecordStream::Test::OperationHelper->do_match(
42 16         100 $this->{'OPERATION'},
43             $args,
44             ['LINES', split(/\n/, $input)],
45             $output,
46             );
47             }
48              
49             sub test_stdin {
50 14     14 0 245 my $this = shift;
51 14         17 my $args = shift;
52 14         17 my $input = shift;
53 14         17 my $output = shift;
54              
55             # Re-open stdin to the given input
56 14 50       56 close(STDIN) or die "Cannot close STDIN: $!";
57 2 50   2   11 open(STDIN, "<", \$input) or die "Cannot re-open STDIN to string ref: $!";
  2         3  
  2         9  
  14         93  
58              
59             return App::RecordStream::Test::OperationHelper->do_match(
60 14         1225 $this->{'OPERATION'},
61             $args,
62             undef,
63             $output,
64             );
65             }
66              
67             1;