Class/Multiton/UnitTests/Multiton.pm

filter: Statementstmt 100% 35 / 35 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod 0.0% 0 / 1 totaltotal 97.7% 43 / 44 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Class/Accessor/UnitTests/Glob.pm ↑ Summary Class/Accessor/UnitTests/Base.pm »
1 #!/usr/bin/perl
2 {
3 package OOP::Perlish::Class::Multiton::UnitTests::Test1;
4 1 ▶ use OOP::Perlish::Class::Multiton;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶ use base qw(OOP::Perlish::Class::Multiton);
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶ BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 __PACKAGE__->_accessors(
9 thing => { type => 'SCALAR', validator => qr/.*foo.*/, required => 1 },
10 );
11 }
12  
13 8 ▶ sub _multiton_key { return 'thing' };
Subroutine _multiton_key: called CC=1 SCAR=0.0
14 }
15  
16 {
17 1 package OOP::Perlish::Class::Multiton::UnitTests::Multiton;
18 1 ▶ use base Test::Class;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 ▶ use Test::More;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 1 ▶ sub multitons : Test(10)
Subroutine multitons: called CC=1 SCAR=0.0
Pod undocumented
22 {
23 1 my ($self) = @_;
24  
25 1 my $a = OOP::Perlish::Class::Multiton::UnitTests::Test1->new( thing => 'hello foo' );
26 1 my $b = OOP::Perlish::Class::Multiton::UnitTests::Test1->new( thing => 'goodbye foo' );
27 1 my $c = OOP::Perlish::Class::Multiton::UnitTests::Test1->new( thing => 'hello foo' );
28 1 my $d = OOP::Perlish::Class::Multiton::UnitTests::Test1->new( thing => 'goodbye foo' );
29  
30 1 is($a, $c, 'Multitons of the same key are the same a => c');
31 1 is($b, $d, 'Multitons of the same key are the same b => d');
32  
33 1 is($a->thing(), $c->thing(), 'Multitons of the same key have the same thing a => c');
34 1 is($b->thing(), $d->thing(), 'Multitons of the same key have the same thing b => d');
35  
36 1 ok( $a != $b, 'Multitons of different keys are unique a => b');
37 1 ok( $b != $c, 'Multitons of different keys are unique b => c');
38 1 ok( $c != $d, 'Multitons of different keys are unique c => d');
39  
40  
41 1 ok( $a->thing() ne $b->thing(), 'Multitons of different keys have unique things a(' . $a->thing() . ') => b(' . $b->thing() . ')');
42 1 ok( $b->thing() ne $c->thing(), 'Multitons of different keys have unique things b(' . $b->thing() . ') => c(' . $c->thing() . ')');
43 1 ok( $c->thing() ne $d->thing(), 'Multitons of different keys have unique things c(' . $c->thing() . ') => d(' . $d->thing() . ')');
44 1 ▶ }
Subroutine BEGIN: called CC=1 SCAR=0.0
45 }
46 1 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<< <jbeverly at cpan.org> >>
58  
59 =head1 BUGS
60  
61 Please report any bugs or feature requests to C<bug-foo-bar at rt.cpan.org>,
62 or through
63 the web interface at
64 L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=OOP-Perlish-Class>. 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<http://rt.cpan.org/NoAuth/Bugs.html?Dist=OOP-Perlish-Class>
82  
83 =item * AnnoCPAN: Annotated CPAN documentation
84  
85 L<http://annocpan.org/dist/OOP-Perlish-Class>
86  
87 =item * CPAN Ratings
88  
89 L<http://cpanratings.perl.org/d/OOP-Perlish-Class>
90  
91 =item * Search CPAN
92  
93 L<http://search.cpan.org/dist/OOP-Perlish-Class/>
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
« Class/Accessor/UnitTests/Glob.pm ↑ Summary Class/Accessor/UnitTests/Base.pm »