blib/lib/Test/Image/Plugin/TestingImage.pm

filter: Statementstmt 100% 22 / 22 Branchbran 75.0% 6 / 8 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 5 / 5 Podpod 100% 4 / 4 totaltotal 95.4% 42 / 44 CC 6 SCAR 10.4
CC
6
Cov
94%
color_at
4.0
new
3.0
BEGIN
1.0
CRAP 2.8
↑ Summary mbk/Module/Build/Kwalitee.pm »
1 package Test::Image::Plugin::TestingImage;
2  
3 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 # use warnings; # I want this to work with old perls!
5  
6 12 our $VERSION = "0.01";
7  
8 =head1 NAME
9  
10 Test::Image::Plugin::TestingImage - for testing only
11  
12 =head1 SYNOPSIS
13  
14 use Test::Image;
15 my $red = [255,0,0];
16 my $green = [0,255,0];
17 my $white = [255,255,255];
18 test_image([
19 [ $red, $red, $white, $white, $green, $green ],
20 [ $red, $red, $white, $white, $green, $green ],
21 [ $red, $red, $white, $white, $green, $green ],
22 ]);
23  
24 =head1 DESCRIPTION
25  
26 This is an image designed for testing. This defines the standard
27 method that you need to implement in order to provide an image.
28  
29 =over
30  
31 =item new
32  
33 =item width
34  
35 =item height
36  
37 =item color_at($x,$y)
38  
39 =back
40  
41 See L<Test::Image> for more details of what these should do.
42  
43 =cut
44  
45 4 ▶sub new {
Subroutine new: called CC=3 SCAR=11.0
Pod documented
46 4 my $class = shift;
47 4 my $image = shift;
48 4 ▶ return undef unless ref $image && ref $image eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
unless ref $image and ref $image eq "ARRAY" 3 1 4
Condition100%3/3
ref $image and ref $image eq "ARRAY"
!ll&&!rl&&r
211
MC/DC100%2/2
ref $image and ref $image eq "ARRAY"
ref $image ref $image eq "ARRAY"
Truth table100%3/3
A and B
A= ref $imageB= ref $image eq "ARRAY"
ABresult
0X0
100
111
49
50
51 return bless {
52 image => $image,
53 1 width => scalar(@{ $image->[0] }),
54 1 height => scalar(@{ $image }),
55 }, $class;
56 }
57  
58 1 ▶sub width { $_[0]->{width} }
Subroutine width: called CC=1 SCAR=0.0
Pod documented
59 1 ▶sub height { $_[0]->{height} }
Subroutine height: called CC=1 SCAR=0.0
Pod documented
60  
61 20 ▶sub color_at {
Subroutine color_at: called CC=4 SCAR=14.0
Pod documented
62 20 my $self = shift;
63 20 my $image = $self->{image};
64
65 20 my $x = shift;
66 20 my $y = shift;
67
68 20 ▶ die "'$x' not a valid value for x"
Branch: 1 branch
BranchTrueFalseTotal
unless $x =~ /^\d+$/ 0 20 20
69 unless $x =~ /^\d+$/;
70  
71 20 ▶ die "'$y' not a valid value for y"
Branch: 1 branch
BranchTrueFalseTotal
unless $y =~ /^\d+$/ 0 20 20
72 unless $y =~ /^\d+$/;
73  
74 20 ▶ return unless $self->{image}->[$y][$x];
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"image"}[$y][$x] 2 18 20
75 18 return @{ $self->{image}->[$y][$x] };
76 }
77  
78 =head1 BUGS
79  
80 None known.
81  
82 Please report any bugs you find via the CPAN RT system.
83 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Test::Image::Plugin::TestingImage>
84  
85 =head1 AUTHOR
86  
87 Written by Mark Fowler, E<lt>mark@twoshortplanks.comE<gt>. Please see
88 L<http://twoshortplanks.com/contact/> for details of how to contact me.
89  
90 Copyright Fotango 2006. All rights reserved.
91  
92 This module is free software; you can redistribute it and/or modify it under
93 the same terms as Perl itself.
94  
95 =head1 SEE ALSO
96  
97  
98  
99 =cut
100  
101 12 1;
102  
↑ Summary mbk/Module/Build/Kwalitee.pm »