XML/Test.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 16 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 12 Podpod 0.0% 0 / 8 totaltotal 0.0% 0 / 86 CC 9 SCAR 37.3
CC
9
Cov
0%
_init
90.0
BEGIN
2.0
new
2.0
CRAP 41.6
1 package PITA::XML::Test;
2  
3 =pod
4  
5 =head1 NAME
6  
7 PITA::XML::Test - The result of an single executed test script
8  
9 =head1 DESCRIPTION
10  
11 The C<PITA::XML::Test> class provides data objects that represent the
12 output from a single test script.
13  
14 =head1 METHODS
15  
16 =cut
17  
18 use strict;
19 use Carp ();
20 use Params::Util qw{ _STRING _SCALAR0 };
21  
22 use vars qw{$VERSION};
23 BEGIN {
24 $VERSION = '0.52';
25 }
26  
27  
28  
29  
30  
31 #####################################################################
32 # Constructor and Accessors
33  
34 =pod
35  
36 =head2 new
37  
38 The C<new> constructor is used to create a new test result.
39  
40 TO BE COMPLETED
41  
42 Returns a C<PITA::XML::Text> object, or dies on error.
43  
44 =cut
45  
46 sub new {
47 my $class = shift;
48 my $self = bless { @_ }, $class;
49  
50 # Check the object
51 $self->_init;
52  
53 $self;
54 }
55  
56 sub _init {
57 my $self = shift;
58  
59 # Check the test name
60 if ( $self->name ) {
61 unless ( _STRING($self->name) ) {
62 Carp::croak('Invalid or missing cmd');
63 }
64 } else {
65 $self->{name} = undef;
66 }
67  
68 # Check the mime-type
69 $self->{language} ||= 'text/x-tap';
70 unless ( _STRING($self->language) ) {
71 Carp::croak('Invalid or missing language mime-type');
72 }
73  
74 # Check the STDOUT
75 unless ( PITA::XML->_OUTPUT($self, 'stdout') ) {
76 Carp::croak('Invalid or missing STDOUT output');
77 }
78  
79 # Check the STDERR (optional)
80 if ( defined $self->stderr or exists $self->{stderr} ) {
81 unless ( PITA::XML->_OUTPUT($self, 'stderr') ) {
82 Carp::croak('Invalid or missing STDERR output');
83 }
84 } else {
85 $self->{stderr} = undef;
86 }
87  
88 # Check the optional exit code
89 if ( defined $self->exitcode ) {
90 unless ( defined _STRING($self->exitcode) ) {
91 Carp::croak('Invalid exit code');
92 }
93 } else {
94 $self->{exitcode} = undef;
95 }
96  
97 $self;
98 }
99  
100 =pod
101  
102 =head2 name
103  
104 The C<name> accessor returns the name of the test, if it has one.
105  
106 Returns a not-null string, or C<undef> if the test is unnamed.
107  
108 =cut
109  
110 sub name {
111 $_[0]->{name};
112 }
113  
114 =pod
115  
116 =head2 language
117  
118 The C<language> accessor returns the mime-type of the test output.
119  
120 On creation, this defaults to "text/x-tap" unless otherwise specified.
121  
122 =cut
123  
124 sub language {
125 $_[0]->{language};
126 }
127  
128 =pod
129  
130 =head2 stdout
131  
132 The C<stdout> accessor returns the output of the test as a
133 C<SCALAR> reference.
134  
135 =cut
136  
137 sub stdout {
138 $_[0]->{stdout};
139 }
140  
141 =pod
142  
143 =head2 stderr
144  
145 The C<stderr> accessor returns the error output of the command
146 as a C<SCALAR> reference, or C<undef> if the test was run via a
147 communications mechanism that does not support error output.
148  
149 =cut
150  
151 sub stderr {
152 $_[0]->{stderr};
153 }
154  
155 =pod
156  
157 =head2 exitcode
158  
159 The C<exitcode> accessor returns the process exit code of the test,
160 if run across a communications mechanism that supports the concept
161 of an exit code.
162  
163 Returns a not-null string (generally an integer), or C<undef> if the
164 test did not return an exit code.
165  
166 =cut
167  
168 sub exitcode {
169 $_[0]->{exitcode};
170 }
171  
172 1;
173  
174  
175 =pod
176  
177 =head1 SUPPORT
178  
179 Bugs should be reported via the CPAN bug tracker at
180  
181 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PITA-XML>
182  
183 For other issues, contact the author.
184  
185 =head1 AUTHOR
186  
187 Adam Kennedy E<lt>adamk@cpan.orgE<gt>, L<http://ali.as/>
188  
189 =head1 SEE ALSO
190  
191 L<PITA::XML>
192  
193 The Perl Image-based Testing Architecture (L<http://ali.as/pita/>)
194  
195 =head1 COPYRIGHT
196  
197 Copyright 2005 - 2013 Adam Kennedy.
198  
199 This program is free software; you can redistribute
200 it and/or modify it under the same terms as Perl itself.
201  
202 The full text of the license can be found in the
203 LICENSE file included with this module.
204  
205 =cut