| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | { | ||
| 4 | package OOP::Perlish::Class::Singleton::UnitTests::Foo; | ||
| 5 | 1 | ▶ | use OOP::Perlish::Class::Singleton; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use base qw(OOP::Perlish::Class::Singleton); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | |||
| 8 | 1 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | __PACKAGE__->_accessors( | |
| 10 | bar => { type => 'SCALAR', validator => qr/.*bar.*/ }, | ||
| 11 | ); | ||
| 12 | }; | ||
| 13 | |||
| 14 | sub foo(@) | ||
| 15 | 0 | ▶ | { |
|
Subroutine
foo: not called CC=1 SCAR=6.9
| |||
| 16 | 0 | my $self = shift; | |
| 17 | 0 | return $self; | |
| 18 | } | ||
| 19 | } | ||
| 20 | |||
| 21 | { | ||
| 22 | 1 | package OOP::Perlish::Class::Singleton::UnitTests::Singleton; | |
| 23 | 1 | ▶ | use base qw(Test::Class); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 24 | 1 | ▶ | use Test::More; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | |||
| 26 | 1 | ▶ | sub singletons : Test(7) |
|
Subroutine
singletons: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 27 | { | ||
| 28 | 1 | my ($self) = @_; | |
| 29 | |||
| 30 | 1 | my $a = OOP::Perlish::Class::Singleton::UnitTests::Foo->new( bar => 'bar-baz' ); | |
| 31 | 1 | my $b = OOP::Perlish::Class::Singleton::UnitTests::Foo->new( bar => 'bar-fred' ); | |
| 32 | 1 | my $c = OOP::Perlish::Class::Singleton::UnitTests::Foo->new(); | |
| 33 | |||
| 34 | 1 | is($a, $b, 'Singleton instantiation a=>b'); | |
| 35 | 1 | is($b, $c, 'Singleton instantiation b=>c'); | |
| 36 | 1 | is($a->bar(), $b->bar(), 'Matching values a=>b'); | |
| 37 | 1 | is($b->bar(), $c->bar(), 'Matching values b=>c'); | |
| 38 | 1 | is($a->bar(), 'bar-baz', 'Initial constructor instantiation wins a'); | |
| 39 | 1 | is($b->bar(), 'bar-baz', 'Initial constructor instantiation wins b'); | |
| 40 | 1 | is($c->bar(), 'bar-baz', 'Initial constructor instantiation wins c'); | |
| 41 | 1 | ▶ | } |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 42 | } | ||
| 43 | 1 | 1; | |
| 44 | =head1 NAME | ||
| 45 | |||
| 46 | =head1 VERSION | ||
| 47 | |||
| 48 | =head1 SYNOPSIS | ||
| 49 | |||
| 50 | =head1 METHODS | ||
| 51 | |||
| 52 | =head1 AUTHOR | ||
| 53 | |||
| 54 | Jamie Beverly, C<< <jbeverly at cpan.org> >> | ||
| 55 | |||
| 56 | =head1 BUGS | ||
| 57 | |||
| 58 | Please report any bugs or feature requests to C<bug-foo-bar at rt.cpan.org>, | ||
| 59 | or through | ||
| 60 | the web interface at | ||
| 61 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=OOP-Perlish-Class>. I will be | ||
| 62 | notified, and then you'll | ||
| 63 | automatically be notified of progress on your bug as I make changes. | ||
| 64 | |||
| 65 | =head1 SUPPORT | ||
| 66 | |||
| 67 | You can find documentation for this module with the perldoc command. | ||
| 68 | |||
| 69 | perldoc OOP::Perlish::Class | ||
| 70 | |||
| 71 | |||
| 72 | You can also look for information at: | ||
| 73 | |||
| 74 | =over 4 | ||
| 75 | |||
| 76 | =item * RT: CPAN's request tracker | ||
| 77 | |||
| 78 | L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=OOP-Perlish-Class> | ||
| 79 | |||
| 80 | =item * AnnoCPAN: Annotated CPAN documentation | ||
| 81 | |||
| 82 | L<http://annocpan.org/dist/OOP-Perlish-Class> | ||
| 83 | |||
| 84 | =item * CPAN Ratings | ||
| 85 | |||
| 86 | L<http://cpanratings.perl.org/d/OOP-Perlish-Class> | ||
| 87 | |||
| 88 | =item * Search CPAN | ||
| 89 | |||
| 90 | L<http://search.cpan.org/dist/OOP-Perlish-Class/> | ||
| 91 | |||
| 92 | =back | ||
| 93 | |||
| 94 | |||
| 95 | =head1 ACKNOWLEDGEMENTS | ||
| 96 | |||
| 97 | =head1 COPYRIGHT & LICENSE | ||
| 98 | |||
| 99 | Copyright 2009 Jamie Beverly | ||
| 100 | |||
| 101 | This program is free software; you can redistribute it and/or modify it | ||
| 102 | under the terms of either: the GNU General Public License as published | ||
| 103 | by the Free Software Foundation; or the Artistic License. | ||
| 104 | |||
| 105 | See http://dev.perl.org/licenses/ for more information. | ||
| 106 | |||
| 107 | =cut | ||