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