From c47bc8a426408cd76eae236aa0f98597d9623fbd Mon Sep 17 00:00:00 2001 From: Ingy dot Net Date: Sun, 11 Sep 2011 01:31:44 +0200 Subject: [PATCH] Released version 0.16 --- Changes | 5 +++++ lib/Mo.pm | 4 ++-- t/Bar.pm | 2 +- t/Boo.pm | 6 ++++++ t/Foo.pm | 2 ++ t/extends.t | 7 ++++++- 6 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 t/Boo.pm diff --git a/Changes b/Changes index 8dd4ed2..52a4491 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,9 @@ --- +version: 0.16 +date: Sun Sep 11 01:31:30 CEST 2011 +changes: +- extends can handle multiple parents +--- version: 0.15 date: Sat Sep 10 23:40:23 CEST 2011 changes: diff --git a/lib/Mo.pm b/lib/Mo.pm index 3c601bd..f328a6b 100644 --- a/lib/Mo.pm +++ b/lib/Mo.pm @@ -1,6 +1,6 @@ -package Mo; require strict; require warnings; $Mo::VERSION = '0.15'; +package Mo; require strict; require warnings; $Mo::VERSION = '0.16'; sub import {strict->import;warnings->import;my $p=caller;@{$p.'::ISA'}=$_[0]; - *{$p.'::extends'} = sub {@{(caller).'::ISA'} = $_[0]; eval "require $_[0]"}; + *{$p.'::extends'} = sub {@{(caller).'::ISA'}=@_;eval "require $_" for @_}; *{$p.'::has'} = sub { my ($n, %a) = @_; my($d,$b)=@a{qw(default builder)}; *{(caller)."::$n"} = $d ? sub { $#_ ? ($_[0]{$n} = $_[1]) : (exists $_[0]{$n}) ? $_[0]{$n} : ($_[0]{$n} = $d->($_[0])) } : diff --git a/t/Bar.pm b/t/Bar.pm index 1a4a241..0720ddf 100644 --- a/t/Bar.pm +++ b/t/Bar.pm @@ -1,4 +1,4 @@ package Bar; use Mo; -extends 'Foo'; +extends 'Foo', 'Boo'; 1; diff --git a/t/Boo.pm b/t/Boo.pm new file mode 100644 index 0000000..b6a716e --- /dev/null +++ b/t/Boo.pm @@ -0,0 +1,6 @@ +package Boo; +use Mo; + +has 'buff'; + +1; diff --git a/t/Foo.pm b/t/Foo.pm index 67df352..728da69 100644 --- a/t/Foo.pm +++ b/t/Foo.pm @@ -1,4 +1,6 @@ package Foo; use Mo; +has 'stuff'; + 1; diff --git a/t/extends.t b/t/extends.t index c5035c0..5889abb 100644 --- a/t/extends.t +++ b/t/extends.t @@ -1,4 +1,4 @@ -use Test::More tests => 1; +use Test::More tests => 4; use lib 't'; use Bar; @@ -6,3 +6,8 @@ use Bar; my $b = Bar->new; ok $b->isa('Foo'), 'Bar is a subclass of Foo'; + +is "@Bar::ISA", "Foo Boo", 'Extends adds multiple classes'; + +ok 'Foo'->can('stuff'), 'Foo is loaded'; +ok 'Bar'->can('buff'), 'Boo is loaded';