From 8911edce03b821f7f385e3c2a32bd0bf9b9751e5 Mon Sep 17 00:00:00 2001 From: Damien Krotkine Date: Thu, 8 Sep 2011 19:47:51 +0200 Subject: [PATCH] make sure make sure t doesn't get clobbered. Add myself to authors. amend documentation doesn't get clobbered. Add myself to authors. amend documentation --- lib/Mo.pm | 2 +- lib/Mo.pod | 11 ++++++++++- t/test.t | 4 +++- t/use_ok.t | 20 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 t/use_ok.t diff --git a/lib/Mo.pm b/lib/Mo.pm index c631a59..7e7e1a5 100644 --- a/lib/Mo.pm +++ b/lib/Mo.pm @@ -12,6 +12,6 @@ sub import { push @{$p.'::ISA'}, $_[0]; } -sub new { $_ = bless { @_[1..$#_] }, $_[0]; $_->can('BUILD') && $_->BUILD; $_ } +sub new { my $s = bless { @_[1..$#_] }, $_[0]; $s->can('BUILD') && $s->BUILD; $s } 1; diff --git a/lib/Mo.pod b/lib/Mo.pod index 9c29a49..f310a74 100644 --- a/lib/Mo.pod +++ b/lib/Mo.pod @@ -10,15 +10,24 @@ Mo - Micro Objects use Mo 'Cow Bell'; extends 'SNL'; - has noise => (is =>'ro'); + has noise; + + sub BUILD { + my $self = shift; + $self->SUPER::BUILD(); + # ... + } =head1 DESCRIPTION Moose led to Mouse led to Moo led to Mo. M, anyone? +This is a minimalistic object oriented sugar. + =head1 AUTHOR Ingy döt Net +Damien 'dams' Krotkine =head1 COPYRIGHT AND LICENSE diff --git a/t/test.t b/t/test.t index c5505f8..d2bb180 100644 --- a/t/test.t +++ b/t/test.t @@ -1,4 +1,4 @@ -use Test::More tests => 8; +use Test::More tests => 9; package Foo; use Mo; @@ -54,6 +54,8 @@ is $bar->this, 'thang', 'Write works'; my $baz = Baz->new; is $baz->foo, 5, 'BUILD works'; +$_ = 5; my $maz = Maz->new; +is $_, 5, '$_ is untouched'; is $maz->foo, 5, 'BUILD works again'; is $maz->bar, 7, 'BUILD works in parent class'; diff --git a/t/use_ok.t b/t/use_ok.t new file mode 100644 index 0000000..4eb0cc3 --- /dev/null +++ b/t/use_ok.t @@ -0,0 +1,20 @@ +use Test::More; +use File::Find; + +my %skip = map {($_, 1)} qw{}; + +my @modules = (); +File::Find::find(sub { + return unless -f $_ and $_ =~ /\.pm$/; + my $module = $File::Find::name; + $module =~ s!lib[\/\\](.*)\.pm$!$1!; + $module =~ s!/+!::!g; + return if $skip{$module}; + push @modules, $module; +}, 'lib'); + +plan tests => scalar(@modules); + +for my $module (sort @modules) { + use_ok $module; +}