Skip to content
Browse files

Improved test coverage.

  • Loading branch information...
1 parent 3a22271 commit a4aa16778575baa6bc49ac037ed8a8bbcfb3003b @davorg committed Oct 23, 2004
Showing with 81 additions and 73 deletions.
  1. +77 −64 lib/Tie/Hash/Cannabinol.pm
  2. +4 −9 t/pod.t
View
141 lib/Tie/Hash/Cannabinol.pm
@@ -1,41 +1,37 @@
-#
-# DESCRIPTION
-# Tie::Hash::Cannibinol is a Perl module that allows you to define hashes
-# that forget things..
-#
-# AUTHOR
-# Dave Cross <dave@mag-sol.com>
-#
-# COPYRIGHT
-# Copyright (C) 2001, Magnum Solutions Ltd. All Rights Reserved.
-#
-# This script is free software; you can redistribute it and/or
-# modify it under the same terms as Perl itself.
-#
# $Id$
-#
-# $Log$
-# Revision 1.6 2002/09/23 19:02:28 dave
-# Fixed to work with Perl 5.8.0.
-#
-# Revision 1.5 2002/07/12 18:32:21 dave
-# Corrected Attribute::Handlers dependency.
-#
-# Revision 1.4 2001/12/09 19:12:54 dave
-# Added Attribute::Handlers interface.
-#
-# Revision 1.3 2001/09/05 19:48:15 dave
-# fixed a very serious bug where instead of returning a random value from the hash we were, in fact, almost always returning C<undef>.
-#
-# Revision 1.2 2001/09/03 19:58:08 dave
-# Minor fixes
-#
-# Revision 1.1 2001/09/02 17:06:18 dave
-# Initial revision
-#
+=head1 NAME
+
+Tie::Hash::Cannabinol - Perl extension for creating hashes that forget things
+
+=head1 SYNOPSIS
+
+ use Tie::Hash::Cannabinol;
+
+ my %hash;
+ tie %hash, 'Tie::Hash::Cannabinol';
+
+or
+
+ my %hash : Stoned;
+
+ # % hash can now be treated exactly like a normal hash - but don't trust
+ # anything it tells you.
+
+=head1 DESCRIPTION
+
+Tie::Hash::Cannabinol is a completely useless demonstration of how to use
+Tie::StdHash to pervert the behaviour of Perl hashes. Once a hash has been
+C<tie>d to Tie::Hash::Cannabinol, there is a 25% chance that it will forget
+anything that you tell it immediately and a further 25% chance that it
+won't be able to retrieve any information you ask it for. Any information
+that it does return will be pulled at random from its keys.
+
+Oh, and the return value from C<exists> isn't to be trusted either :)
package Tie::Hash::Cannabinol;
+=cut
+
use strict;
use vars qw($VERSION @ISA);
use Tie::Hash;
@@ -44,7 +40,11 @@ use Attribute::Handlers autotie => { "__CALLER__::Stoned" => __PACKAGE__ };
$VERSION = sprintf "%d.%02d", '$Revision$ ' =~ /(\d+)\.(\d+)/;
@ISA = qw(Tie::StdHash);
-# Preloaded methods go here.
+=head2 STORE
+
+Stores data in the hash 3 times out of 4.
+
+=cut
sub STORE {
my ($self, $key, $val) = @_;
@@ -54,6 +54,12 @@ sub STORE {
$self->{$key} = $val;
}
+=head2 FETCH
+
+Fetchs I<something> from the hash 3 times out of 4.
+
+=cut
+
sub FETCH {
my ($self, $key) = @_;
@@ -62,6 +68,12 @@ sub FETCH {
return $self->{(keys %$self)[rand keys %$self]};
}
+=head2 EXISTS
+
+Gives very dodgy information about the existance of keys in the hash.
+
+=cut
+
sub EXISTS {
return rand > .5;
}
@@ -70,42 +82,43 @@ sub EXISTS {
__END__
-=head1 NAME
-
-Tie::Hash::Cannabinol - Perl extension for creating hashes that forget things
-
-=head1 SYNOPSIS
-
- use Tie::Hash::Cannabinol;
-
- my %hash;
- tie %hash, 'Tie::Hash::Cannabinol';
-
-or
-
- my %hash : Stoned;
-
- # % hash can now be treated exactly like a normal hash - but don't trust
- # anything it tells you.
-
-
-=head1 DESCRIPTION
+=head1 AUTHOR
-Tie::Hash::Cannabinol is a completely useless demonstration of how to use
-Tie::StdHash to pervert the behaviour of Perl hashes. Once a hash has been
-C<tie>d to Tie::Hash::Cannabinol, there is a 25% chance that it will forget
-anything that you tell it immediately and a further 25% chance that it
-won't be able to retrieve any information you ask it for. Any information
-that it does return will be pulled at random from its keys.
+Dave Cross <dave@dave.org.uk>
-Oh, and the return value from C<exists> isn't to be trusted either :)
+=head1 COPYRIGHT
-=head1 AUTHOR
+Copyright (C) 2001, Magnum Solutions Ltd. All Rights Reserved.
-Dave Cross <dave@dave.org.uk>
+This script is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
=head1 SEE ALSO
perl(1), perltie(1), Tie::StdHash(1)
=cut
+
+#
+# $Log$
+# Revision 1.7 2004/10/23 09:36:50 dave
+# Improved test coverage.
+#
+# Revision 1.6 2002/09/23 19:02:28 dave
+# Fixed to work with Perl 5.8.0.
+#
+# Revision 1.5 2002/07/12 18:32:21 dave
+# Corrected Attribute::Handlers dependency.
+#
+# Revision 1.4 2001/12/09 19:12:54 dave
+# Added Attribute::Handlers interface.
+#
+# Revision 1.3 2001/09/05 19:48:15 dave
+# fixed a very serious bug where instead of returning a random value from the hash we were, in fact, almost always returning C<undef>.
+#
+# Revision 1.2 2001/09/03 19:58:08 dave
+# Minor fixes
+#
+# Revision 1.1 2001/09/02 17:06:18 dave
+# Initial revision
+#
View
13 t/pod.t
@@ -1,9 +1,4 @@
-use File::Find;
-my @pod;
-BEGIN {
- find sub { push @pod, $File::Find::name if /\.pm$/ }, 'blib';
-}
-
-use Test::Pod tests => scalar @pod;
-
-pod_file_ok($_) for @pod;
+use Test::More;
+eval "use Test::Pod 1.00";
+plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
+all_pod_files_ok();

0 comments on commit a4aa167

Please sign in to comment.
Something went wrong with that request. Please try again.