JavaScript/Test.pm

filter: Statementstmt 91.6% 77 / 84 Branchbran 61.1% 11 / 18 Conditioncond 58.3% 7 / 12 MC/DCmcdc 16.6% 1 / 6 Subroutinesub 100% 20 / 20 Podpod n/a totaltotal 82.8% 116 / 140 CC 17 SCAR 19.2
CC
17
Cov
83%
_is_anyone_sealed
29.4
handle_sealed
4.4
check_stash
4.1
CRAP 6.8
↑ Summary JavaScript/AutoSelect.pm »
1 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 4 ▶use warnings FATAL => 'all';
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 package HTML::Tested::JavaScript::Test::Serializer::Array;
5 4 ▶use base 'HTML::Tested::Test::Value';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 ▶sub handle_sealed {
Subroutine handle_sealed: called CC=4 SCAR=14.8
8 2 my ($class, $e_root, $name, $e_val, $r_val, $err) = @_;
9 2 my @e;
10 2 my @res = $class->SUPER::handle_sealed($e_root, $name
11 , $e_val, $r_val, \@e);
12 2 ▶ push @$err, @e if (@e && !(@{ $e_root->$name } == 0
Branch: 1 branch
BranchTrueFalseTotal
if @e and not @{$e_root->$name;} == 0 && $e[0] =~ /wasn't sealed/ 0 2 2
Condition50%3/6
@e and not @{$e_root->$name;} == 0 && $e[0] =~ /wasn't sealed/
!ll&&!rl&&r
110
@{$e_root->$name;} == 0 && $e[0] =~ /wasn't sealed/
!ll&&!rl&&r
001
MC/DC0%0/3
@e and not @{$e_root->$name;} == 0 && $e[0] =~ /wasn't sealed/
@e @{$e_root->$name;} == 0 $e[0] =~ /wasn't sealed/
Truth table50%2/4
A and not(B && C)
A= @eB= @{$e_root->$name;} == 0C= $e[0] =~ /wasn't sealed/
ABCresult
0XX0
1110
10X1
1101
13 && $e[0] =~ /wasn't sealed/));
14 2 return @res;
15 }
16  
17 2 ▶sub convert_to_sealed {
Subroutine convert_to_sealed: called CC=1 SCAR=0.0
18 2 my ($self, $val) = @_;
19 2 my $seal = HTML::Tested::Seal->instance;
20 2 return [ map { $seal->encrypt($_) } @$val ];
21 }
22  
23 3 ▶sub convert_to_param {
Subroutine convert_to_param: called CC=1 SCAR=0.0
24 3 my ($class, $obj_class, $r, $name, $val) = @_;
25 3 return $class->SUPER::convert_to_param($obj_class, $r, $name
26 , join(",", @$val));
27 }
28  
29 package HTML::Tested::JavaScript::Test::Serializer::Value;
30 4 ▶use base 'HTML::Tested::Test::Value';
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 15 ▶sub check_text {
Subroutine check_text: called CC=2 SCAR=6.9
33 15 my ($class, $e_root, $name, $e_stash, $text) = @_;
34 15 ▶ $e_stash->{$name} =~ s#/#\\/#g if $e_stash->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $e_stash->{$name} 14 1 15
35 15 return $class->SUPER::check_text($e_root, $name, $e_stash, $text);
36 }
37  
38 package HTML::Tested::JavaScript::Test::Serializer;
39 4 ▶use base 'HTML::Tested::Test::Value';
Subroutine BEGIN: called CC=1 SCAR=0.0
40 4 ▶use Text::Diff;
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 31 ▶sub _is_anyone_sealed {
Subroutine _is_anyone_sealed: called CC=6 SCAR=33.8
43 31 my ($class, $e_root, $js) = @_;
44 31 return $class->SUPER::is_marked_as_sealed($e_root, $js);
45 0 my $a = $e_root->{$js};
46 0 ▶ return undef unless ref($a);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $a 0 0 0
47 0 for my $r (@$a) {
48 0 ▶ next unless ref($r);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $r 0 0 0
49 0 for my $k (keys %$r) {
50 0 ▶ return 1 if $class->_is_anyone_sealed($r, $k);
Branch: 1 branch
BranchTrueFalseTotal
if $class->_is_anyone_sealed($r, $k) 0 0 0
51 }
52 }
53 0 return undef;
54 }
55  
56 10 ▶sub is_marked_as_sealed {
Subroutine is_marked_as_sealed: called CC=3 SCAR=11.0
57 10 my ($class, $e_root, $name) = @_;
58 10 my $ser_widget = $e_root->ht_find_widget($name);
59 10 for my $j (@{ $ser_widget->{_jses} }) {
60 31 ▶ next unless $class->_is_anyone_sealed($e_root, $j);
Branch: 1 branch
BranchTrueFalseTotal
unless $class->_is_anyone_sealed($e_root, $j) 30 1 31
61 1 return 1;
62 }
63 9 return undef;
64 }
65  
66 6 ▶sub check_stash {
Subroutine check_stash: called CC=4 SCAR=14.0
67 6 my ($class, $e_root, $name, $e_stash, $r_stash) = @_;
68 6 my @res = $class->SUPER::check_stash($e_root, $name
69 , $e_stash, $r_stash);
70 6 my ($ev, $rv) = ($e_stash->{$name}, $r_stash->{$name});
71 6 ▶ $res[0] .= "\nThe diff is:\n" . diff(\$ev, \$rv)
Branch: 1 branch
BranchTrueFalseTotal
if @res and $ev and $rv 4 2 6
Condition66%4/6
@res and $ev and $rv
!ll&&!rl&&r
204
@res and $ev
!ll&&!rl&&r
204
MC/DC33%1/3
@res and $ev and $rv
@res $ev $rv
Truth table50%2/4
A and B and C
A= @resB= $evC= $rv
ABCresult
0XX0
10X0
1100
1111
72 if (@res && $ev && $rv);
73 6 return @res;
74 }
75  
76 4 ▶sub check_text {
Subroutine check_text: called CC=3 SCAR=11.0
77 4 my ($class, $e_root, $name, $e_stash, $text) = @_;
78 4 my @res = $class->SUPER::check_text($e_root, $name, $e_stash, $text);
79 4 ▶ if (@res) {
Branch: 1 branch
BranchTrueFalseTotal
if (@res) 2 2 4
80 2 my $his = HTML::Tested::JavaScript::Serializer::Extract_Text(
81 $name, $text);
82 my $mine = HTML::Tested::JavaScript::Serializer::Extract_Text(
83 2 $name, $e_stash->{$name});
84 2 ▶ $res[0] .= $his ? "\nThe diff is:\n" . diff(\$mine, \$his)
Branch: 1 branch
BranchTrueFalseTotal
$his ? : 1 1 2
85 : "\nUnable to extract text for diff\n";
86 }
87 4 return @res;
88 }
89  
90 package HTML::Tested::JavaScript::Test;
91 4 ▶use HTML::Tested::Test qw(Register_Widget_Tester);
Subroutine BEGIN: called CC=1 SCAR=0.0
92 4 ▶use HTML::Tested::JavaScript::Serializer;
Subroutine BEGIN: called CC=1 SCAR=0.0
93 4 ▶use HTML::Tested::JavaScript::Serializer::Value;
Subroutine BEGIN: called CC=1 SCAR=0.0
94 4 ▶use HTML::Tested::JavaScript::Serializer::Array;
Subroutine BEGIN: called CC=1 SCAR=0.0
95 4 ▶use HTML::Tested::JavaScript::RichEdit;
Subroutine BEGIN: called CC=1 SCAR=0.0
96 4 ▶use HTML::Tested::JavaScript::Test::RichEdit;
Subroutine BEGIN: called CC=1 SCAR=0.0
97  
98 4 Register_Widget_Tester("HTML::Tested::JavaScript::Serializer::Array"
99 , 'HTML::Tested::JavaScript::Test::Serializer::Array');
100 4 Register_Widget_Tester("HTML::Tested::JavaScript::Serializer::Value"
101 , 'HTML::Tested::JavaScript::Test::Serializer::Value');
102 4 Register_Widget_Tester("HTML::Tested::JavaScript::Serializer"
103 , 'HTML::Tested::JavaScript::Test::Serializer');
104 4 Register_Widget_Tester("HTML::Tested::JavaScript::RichEdit"
105 , 'HTML::Tested::JavaScript::Test::RichEdit');
106  
107 4 1;
↑ Summary JavaScript/AutoSelect.pm »