File Coverage

OK.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 25 25 100.0


line stmt bran cond sub pod time code
1             package Tie::Scalar::OK;
2              
3 1     1   880 use strict;
  1         2  
  1         40  
4 1     1   5 use base qw(Tie::Scalar);
  1         2  
  1         889  
5 1     1   742 use vars qw($VERSION);
  1         2  
  1         205  
6              
7             $VERSION = '1.06';
8              
9             sub TIESCALAR {
10 1     1   479 my $class = shift;
11 1         4 my $self = {
12             i => 0,
13             ok => '',
14             };
15 1         6 return bless $self, $class;
16             }
17              
18             sub STORE {
19 2     2   394 my ($self,$ok) = @_;
20 2 100       12 $self->{ok} = $ok ? 'ok' : 'not ok';
21 2         7 $self->{i}++;
22             }
23              
24             sub FETCH {
25 2     2   41 my ($self) = @_;
26 2         11 return "$self->{ok} $self->{i}\n";
27             }
28              
29             1;
30              
31             =pod
32              
33             =head1 NAME
34              
35             Tie::Scalar::OK - generate numbered 'ok/not ok' strings
36              
37             =head1 DESCRIPTION
38              
39             This module generates the output that test modules expect
40             in a similar manner as Test.pm, i.e. "ok #" or "not ok #"
41             strings are printed to STDOUT for pass and fail, respectively.
42              
43             =head1 SYNOPSIS
44              
45             use strict;
46             use Tie::Scalar::OK;
47              
48             my $ok;
49             tie $ok, 'Tie::Scalar::OK';
50              
51             print $ok = (1 != 1); # not ok
52             print $ok = (2 == 1+1); # ok
53             print $ok = ('foo' eq join('',qw(f o o))); # ok
54             print $ok = ('rab' ne scalar reverse 'bar'); # not ok
55             print $ok = ('phenobarbitone' =~ /bar/ ); # ok
56             print $ok = (0 != (32&(32-1))); # not ok
57              
58             =head1 BUGS
59              
60             If you have found a bug, typo, etc. please visit Best Practical Solution's
61             CPAN bug tracker at http://rt.cpan.org:
62              
63             Ehttp://rt.cpan.org/NoAuth/Bugs.html?Dist=Tie-Scalar-OKE
64              
65             or send mail to Ebug-Tie-Scalar-OK#rt.cpan.orgE
66              
67             (you got this far ... you can figure out how to make that
68             a valid address ... and note that i won't respond to bugs
69             sent to my personal address any longer)
70              
71             =head1 AUTHOR
72              
73             Jeffrey Hayes Anderson
74              
75             =head1 SEE ALSO
76              
77             Test
78             Test::Harness
79             Test::Simple
80             Test::More
81              
82             =head1 COPYRIGHT
83              
84             Copyright (c) 2004 Jeffrey Hayes Anderson.
85              
86             Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
87              
88             The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
89              
90             THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
91              
92             =cut