Skip to content

Commit

Permalink
Import of MSCHWERN/mixin-0.04 from CPAN.
Browse files Browse the repository at this point in the history
gitpan-cpan-distribution: mixin
gitpan-cpan-version:      0.04
gitpan-cpan-path:         MSCHWERN/mixin-0.04.tar.gz
gitpan-cpan-author:       MSCHWERN
gitpan-cpan-maturity:     released
  • Loading branch information
schwern authored and Gitpan committed Oct 21, 2014
1 parent 1eb66fa commit 5757b8f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,3 +1,6 @@
0.04 Mon Apr 29 18:45:58 EDT 2002
* And I forgot to test it. :(

0.03 Mon Apr 29 18:33:45 EDT 2002
* mixin forgot to require the package being mixed in!

Expand Down
1 change: 1 addition & 0 deletions MANIFEST
Expand Up @@ -3,6 +3,7 @@ MANIFEST
Makefile.PL
lib/mixin.pm
lib/mixin/with.pm
t/lib/Dog/Hamish.pm
t/lib/Test/Builder.pm
t/lib/Test/More.pm
t/lib/Test/Simple.pm
Expand Down
6 changes: 4 additions & 2 deletions lib/mixin.pm
Expand Up @@ -3,7 +3,7 @@ package mixin;
use strict;
no strict 'refs';
use vars qw($VERSION);
$VERSION = '0.03';
$VERSION = '0.04';


=head1 NAME
Expand Down Expand Up @@ -67,7 +67,9 @@ sub import {

foreach my $mixin (@mixins) {
# XXX This is lousy, but it will do for now.
eval { require $caller; } unless defined ${$caller.'::VERSION'};
unless( defined ${$mixin.'::VERSION'} ) {
eval qq{ require $mixin; };
}
_mixup($mixin, $caller);
}
}
Expand Down
9 changes: 9 additions & 0 deletions t/lib/Dog/Hamish.pm
@@ -0,0 +1,9 @@
package Dog::Hamish;

use mixin::with 'Dog';

sub burglers {
return 'burglers are everywhere!';
}

1;
14 changes: 13 additions & 1 deletion t/mixin.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl -w

use lib 't/lib';
use Test::More tests => 4;
use Test::More tests => 7;

require_ok('mixin');
require_ok('mixin::with');
Expand Down Expand Up @@ -31,3 +31,15 @@ package main;
my $small_retriever = Dog::Small::Retriever->new;
is( $small_retriever->speak, "Yip!\n" );
is( $small_retriever->fetch('ball'), "Get your own stinking ball\n" );


package Hamish;
use base 'Dog';
use mixin 'Dog::Hamish';


package main;
my $hamish = Hamish->new;
isa_ok( $hamish, 'Hamish' );
is( $hamish->speak, "Bark!\n" );
is( $hamish->burglers, 'burglers are everywhere!' );

0 comments on commit 5757b8f

Please sign in to comment.