File Coverage

blib/lib/OOP/Perlish/Class/Multiton/UnitTests/Multiton.pm
Criterion Covered Total %
statement 32 32 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 0 1 0.0
total 40 41 97.5


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2             {
3             package OOP::Perlish::Class::Multiton::UnitTests::Test1;
4 1     1   6 use OOP::Perlish::Class::Multiton;
  1         2  
  1         14  
5 1     1   7 use base qw(OOP::Perlish::Class::Multiton);
  1         2  
  1         130  
6              
7             BEGIN {
8 1     1   17 __PACKAGE__->_accessors(
9             thing => { type => 'SCALAR', validator => qr/.*foo.*/, required => 1 },
10             );
11             }
12              
13 8     8   32 sub _multiton_key { return 'thing' };
14             }
15              
16             {
17             package OOP::Perlish::Class::Multiton::UnitTests::Multiton;
18 1     1   11 use base Test::Class;
  1         1  
  1         119  
19 1     1   1410 use Test::More;
  1         7651  
  1         12  
20              
21             sub multitons : Test(10)
22             {
23 1     1 0 1883 my ($self) = @_;
24              
25 1         23 my $a = OOP::Perlish::Class::Multiton::UnitTests::Test1->new( thing => 'hello foo' );
26 1         8 my $b = OOP::Perlish::Class::Multiton::UnitTests::Test1->new( thing => 'goodbye foo' );
27 1         7 my $c = OOP::Perlish::Class::Multiton::UnitTests::Test1->new( thing => 'hello foo' );
28 1         6 my $d = OOP::Perlish::Class::Multiton::UnitTests::Test1->new( thing => 'goodbye foo' );
29              
30 1         7 is($a, $c, 'Multitons of the same key are the same a => c');
31 1         841 is($b, $d, 'Multitons of the same key are the same b => d');
32              
33 1         509 is($a->thing(), $c->thing(), 'Multitons of the same key have the same thing a => c');
34 1         534 is($b->thing(), $d->thing(), 'Multitons of the same key have the same thing b => d');
35              
36 1         468 ok( $a != $b, 'Multitons of different keys are unique a => b');
37 1         463 ok( $b != $c, 'Multitons of different keys are unique b => c');
38 1         433 ok( $c != $d, 'Multitons of different keys are unique c => d');
39              
40              
41 1         444 ok( $a->thing() ne $b->thing(), 'Multitons of different keys have unique things a(' . $a->thing() . ') => b(' . $b->thing() . ')');
42 1         483 ok( $b->thing() ne $c->thing(), 'Multitons of different keys have unique things b(' . $b->thing() . ') => c(' . $c->thing() . ')');
43 1         619 ok( $c->thing() ne $d->thing(), 'Multitons of different keys have unique things c(' . $c->thing() . ') => d(' . $d->thing() . ')');
44 1     1   621 }
  1         4  
  1         9  
45             }
46             1;
47             =head1 NAME
48              
49             =head1 VERSION
50              
51             =head1 SYNOPSIS
52              
53             =head1 METHODS
54              
55             =head1 AUTHOR
56              
57             Jamie Beverly, C<< >>
58              
59             =head1 BUGS
60              
61             Please report any bugs or feature requests to C,
62             or through
63             the web interface at
64             L. I will be
65             notified, and then you'll
66             automatically be notified of progress on your bug as I make changes.
67              
68             =head1 SUPPORT
69              
70             You can find documentation for this module with the perldoc command.
71              
72             perldoc OOP::Perlish::Class
73              
74              
75             You can also look for information at:
76              
77             =over 4
78              
79             =item * RT: CPAN's request tracker
80              
81             L
82              
83             =item * AnnoCPAN: Annotated CPAN documentation
84              
85             L
86              
87             =item * CPAN Ratings
88              
89             L
90              
91             =item * Search CPAN
92              
93             L
94              
95             =back
96              
97              
98             =head1 ACKNOWLEDGEMENTS
99              
100             =head1 COPYRIGHT & LICENSE
101              
102             Copyright 2009 Jamie Beverly
103              
104             This program is free software; you can redistribute it and/or modify it
105             under the terms of either: the GNU General Public License as published
106             by the Free Software Foundation; or the Artistic License.
107              
108             See http://dev.perl.org/licenses/ for more information.
109              
110             =cut