File Coverage

blib/lib/HTML/Tested/Test/Radio.pm
Criterion Covered Total %
statement 30 30 100.0
branch 7 8 87.5
condition n/a
subroutine 6 6 100.0
pod 0 2 0.0
total 43 46 93.4


line stmt bran cond sub pod time code
1 17     17   140 use strict;
  17         36  
  17         950  
2 17     17   101 use warnings FATAL => 'all';
  17         119  
  17         18098  
3              
4             package HTML::Tested::Test::Radio;
5 17     17   234 use base 'HTML::Tested::Test::Value';
  17         33  
  17         9995  
6              
7             sub _grep_my_vars {
8 19     19   23 my ($class, $name, $stash) = @_;
9 19         21 my @res;
10 19         59 while (my ($n, $v) = each %$stash) {
11 55 50       244 next unless $n =~ /^$name\_/;
12 55         171 push @res, $n;
13             }
14 19         425 return @res;
15             }
16              
17             sub check_stash {
18 7     7 0 11 my ($class, $e_root, $name, $e_stash, $r_stash) = @_;
19 7         9 my @err;
20 7         20 for my $n ($class->_grep_my_vars($name, $e_stash)) {
21 20         25 my $e_val = $e_stash->{$n};
22 20         52 my $r_val = HTML::Tested::Test::Ensure_Value_To_Check(
23             $r_stash, $n, $e_val, \@err);
24 20 100       39 next unless defined($r_val);
25 19 100       64 next if ($r_val eq $e_val);
26 1         4 push @err, HTML::Tested::Test::Stash_Mismatch(
27             $n, $r_val, $e_val);
28             }
29              
30 7         27 for my $n ($class->_grep_my_vars($name, $r_stash)) {
31 20 100       44 next if exists $e_stash->{$n};
32 1         4 push @err, HTML::Tested::Test::Stash_Mismatch(
33             $n, $r_stash->{$n}, undef);
34             }
35 7         45 return @err;
36             }
37              
38             sub check_text {
39 5     5 0 18 my ($class, $e_root, $name, $e_stash, $text) = @_;
40 15         61 return map {
41 5         18 $class->_check_text_i($e_root, $name, $e_stash->{$_}, $text)
42             } $class->_grep_my_vars($name, $e_stash);
43             }
44              
45             1;