line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id: TestResult.pm,v 1.5 2003/03/02 11:52:10 m_ilya Exp $ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HTTP::WebTest::TestResult; |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 NAME |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
HTTP::WebTest::TestResult - Test results class |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use HTTP::WebTest::TestResult; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $result = HTTP::WebTest::TestResult; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $bool = $result->ok; |
16
|
|
|
|
|
|
|
$result->ok($bool); |
17
|
|
|
|
|
|
|
my $comment = $result->comment; |
18
|
|
|
|
|
|
|
$result->comment($comment); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
if($result) { ... } |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 DESCRIPTION |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
Objects of this class represent test results. Test results are |
25
|
|
|
|
|
|
|
basicly C/C and some attached commentary. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
This class overloads C operation so it can be directly used in |
28
|
|
|
|
|
|
|
statements that require boolean values. |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
if($result) { ... } |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
is equivalent to |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
if($result->ok) { ... } |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=head1 CLASS METHODS |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
39
|
|
|
|
|
|
|
|
40
|
21
|
|
|
21
|
|
115
|
use strict; |
|
21
|
|
|
|
|
43
|
|
|
21
|
|
|
|
|
718
|
|
41
|
|
|
|
|
|
|
|
42
|
21
|
|
|
21
|
|
125
|
use HTTP::WebTest::Utils qw(make_access_method); |
|
21
|
|
|
|
|
35
|
|
|
21
|
|
|
|
|
1268
|
|
43
|
|
|
|
|
|
|
|
44
|
21
|
|
|
21
|
|
137
|
use overload bool => \&_bool; |
|
21
|
|
|
|
|
34
|
|
|
21
|
|
|
|
|
385
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head2 new () |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
Constructor |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head3 Returns |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
A new C object. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub new { |
57
|
373
|
|
|
373
|
1
|
663
|
my $proto = shift; |
58
|
373
|
|
33
|
|
|
3656
|
my $class = ref($proto) || $proto; |
59
|
|
|
|
|
|
|
|
60
|
373
|
|
|
|
|
1320
|
my $self = bless {}, $class; |
61
|
|
|
|
|
|
|
|
62
|
373
|
|
|
|
|
1172
|
return $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 ok ($optional_ok) |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
If C<$optional_ok> is passed, |
68
|
|
|
|
|
|
|
Defines whether or not test is successful. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head3 Returns |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
True if test is successful. False otherwise. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=cut |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
*ok = make_access_method('OK'); |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 comment ($optional_comment) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
If C<$optional_comment> is passed, sets test result comment. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head3 Returns |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
A test result comment. |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=cut |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
*comment = make_access_method('COMMENT'); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
# this method is used to overload 'bool' operation. 'ok' can't be used |
91
|
|
|
|
|
|
|
# directly because method which is overloads operation is called with |
92
|
|
|
|
|
|
|
# some additional arguments which doesn't play nice with accessor |
93
|
|
|
|
|
|
|
# method like 'ok' |
94
|
742
|
|
|
742
|
|
2033
|
sub _bool { shift->ok } |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 COPYRIGHT |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Copyright (c) 2001-2003 Ilya Martynov. All rights reserved. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
101
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 SEE ALSO |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
L |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
L |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
L |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=cut |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |