| 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
Condition100%3/3
ref $image and ref $image eq "ARRAY"
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"
| |||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||
| 69 | unless $x =~ /^\d+$/; | ||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | 20 | ▶ | die "'$y' not a valid value for y" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 72 | unless $y =~ /^\d+$/; | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 20 | ▶ | return unless $self->{image}->[$y][$x]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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 | |||||||||||||||||||||||||||||