From: Fuji, Goro Date: Fri, 24 Sep 2010 09:01:21 +0000 (+0900) Subject: Cleanup failing tests X-Git-Tag: 0.71~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c47cf41554416ee1828eab17d31342a53aaa0839;p=gitmo%2FMouse.git Cleanup failing tests --- diff --git a/Moose-t-failing/010_basics/002_require_superclasses.t b/Moose-t-failing/010_basics/002_require_superclasses.t new file mode 100644 index 0000000..b08c95d --- /dev/null +++ b/Moose-t-failing/010_basics/002_require_superclasses.t @@ -0,0 +1,73 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use lib 't/lib', 'lib'; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + + +{ + + package Bar; + use Mouse; + + ::lives_ok { extends 'Foo' } 'loaded Foo superclass correctly'; +} + +{ + + package Baz; + use Mouse; + + ::lives_ok { extends 'Bar' } 'loaded (inline) Bar superclass correctly'; +} + +{ + + package Foo::Bar; + use Mouse; + + ::lives_ok { extends 'Foo', 'Bar' } + 'loaded Foo and (inline) Bar superclass correctly'; +} + +{ + + package Bling; + use Mouse; + + ::throws_ok { extends 'No::Class' } + qr{Can't locate No/Class\.pm in \@INC}, + 'correct error when superclass could not be found'; +} + +{ + package Affe; + our $VERSION = 23; +} + +{ + package Tiger; + use Mouse; + + ::lives_ok { extends 'Foo', Affe => { -version => 13 } } + 'extends with version requirement'; +} + +{ + package Birne; + use Mouse; + + ::throws_ok { extends 'Foo', Affe => { -version => 42 } } + qr/Affe version 42 required--this is only version 23/, + 'extends with unsatisfied version requirement'; +} + +done_testing; diff --git a/t/010_basics/failing/012_rebless.t b/Moose-t-failing/010_basics/012_rebless.t similarity index 83% rename from t/010_basics/failing/012_rebless.t rename to Moose-t-failing/010_basics/012_rebless.t index e8c6722..dd946f0 100644 --- a/t/010_basics/failing/012_rebless.t +++ b/Moose-t-failing/010_basics/012_rebless.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 11; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; use Scalar::Util 'blessed'; @@ -62,10 +66,10 @@ lives_ok { $foo->type_constrained(10.5) } "Num type constraint for now.."; # try to rebless, except it will fail due to Child's stricter type constraint throws_ok { Child->meta->rebless_instance($foo) } -qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' failed with value 10\.5/, +qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' with value 10\.5/, '... this failed cause of type check'; throws_ok { Child->meta->rebless_instance($bar) } -qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' failed with value 5\.5/, +qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' with value 5\.5/, '... this failed cause of type check';; $foo->type_constrained(10); @@ -81,5 +85,7 @@ is($foo->lazy_classname, 'Parent', "lazy attribute was already initialized"); is($bar->lazy_classname, 'Child', "lazy attribute just now initialized"); throws_ok { $foo->type_constrained(10.5) } -qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' failed with value 10\.5/, +qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' with value 10\.5/, '... this failed cause of type check'; + +done_testing; diff --git a/Moose-t-failing/020_attributes/005_attribute_does.t b/Moose-t-failing/020_attributes/005_attribute_does.t new file mode 100644 index 0000000..e41a4d1 --- /dev/null +++ b/Moose-t-failing/020_attributes/005_attribute_does.t @@ -0,0 +1,105 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + + +{ + package Foo::Role; + use Mouse::Role; + use Mouse::Util::TypeConstraints; + + # if does() exists on its own, then + # we create a type constraint for + # it, just as we do for isa() + has 'bar' => (is => 'rw', does => 'Bar::Role'); + has 'baz' => ( + is => 'rw', + does => role_type('Bar::Role') + ); + + package Foo::Class; + use Mouse; + + with 'Foo::Role'; + + package Bar::Role; + use Mouse::Role; + + # if isa and does appear together, then see if Class->does(Role) + # if it does work... then the does() check is actually not needed + # since the isa() check will imply the does() check + has 'foo' => (is => 'rw', isa => 'Foo::Class', does => 'Foo::Role'); + + package Bar::Class; + use Mouse; + + with 'Bar::Role'; +} + +my $foo = Foo::Class->new; +isa_ok($foo, 'Foo::Class'); + +my $bar = Bar::Class->new; +isa_ok($bar, 'Bar::Class'); + +lives_ok { + $foo->bar($bar); +} '... bar passed the type constraint okay'; + +dies_ok { + $foo->bar($foo); +} '... foo did not pass the type constraint okay'; + +lives_ok { + $foo->baz($bar); +} '... baz passed the type constraint okay'; + +dies_ok { + $foo->baz($foo); +} '... foo did not pass the type constraint okay'; + +lives_ok { + $bar->foo($foo); +} '... foo passed the type constraint okay'; + + + +# some error conditions + +{ + package Baz::Class; + use Mouse; + + # if isa and does appear together, then see if Class->does(Role) + # if it does not,.. we have a conflict... so we die loudly + ::dies_ok { + has 'foo' => (isa => 'Foo::Class', does => 'Bar::Class'); + } '... cannot have a does() which is not done by the isa()'; +} + +{ + package Bling; + use strict; + use warnings; + + sub bling { 'Bling::bling' } + + package Bling::Bling; + use Mouse; + + # if isa and does appear together, then see if Class->does(Role) + # if it does not,.. we have a conflict... so we die loudly + ::dies_ok { + has 'foo' => (isa => 'Bling', does => 'Bar::Class'); + } '... cannot have a isa() which is cannot does()'; +} + +done_testing; diff --git a/t/020_attributes/failing/010_attribute_delegation.t b/Moose-t-failing/020_attributes/010_attribute_delegation.t similarity index 90% rename from t/020_attributes/failing/010_attribute_delegation.t rename to Moose-t-failing/020_attributes/010_attribute_delegation.t index 9dd746a..b111bc8 100644 --- a/t/020_attributes/failing/010_attribute_delegation.t +++ b/Moose-t-failing/020_attributes/010_attribute_delegation.t @@ -1,13 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 92; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; - # ------------------------------------------------------------------- # HASH handles # ------------------------------------------------------------------- @@ -44,7 +47,7 @@ ok($bar->foo, '... we have something in bar->foo'); isa_ok($bar->foo, 'Foo'); my $meth = Bar->meta->get_method('foo_bar'); -isa_ok($meth, 'Mouse::Meta::Method::Delegation'); +isa_ok($meth, 'Mouse::Meta::Method'); is($meth->associated_attribute->name, 'foo', 'associated_attribute->name for this method is foo'); @@ -244,6 +247,15 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); handles => 'Foo::Bar', ); + package Foo::OtherThing; + use Mouse; + use Mouse::Util::TypeConstraints; + + has 'other_thing' => ( + is => 'rw', + isa => 'Foo::Baz', + handles => Mouse::Util::TypeConstraints::find_type_constraint('Foo::Bar'), + ); } { @@ -260,6 +272,19 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); is($foo->thing->baz, 'Foo::Baz::BAZ', '... got the right value'); } +{ + my $foo = Foo::OtherThing->new(other_thing => Foo::Baz->new); + isa_ok($foo, 'Foo::OtherThing'); + isa_ok($foo->other_thing, 'Foo::Baz'); + + ok($foo->meta->has_method('foo'), '... we have the method we expect'); + ok($foo->meta->has_method('bar'), '... we have the method we expect'); + ok(!$foo->meta->has_method('baz'), '... we dont have the method we expect'); + + is($foo->foo, 'Foo::Baz::FOO', '... got the right value'); + is($foo->bar, 'Foo::Baz::BAR', '... got the right value'); + is($foo->other_thing->baz, 'Foo::Baz::BAZ', '... got the right value'); +} # ------------------------------------------------------------------- # AUTOLOAD & handles # ------------------------------------------------------------------- @@ -434,3 +459,5 @@ is($car->stop, 'Engine::stop', '... got the right value from ->stop'); my $k = Bar->new(foo => "Foo"); lives_ok { $k->foo_baz } "but not for class name"; } + +done_testing; diff --git a/Moose-t-failing/020_attributes/011_more_attr_delegation.t b/Moose-t-failing/020_attributes/011_more_attr_delegation.t new file mode 100644 index 0000000..c588848 --- /dev/null +++ b/Moose-t-failing/020_attributes/011_more_attr_delegation.t @@ -0,0 +1,267 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +=pod + +This tests the more complex +delegation cases and that they +do not fail at compile time. + +=cut + +{ + + package ChildASuper; + use Mouse; + + sub child_a_super_method { "as" } + + package ChildA; + use Mouse; + + extends "ChildASuper"; + + sub child_a_method_1 { "a1" } + sub child_a_method_2 { Scalar::Util::blessed($_[0]) . " a2" } + + package ChildASub; + use Mouse; + + extends "ChildA"; + + sub child_a_method_3 { "a3" } + + package ChildB; + use Mouse; + + sub child_b_method_1 { "b1" } + sub child_b_method_2 { "b2" } + sub child_b_method_3 { "b3" } + + package ChildC; + use Mouse; + + sub child_c_method_1 { "c1" } + sub child_c_method_2 { "c2" } + sub child_c_method_3_la { "c3" } + sub child_c_method_4_la { "c4" } + + package ChildD; + use Mouse; + + sub child_d_method_1 { "d1" } + sub child_d_method_2 { "d2" } + + package ChildE; + # no Mouse + + sub new { bless {}, shift } + sub child_e_method_1 { "e1" } + sub child_e_method_2 { "e2" } + + package ChildF; + # no Mouse + + sub new { bless {}, shift } + sub child_f_method_1 { "f1" } + sub child_f_method_2 { "f2" } + + package ChildG; + use Mouse; + + sub child_g_method_1 { "g1" } + + package ChildH; + use Mouse; + + sub child_h_method_1 { "h1" } + sub parent_method_1 { "child_parent_1" } + + package ChildI; + use Mouse; + + sub child_i_method_1 { "i1" } + sub parent_method_1 { "child_parent_1" } + + package Parent; + use Mouse; + + sub parent_method_1 { "parent_1" } + ::can_ok('Parent', 'parent_method_1'); + + ::dies_ok { + has child_a => ( + is => "ro", + default => sub { ChildA->new }, + handles => qr/.*/, + ); + } "all_methods requires explicit isa"; + + ::lives_ok { + has child_a => ( + isa => "ChildA", + is => "ro", + default => sub { ChildA->new }, + handles => qr/.*/, + ); + } "allow all_methods with explicit isa"; + + ::lives_ok { + has child_b => ( + is => 'ro', + default => sub { ChildB->new }, + handles => [qw/child_b_method_1/], + ); + } "don't need to declare isa if method list is predefined"; + + ::lives_ok { + has child_c => ( + isa => "ChildC", + is => "ro", + default => sub { ChildC->new }, + handles => qr/_la$/, + ); + } "can declare regex collector"; + + ::dies_ok { + has child_d => ( + is => "ro", + default => sub { ChildD->new }, + handles => sub { + my ( $class, $delegate_class ) = @_; + } + ); + } "can't create attr with generative handles parameter and no isa"; + + ::lives_ok { + has child_d => ( + isa => "ChildD", + is => "ro", + default => sub { ChildD->new }, + handles => sub { + my ( $class, $delegate_class ) = @_; + return; + } + ); + } "can't create attr with generative handles parameter and no isa"; + + ::lives_ok { + has child_e => ( + isa => "ChildE", + is => "ro", + default => sub { ChildE->new }, + handles => ["child_e_method_2"], + ); + } "can delegate to non moose class using explicit method list"; + + my $delegate_class; + ::lives_ok { + has child_f => ( + isa => "ChildF", + is => "ro", + default => sub { ChildF->new }, + handles => sub { + $delegate_class = $_[1]->name; + return; + }, + ); + } "subrefs on non moose class give no meta"; + + ::is( $delegate_class, "ChildF", "plain classes are handed down to subs" ); + + ::lives_ok { + has child_g => ( + isa => "ChildG", + default => sub { ChildG->new }, + handles => ["child_g_method_1"], + ); + } "can delegate to object even without explicit reader"; + + ::can_ok('Parent', 'parent_method_1'); + ::dies_ok { + has child_h => ( + isa => "ChildH", + is => "ro", + default => sub { ChildH->new }, + handles => sub { map { $_, $_ } $_[1]->get_all_method_names }, + ); + } "Can't override exisiting class method in delegate"; + ::can_ok('Parent', 'parent_method_1'); + + ::lives_ok { + has child_i => ( + isa => "ChildI", + is => "ro", + default => sub { ChildI->new }, + handles => sub { + map { $_, $_ } grep { !/^parent_method_1|meta$/ } + $_[1]->get_all_method_names; + }, + ); + } "Test handles code ref for skipping predefined methods"; + + + sub parent_method { "p" } +} + +# sanity + +isa_ok( my $p = Parent->new, "Parent" ); +isa_ok( $p->child_a, "ChildA" ); +isa_ok( $p->child_b, "ChildB" ); +isa_ok( $p->child_c, "ChildC" ); +isa_ok( $p->child_d, "ChildD" ); +isa_ok( $p->child_e, "ChildE" ); +isa_ok( $p->child_f, "ChildF" ); +isa_ok( $p->child_i, "ChildI" ); + +ok(!$p->can('child_g'), '... no child_g accessor defined'); +ok(!$p->can('child_h'), '... no child_h accessor defined'); + + +is( $p->parent_method, "p", "parent method" ); +is( $p->child_a->child_a_super_method, "as", "child supermethod" ); +is( $p->child_a->child_a_method_1, "a1", "child method" ); + +can_ok( $p, "child_a_super_method" ); +can_ok( $p, "child_a_method_1" ); +can_ok( $p, "child_a_method_2" ); +ok( !$p->can( "child_a_method_3" ), "but not subclass of delegate class" ); + +is( $p->child_a_method_1, $p->child_a->child_a_method_1, "delegate behaves the same" ); +is( $p->child_a_method_2, "ChildA a2", "delegates are their own invocants" ); + + +can_ok( $p, "child_b_method_1" ); +ok( !$p->can("child_b_method_2"), "but not ChildB's unspecified siblings" ); + + +ok( !$p->can($_), "none of ChildD's methods ($_)" ) + for grep { /^child/ } map { $_->name } ChildD->meta->get_all_methods(); + +can_ok( $p, "child_c_method_3_la" ); +can_ok( $p, "child_c_method_4_la" ); + +is( $p->child_c_method_3_la, "c3", "ChildC method delegated OK" ); + +can_ok( $p, "child_e_method_2" ); +ok( !$p->can("child_e_method_1"), "but not child_e_method_1"); + +is( $p->child_e_method_2, "e2", "delegate to non moose class (child_e_method_2)" ); + +can_ok( $p, "child_g_method_1" ); +is( $p->child_g_method_1, "g1", "delegate to moose class without reader (child_g_method_1)" ); + +can_ok( $p, "child_i_method_1" ); +is( $p->parent_method_1, "parent_1", "delegate doesn't override existing method" ); + +done_testing; diff --git a/t/020_attributes/failing/021_method_generation_rules.t b/Moose-t-failing/020_attributes/021_method_generation_rules.t similarity index 88% rename from t/020_attributes/failing/021_method_generation_rules.t rename to Moose-t-failing/020_attributes/021_method_generation_rules.t index 2169780..b275d1c 100644 --- a/t/020_attributes/failing/021_method_generation_rules.t +++ b/Moose-t-failing/020_attributes/021_method_generation_rules.t @@ -1,13 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 17; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; - =pod is => rw, writer => _foo # turns into (reader => foo, writer => _foo) @@ -61,3 +64,4 @@ is($obj->_foo(), 1, "$class->foo is reader"); dies_ok { make_class('ro', 'accessor', "Test::Class::AccessorRO"); } "Cant define attr with ro + accessor"; +done_testing; diff --git a/t/020_attributes/failing/023_attribute_names.t b/Moose-t-failing/020_attributes/023_attribute_names.t similarity index 81% rename from t/020_attributes/failing/023_attribute_names.t rename to Moose-t-failing/020_attributes/023_attribute_names.t index f98d556..6eb442d 100644 --- a/t/020_attributes/failing/023_attribute_names.t +++ b/Moose-t-failing/020_attributes/023_attribute_names.t @@ -1,8 +1,12 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 8; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; my $exception_regex = qr/You must provide a name for the attribute/; @@ -56,3 +60,4 @@ my $exception_regex = qr/You must provide a name for the attribute/; } 'has 0; works now'; } +done_testing; diff --git a/t/020_attributes/failing/028_no_slot_access.t b/Moose-t-failing/020_attributes/028_no_slot_access.t similarity index 78% rename from t/020_attributes/failing/028_no_slot_access.t rename to Moose-t-failing/020_attributes/028_no_slot_access.t index 12ff7b0..668f71b 100644 --- a/t/020_attributes/failing/028_no_slot_access.t +++ b/Moose-t-failing/020_attributes/028_no_slot_access.t @@ -1,4 +1,7 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; @@ -12,7 +15,7 @@ use warnings; } { - package MouseX::SomeAwesomeDBFields; + package MooseX::SomeAwesomeDBFields; # implementation of methods not called in the example deliberately # omitted @@ -60,12 +63,13 @@ use warnings; use Mouse; use Mouse::Util::MetaRole; - use Test::More tests => 3; + use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => __PACKAGE__, - instance_metaclass_roles => ['MouseX::SomeAwesomeDBFields'] + Mouse::Util::MetaRole::apply_metaroles( + for => __PACKAGE__, + class_metaroles => { instance => ['MooseX::SomeAwesomeDBFields'] }, ); lives_ok { @@ -87,4 +91,6 @@ use warnings; lives_ok { __PACKAGE__->meta->make_immutable; } "Inling constructor does not use inline_slot_access"; + + done_testing; } diff --git a/Moose-t-failing/020_attributes/033_accessor_inlining.t b/Moose-t-failing/020_attributes/033_accessor_inlining.t new file mode 100644 index 0000000..0d664c7 --- /dev/null +++ b/Moose-t-failing/020_attributes/033_accessor_inlining.t @@ -0,0 +1,37 @@ +#!/usr/bin/env perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use strict; +use warnings; +use Test::More; +$TODO = q{Mouse is not yet completed}; + +my $called; +{ + package Foo::Meta::Instance; + use Mouse::Role; + + sub is_inlinable { 0 } + + after get_slot_value => sub { $called++ }; +} + +{ + package Foo; + use Mouse; + Mouse::Util::MetaRole::apply_metaroles( + for => __PACKAGE__, + class_metaroles => { + instance => ['Foo::Meta::Instance'], + }, + ); + + has foo => (is => 'ro'); +} + +my $foo = Foo->new(foo => 1); +is($foo->foo, 1, "got the right value"); +is($called, 1, "reader was called"); + +done_testing; diff --git a/Moose-t-failing/030_roles/001_meta_role.t b/Moose-t-failing/030_roles/001_meta_role.t new file mode 100644 index 0000000..b93903f --- /dev/null +++ b/Moose-t-failing/030_roles/001_meta_role.t @@ -0,0 +1,117 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +use Mouse::Meta::Role; +use Mouse::Util::TypeConstraints (); + +{ + package FooRole; + + our $VERSION = '0.01'; + + sub foo { 'FooRole::foo' } +} + +my $foo_role = Mouse::Meta::Role->initialize('FooRole'); +isa_ok($foo_role, 'Mouse::Meta::Role'); +isa_ok($foo_role, 'Mouse::Meta::Module'); + +is($foo_role->name, 'FooRole', '... got the right name of FooRole'); +is($foo_role->version, '0.01', '... got the right version of FooRole'); + +# methods ... + +ok($foo_role->has_method('foo'), '... FooRole has the foo method'); +is($foo_role->get_method('foo')->body, \&FooRole::foo, '... FooRole got the foo method'); + +isa_ok($foo_role->get_method('foo'), 'Mouse::Meta::Role::Method'); + +is_deeply( + [ $foo_role->get_method_list() ], + [ 'foo' ], + '... got the right method list'); + +# attributes ... + +is_deeply( + [ $foo_role->get_attribute_list() ], + [], + '... got the right attribute list'); + +ok(!$foo_role->has_attribute('bar'), '... FooRole does not have the bar attribute'); + +lives_ok { + $foo_role->add_attribute('bar' => (is => 'rw', isa => 'Foo')); +} '... added the bar attribute okay'; + +is_deeply( + [ $foo_role->get_attribute_list() ], + [ 'bar' ], + '... got the right attribute list'); + +ok($foo_role->has_attribute('bar'), '... FooRole does have the bar attribute'); + +my $bar = $foo_role->get_attribute('bar'); +is_deeply( $bar->original_options, { is => 'rw', isa => 'Foo' }, + 'original options for bar attribute' ); +my $bar_for_class = $bar->attribute_for_class('Mouse::Meta::Attribute'); +is( + $bar_for_class->type_constraint, + Mouse::Util::TypeConstraints::class_type('Foo'), + 'bar has a Foo class type' +); + +lives_ok { + $foo_role->add_attribute('baz' => (is => 'ro')); +} '... added the baz attribute okay'; + +is_deeply( + [ sort $foo_role->get_attribute_list() ], + [ 'bar', 'baz' ], + '... got the right attribute list'); + +ok($foo_role->has_attribute('baz'), '... FooRole does have the baz attribute'); + +my $baz = $foo_role->get_attribute('baz'); +is_deeply( $baz->original_options, { is => 'ro' }, + 'original options for baz attribute' ); + +lives_ok { + $foo_role->remove_attribute('bar'); +} '... removed the bar attribute okay'; + +is_deeply( + [ $foo_role->get_attribute_list() ], + [ 'baz' ], + '... got the right attribute list'); + +ok(!$foo_role->has_attribute('bar'), '... FooRole does not have the bar attribute'); +ok($foo_role->has_attribute('baz'), '... FooRole does still have the baz attribute'); + +# method modifiers + +ok(!$foo_role->has_before_method_modifiers('boo'), '... no boo:before modifier'); + +my $method = sub { "FooRole::boo:before" }; +lives_ok { + $foo_role->add_before_method_modifier('boo' => $method); +} '... added a method modifier okay'; + +ok($foo_role->has_before_method_modifiers('boo'), '... now we have a boo:before modifier'); +is(($foo_role->get_before_method_modifiers('boo'))[0], $method, '... got the right method back'); + +is_deeply( + [ $foo_role->get_method_modifier_list('before') ], + [ 'boo' ], + '... got the right list of before method modifiers'); + +done_testing; diff --git a/Moose-t-failing/030_roles/003_apply_role.t b/Moose-t-failing/030_roles/003_apply_role.t new file mode 100644 index 0000000..2ff8a0d --- /dev/null +++ b/Moose-t-failing/030_roles/003_apply_role.t @@ -0,0 +1,199 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +{ + package FooRole; + use Mouse::Role; + + our $VERSION = 23; + + has 'bar' => ( is => 'rw', isa => 'FooClass' ); + has 'baz' => ( is => 'ro' ); + + sub goo {'FooRole::goo'} + sub foo {'FooRole::foo'} + + override 'boo' => sub { 'FooRole::boo -> ' . super() }; + + around 'blau' => sub { + my $c = shift; + 'FooRole::blau -> ' . $c->(); + }; +} + +{ + package BarRole; + use Mouse::Role; + sub woot {'BarRole::woot'} +} + +{ + package BarClass; + use Mouse; + + sub boo {'BarClass::boo'} + sub foo {'BarClass::foo'} # << the role overrides this ... +} + +{ + package FooClass; + use Mouse; + + extends 'BarClass'; + + ::throws_ok { with 'FooRole' => { -version => 42 } } + qr/FooRole version 42 required--this is only version 23/, + 'applying role with unsatisfied version requirement'; + + ::lives_ok { with 'FooRole' => { -version => 13 } } + 'applying role with satisfied version requirement'; + + sub blau {'FooClass::blau'} # << the role wraps this ... + + sub goo {'FooClass::goo'} # << overrides the one from the role ... +} + +{ + package FooBarClass; + use Mouse; + + extends 'FooClass'; + with 'FooRole', 'BarRole'; +} + +my $foo_class_meta = FooClass->meta; +isa_ok( $foo_class_meta, 'Mouse::Meta::Class' ); + +my $foobar_class_meta = FooBarClass->meta; +isa_ok( $foobar_class_meta, 'Mouse::Meta::Class' ); + +dies_ok { + $foo_class_meta->does_role(); +} +'... does_role requires a role name'; + +dies_ok { + $foo_class_meta->add_role(); +} +'... apply_role requires a role'; + +dies_ok { + $foo_class_meta->add_role( bless( {} => 'Fail' ) ); +} +'... apply_role requires a role'; + +ok( $foo_class_meta->does_role('FooRole'), + '... the FooClass->meta does_role FooRole' ); +ok( !$foo_class_meta->does_role('OtherRole'), + '... the FooClass->meta !does_role OtherRole' ); + +ok( $foobar_class_meta->does_role('FooRole'), + '... the FooBarClass->meta does_role FooRole' ); +ok( $foobar_class_meta->does_role('BarRole'), + '... the FooBarClass->meta does_role BarRole' ); +ok( !$foobar_class_meta->does_role('OtherRole'), + '... the FooBarClass->meta !does_role OtherRole' ); + +foreach my $method_name (qw(bar baz foo boo blau goo)) { + ok( $foo_class_meta->has_method($method_name), + '... FooClass has the method ' . $method_name ); + ok( $foobar_class_meta->has_method($method_name), + '... FooBarClass has the method ' . $method_name ); +} + +ok( !$foo_class_meta->has_method('woot'), + '... FooClass lacks the method woot' ); +ok( $foobar_class_meta->has_method('woot'), + '... FooBarClass has the method woot' ); + +foreach my $attr_name (qw(bar baz)) { + ok( $foo_class_meta->has_attribute($attr_name), + '... FooClass has the attribute ' . $attr_name ); + ok( $foobar_class_meta->has_attribute($attr_name), + '... FooBarClass has the attribute ' . $attr_name ); +} + +can_ok( 'FooClass', 'does' ); +ok( FooClass->does('FooRole'), '... the FooClass does FooRole' ); +ok( !FooClass->does('BarRole'), '... the FooClass does not do BarRole' ); +ok( !FooClass->does('OtherRole'), '... the FooClass does not do OtherRole' ); + +can_ok( 'FooBarClass', 'does' ); +ok( FooBarClass->does('FooRole'), '... the FooClass does FooRole' ); +ok( FooBarClass->does('BarRole'), '... the FooBarClass does FooBarRole' ); +ok( !FooBarClass->does('OtherRole'), + '... the FooBarClass does not do OtherRole' ); + +my $foo = FooClass->new(); +isa_ok( $foo, 'FooClass' ); + +my $foobar = FooBarClass->new(); +isa_ok( $foobar, 'FooBarClass' ); + +is( $foo->goo, 'FooClass::goo', '... got the right value of goo' ); +is( $foobar->goo, 'FooRole::goo', '... got the right value of goo' ); + +is( $foo->boo, 'FooRole::boo -> BarClass::boo', + '... got the right value from ->boo' ); +is( $foobar->boo, 'FooRole::boo -> FooRole::boo -> BarClass::boo', + '... got the right value from ->boo (double wrapped)' ); + +is( $foo->blau, 'FooRole::blau -> FooClass::blau', + '... got the right value from ->blau' ); +is( $foobar->blau, 'FooRole::blau -> FooRole::blau -> FooClass::blau', + '... got the right value from ->blau' ); + +foreach my $foo ( $foo, $foobar ) { + can_ok( $foo, 'does' ); + ok( $foo->does('FooRole'), '... an instance of FooClass does FooRole' ); + ok( !$foo->does('OtherRole'), + '... and instance of FooClass does not do OtherRole' ); + + can_ok( $foobar, 'does' ); + ok( $foobar->does('FooRole'), + '... an instance of FooBarClass does FooRole' ); + ok( $foobar->does('BarRole'), + '... an instance of FooBarClass does BarRole' ); + ok( !$foobar->does('OtherRole'), + '... and instance of FooBarClass does not do OtherRole' ); + + for my $method (qw/bar baz foo boo goo blau/) { + can_ok( $foo, $method ); + } + + is( $foo->foo, 'FooRole::foo', '... got the right value of foo' ); + + ok( !defined( $foo->baz ), '... $foo->baz is undefined' ); + ok( !defined( $foo->bar ), '... $foo->bar is undefined' ); + + dies_ok { + $foo->baz(1); + } + '... baz is a read-only accessor'; + + dies_ok { + $foo->bar(1); + } + '... bar is a read-write accessor with a type constraint'; + + my $foo2 = FooClass->new(); + isa_ok( $foo2, 'FooClass' ); + + lives_ok { + $foo->bar($foo2); + } + '... bar is a read-write accessor with a type constraint'; + + is( $foo->bar, $foo2, '... got the right value for bar now' ); +} + +done_testing; diff --git a/t/030_roles/failing/006_role_exclusion.t b/Moose-t-failing/030_roles/006_role_exclusion.t similarity index 94% rename from t/030_roles/failing/006_role_exclusion.t rename to Moose-t-failing/030_roles/006_role_exclusion.t index e60a768..32eed57 100644 --- a/t/030_roles/failing/006_role_exclusion.t +++ b/Moose-t-failing/030_roles/006_role_exclusion.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 22; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; =pod @@ -121,3 +125,4 @@ ok(My::Test4->meta->does_role('Molecule::Organic'), '... My::Test4 meat does_rol ok(My::Test4->meta->excludes_role('Molecule::Inorganic'), '... My::Test4 meta excludes Molecule::Organic'); ok(!My::Test4->does('Molecule::Inorganic'), '... My::Test4 does Molecule::Inorganic'); +done_testing; diff --git a/t/030_roles/failing/007_roles_and_req_method_edge_cases.t b/Moose-t-failing/030_roles/007_roles_and_req_method_edge_cases.t similarity index 95% rename from t/030_roles/failing/007_roles_and_req_method_edge_cases.t rename to Moose-t-failing/030_roles/007_roles_and_req_method_edge_cases.t index 5e45d89..b9fbeb6 100644 --- a/t/030_roles/failing/007_roles_and_req_method_edge_cases.t +++ b/Moose-t-failing/030_roles/007_roles_and_req_method_edge_cases.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 15; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; =pod @@ -136,7 +140,7 @@ method modifier. sub foo { 'Class::ProvideFoo::foo' } before 'foo' => sub { 'Class::ProvideFoo::foo:before' }; - ::isa_ok(__PACKAGE__->meta->get_method('foo'), 'Class::MOP::Method::Wrapped'); + ::isa_ok(__PACKAGE__->meta->get_method('foo'), 'Mouse::Meta::Method'); ::is(__PACKAGE__->meta->get_method('foo')->get_original_method->package_name, __PACKAGE__, '... but the original method is from our package'); @@ -275,3 +279,5 @@ method modifier. with 'Bar2::Role'; } 'required method exists in superclass as non-modifier, so we live'; } + +done_testing; diff --git a/t/030_roles/failing/011_overriding.t b/Moose-t-failing/030_roles/011_overriding.t similarity index 96% rename from t/030_roles/failing/011_overriding.t rename to Moose-t-failing/030_roles/011_overriding.t index 89e1668..6007e25 100644 --- a/t/030_roles/failing/011_overriding.t +++ b/Moose-t-failing/030_roles/011_overriding.t @@ -1,13 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 39; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; - { # test no conflicts here package Role::A; @@ -227,3 +230,4 @@ ok(Role::I->meta->requires_method('foo'), '... Role::I still have the &foo requi } +done_testing; diff --git a/t/030_roles/failing/012_method_exclusion_in_composition.t b/Moose-t-failing/030_roles/012_method_exclusion_in_composition.t similarity index 92% rename from t/030_roles/failing/012_method_exclusion_in_composition.t rename to Moose-t-failing/030_roles/012_method_exclusion_in_composition.t index d852b17..1bc3b98 100644 --- a/t/030_roles/failing/012_method_exclusion_in_composition.t +++ b/Moose-t-failing/030_roles/012_method_exclusion_in_composition.t @@ -1,13 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 19; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; - { package My::Role; use Mouse::Role; @@ -111,5 +114,4 @@ ok(!My::Foo::Role->meta->requires_method('foo'), '... and the &foo method is not ok(!My::Foo::Role::Other->meta->has_method('foo'), "we dont have a foo method"); ok(My::Foo::Role::Other->meta->requires_method('foo'), '... and the &foo method is required'); - - +done_testing; diff --git a/Moose-t-failing/030_roles/013_method_aliasing_in_composition.t b/Moose-t-failing/030_roles/013_method_aliasing_in_composition.t new file mode 100644 index 0000000..1934d64 --- /dev/null +++ b/Moose-t-failing/030_roles/013_method_aliasing_in_composition.t @@ -0,0 +1,219 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + + +{ + package My::Role; + use Mouse::Role; + + sub foo { 'Foo::foo' } + sub bar { 'Foo::bar' } + sub baz { 'Foo::baz' } + + requires 'role_bar'; + + package My::Class; + use Mouse; + + ::lives_ok { + with 'My::Role' => { -alias => { bar => 'role_bar' } }; + } '... this succeeds'; + + package My::Class::Failure; + use Mouse; + + ::throws_ok { + with 'My::Role' => { -alias => { bar => 'role_bar' } }; + } qr/Cannot create a method alias if a local method of the same name exists/, '... this succeeds'; + + sub role_bar { 'FAIL' } +} + +ok(My::Class->meta->has_method($_), "we have a $_ method") for qw(foo baz bar role_bar); + +{ + package My::OtherRole; + use Mouse::Role; + + ::lives_ok { + with 'My::Role' => { -alias => { bar => 'role_bar' } }; + } '... this succeeds'; + + sub bar { 'My::OtherRole::bar' } + + package My::OtherRole::Failure; + use Mouse::Role; + + ::throws_ok { + with 'My::Role' => { -alias => { bar => 'role_bar' } }; + } qr/Cannot create a method alias if a local method of the same name exists/, '... cannot alias to a name that exists'; + + sub role_bar { 'FAIL' } +} + +ok(My::OtherRole->meta->has_method($_), "we have a $_ method") for qw(foo baz role_bar); +ok(My::OtherRole->meta->requires_method('bar'), '... and the &bar method is required'); +ok(!My::OtherRole->meta->requires_method('role_bar'), '... and the &role_bar method is not required'); + +{ + package My::AliasingRole; + use Mouse::Role; + + ::lives_ok { + with 'My::Role' => { -alias => { bar => 'role_bar' } }; + } '... this succeeds'; +} + +ok(My::AliasingRole->meta->has_method($_), "we have a $_ method") for qw(foo baz role_bar); +ok(!My::AliasingRole->meta->requires_method('bar'), '... and the &bar method is not required'); + +{ + package Foo::Role; + use Mouse::Role; + + sub foo { 'Foo::Role::foo' } + + package Bar::Role; + use Mouse::Role; + + sub foo { 'Bar::Role::foo' } + + package Baz::Role; + use Mouse::Role; + + sub foo { 'Baz::Role::foo' } + + package My::Foo::Class; + use Mouse; + + ::lives_ok { + with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, + 'Bar::Role' => { -alias => { 'foo' => 'bar_foo' }, -excludes => 'foo' }, + 'Baz::Role'; + } '... composed our roles correctly'; + + package My::Foo::Class::Broken; + use Mouse; + + ::throws_ok { + with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, + 'Bar::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, + 'Baz::Role'; + } qr/Due to a method name conflict in roles 'Bar::Role' and 'Foo::Role', the method 'foo_foo' must be implemented or excluded by 'My::Foo::Class::Broken'/, + '... composed our roles correctly'; +} + +{ + my $foo = My::Foo::Class->new; + isa_ok($foo, 'My::Foo::Class'); + can_ok($foo, $_) for qw/foo foo_foo bar_foo/; + is($foo->foo, 'Baz::Role::foo', '... got the right method'); + is($foo->foo_foo, 'Foo::Role::foo', '... got the right method'); + is($foo->bar_foo, 'Bar::Role::foo', '... got the right method'); +} + +{ + package My::Foo::Role; + use Mouse::Role; + + ::lives_ok { + with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, + 'Bar::Role' => { -alias => { 'foo' => 'bar_foo' }, -excludes => 'foo' }, + 'Baz::Role'; + } '... composed our roles correctly'; +} + +ok(My::Foo::Role->meta->has_method($_), "we have a $_ method") for qw/foo foo_foo bar_foo/;; +ok(!My::Foo::Role->meta->requires_method('foo'), '... and the &foo method is not required'); + + +{ + package My::Foo::Role::Other; + use Mouse::Role; + + ::lives_ok { + with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, + 'Bar::Role' => { -alias => { 'foo' => 'foo_foo' }, -excludes => 'foo' }, + 'Baz::Role'; + } '... composed our roles correctly'; +} + +ok(!My::Foo::Role::Other->meta->has_method('foo_foo'), "we dont have a foo_foo method"); +ok(My::Foo::Role::Other->meta->requires_method('foo_foo'), '... and the &foo method is required'); + +{ + package My::Foo::AliasOnly; + use Mouse; + + ::lives_ok { + with 'Foo::Role' => { -alias => { 'foo' => 'foo_foo' } }, + } '... composed our roles correctly'; +} + +ok(My::Foo::AliasOnly->meta->has_method('foo'), 'we have a foo method'); +ok(My::Foo::AliasOnly->meta->has_method('foo_foo'), '.. and the aliased foo_foo method'); + +{ + package Role::Foo; + use Mouse::Role; + + sub x1 {} + sub y1 {} +} + +{ + package Role::Bar; + use Mouse::Role; + + use Test::Exception; + + lives_ok { + with 'Role::Foo' => { + -alias => { x1 => 'foo_x1' }, + -excludes => ['y1'], + }; + } + 'Compose Role::Foo into Role::Bar with alias and exclude'; + + sub x1 {} + sub y1 {} +} + +{ + my $bar = Role::Bar->meta; + ok( $bar->has_method($_), "has $_ method" ) + for qw( x1 y1 foo_x1 ); +} + +{ + package Role::Baz; + use Mouse::Role; + + use Test::Exception; + + lives_ok { + with 'Role::Foo' => { + -alias => { x1 => 'foo_x1' }, + -excludes => ['y1'], + }; + } + 'Compose Role::Foo into Role::Baz with alias and exclude'; +} + +{ + my $baz = Role::Baz->meta; + ok( $baz->has_method($_), "has $_ method" ) + for qw( x1 foo_x1 ); + ok( ! $baz->has_method('y1'), 'Role::Baz has no y1 method' ); +} + +done_testing; diff --git a/Moose-t-failing/030_roles/017_extending_role_attrs.t b/Moose-t-failing/030_roles/017_extending_role_attrs.t new file mode 100644 index 0000000..c672ae9 --- /dev/null +++ b/Moose-t-failing/030_roles/017_extending_role_attrs.t @@ -0,0 +1,191 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + + +=pod + +This basically just makes sure that using +name +on role attributes works right. + +=cut + +{ + package Foo::Role; + use Mouse::Role; + + has 'bar' => ( + is => 'rw', + isa => 'Int', + default => sub { 10 }, + ); + + package Foo; + use Mouse; + + with 'Foo::Role'; + + ::lives_ok { + has '+bar' => (default => sub { 100 }); + } '... extended the attribute successfully'; +} + +my $foo = Foo->new; +isa_ok($foo, 'Foo'); + +is($foo->bar, 100, '... got the extended attribute'); + + +{ + package Bar::Role; + use Mouse::Role; + + has 'foo' => ( + is => 'rw', + isa => 'Str | Int', + ); + + package Bar; + use Mouse; + + with 'Bar::Role'; + + ::lives_ok { + has '+foo' => ( + isa => 'Int', + ) + } "... narrowed the role's type constraint successfully"; +} + +my $bar = Bar->new(foo => 42); +isa_ok($bar, 'Bar'); +is($bar->foo, 42, '... got the extended attribute'); +$bar->foo(100); +is($bar->foo, 100, "... can change the attribute's value to an Int"); + +throws_ok { $bar->foo("baz") } qr/^Attribute \(foo\) does not pass the type constraint because: Validation failed for 'Int' with value baz at /; +is($bar->foo, 100, "... still has the old Int value"); + + +{ + package Baz::Role; + use Mouse::Role; + + has 'baz' => ( + is => 'rw', + isa => 'Value', + ); + + package Baz; + use Mouse; + + with 'Baz::Role'; + + ::lives_ok { + has '+baz' => ( + isa => 'Int | ClassName', + ) + } "... narrowed the role's type constraint successfully"; +} + +my $baz = Baz->new(baz => 99); +isa_ok($baz, 'Baz'); +is($baz->baz, 99, '... got the extended attribute'); +$baz->baz('Foo'); +is($baz->baz, 'Foo', "... can change the attribute's value to a ClassName"); + +throws_ok { $baz->baz("zonk") } qr/^Attribute \(baz\) does not pass the type constraint because: Validation failed for 'ClassName\|Int' with value zonk at /; +is_deeply($baz->baz, 'Foo', "... still has the old ClassName value"); + + +{ + package Quux::Role; + use Mouse::Role; + + has 'quux' => ( + is => 'rw', + isa => 'Str | Int | Ref', + ); + + package Quux; + use Mouse; + use Mouse::Util::TypeConstraints; + + with 'Quux::Role'; + + subtype 'Positive' + => as 'Int' + => where { $_ > 0 }; + + ::lives_ok { + has '+quux' => ( + isa => 'Positive | ArrayRef', + ) + } "... narrowed the role's type constraint successfully"; +} + +my $quux = Quux->new(quux => 99); +isa_ok($quux, 'Quux'); +is($quux->quux, 99, '... got the extended attribute'); +$quux->quux(100); +is($quux->quux, 100, "... can change the attribute's value to an Int"); +$quux->quux(["hi"]); +is_deeply($quux->quux, ["hi"], "... can change the attribute's value to an ArrayRef"); + +throws_ok { $quux->quux("quux") } qr/^Attribute \(quux\) does not pass the type constraint because: Validation failed for 'ArrayRef\|Positive' with value quux at /; +is_deeply($quux->quux, ["hi"], "... still has the old ArrayRef value"); + +throws_ok { $quux->quux({a => 1}) } qr/^Attribute \(quux\) does not pass the type constraint because: Validation failed for 'ArrayRef\|Positive' with value HASH\(\w+\) at /; +is_deeply($quux->quux, ["hi"], "... still has the old ArrayRef value"); + + +{ + package Err::Role; + use Mouse::Role; + + for (1..3) { + has "err$_" => ( + isa => 'Str | Int', + is => 'bare', + ); + } + + package Err; + use Mouse; + + with 'Err::Role'; + + ::lives_ok { + has '+err1' => (isa => 'Defined'); + } "can get less specific in the subclass"; + + ::lives_ok { + has '+err2' => (isa => 'Bool'); + } "or change the type completely"; + + ::lives_ok { + has '+err3' => (isa => 'Str | ArrayRef'); + } "or add new types to the union"; +} + +{ + package Role::With::PlusAttr; + use Mouse::Role; + + with 'Foo::Role'; + + ::throws_ok { + has '+bar' => ( is => 'ro' ); + } qr/has '\+attr' is not supported in roles/, + "Test has '+attr' in roles explodes"; +} + +done_testing; diff --git a/t/030_roles/failing/020_role_composite.t b/Moose-t-failing/030_roles/020_role_composite.t similarity index 84% rename from t/030_roles/failing/020_role_composite.t rename to Moose-t-failing/030_roles/020_role_composite.t index 0f00eb0..78335e8 100644 --- a/t/030_roles/failing/020_role_composite.t +++ b/Moose-t-failing/030_roles/020_role_composite.t @@ -1,12 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 14; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; -#use Mouse::Meta::Role::Application::RoleSummation; +use Mouse::Meta::Role::Application; use Mouse::Meta::Role::Composite; { @@ -49,7 +53,7 @@ use Mouse::Meta::Role::Composite; ); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this composed okay'; ##... now nest 'em @@ -78,3 +82,5 @@ use Mouse::Meta::Role::Composite; ); } } + +done_testing; diff --git a/t/030_roles/failing/021_role_composite_exclusion.t b/Moose-t-failing/030_roles/021_role_composite_exclusion.t similarity index 81% rename from t/030_roles/failing/021_role_composite_exclusion.t rename to Moose-t-failing/030_roles/021_role_composite_exclusion.t index c8b6f6b..e58faf3 100644 --- a/t/030_roles/failing/021_role_composite_exclusion.t +++ b/Moose-t-failing/030_roles/021_role_composite_exclusion.t @@ -1,12 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 12; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; -#use Mouse::Meta::Role::Application::RoleSummation; +use Mouse::Meta::Role::Application; use Mouse::Meta::Role::Composite; { @@ -34,7 +38,7 @@ ok(Role::DoesExcludesFoo->meta->excludes_role('Role::Foo'), '... got the right e # test simple exclusion dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::Foo->meta, @@ -57,7 +61,7 @@ dies_ok { is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this lives as expected'; } @@ -74,7 +78,7 @@ dies_ok { is($c->name, 'Role::Bar|Role::ExcludesFoo', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this lives as expected'; is_deeply([$c->get_excluded_roles_list], ['Role::Foo'], '... has excluded roles'); @@ -83,7 +87,7 @@ dies_ok { # test conflict with an "inherited" exclusion dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::Foo->meta, @@ -96,7 +100,7 @@ dies_ok { # test conflict with an "inherited" exclusion of an "inherited" role dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::DoesFoo->meta, @@ -106,4 +110,4 @@ dies_ok { ); } '... this fails as expected'; - +done_testing; diff --git a/t/030_roles/failing/022_role_composition_req_methods.t b/Moose-t-failing/030_roles/022_role_composition_req_methods.t similarity index 84% rename from t/030_roles/failing/022_role_composition_req_methods.t rename to Moose-t-failing/030_roles/022_role_composition_req_methods.t index 3843153..1ca09ff 100644 --- a/t/030_roles/failing/022_role_composition_req_methods.t +++ b/Moose-t-failing/030_roles/022_role_composition_req_methods.t @@ -1,12 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 16; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; -use Mouse::Meta::Role::Application::RoleSummation; +use Mouse::Meta::Role::Application; use Mouse::Meta::Role::Composite; { @@ -40,7 +44,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -63,7 +67,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::ProvidesFoo', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -87,7 +91,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::Bar', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -112,7 +116,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::ProvidesFoo|Role::ProvidesBar|Role::Bar', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -122,4 +126,4 @@ use Mouse::Meta::Role::Composite; ); } - +done_testing; diff --git a/t/030_roles/failing/023_role_composition_attributes.t b/Moose-t-failing/030_roles/023_role_composition_attributes.t similarity index 80% rename from t/030_roles/failing/023_role_composition_attributes.t rename to Moose-t-failing/030_roles/023_role_composition_attributes.t index 9785463..4c04817 100644 --- a/t/030_roles/failing/023_role_composition_attributes.t +++ b/Moose-t-failing/030_roles/023_role_composition_attributes.t @@ -1,12 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 7; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; -use Mouse::Meta::Role::Application::RoleSummation; +use Mouse::Meta::Role::Application; use Mouse::Meta::Role::Composite; { @@ -44,7 +48,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -56,7 +60,7 @@ use Mouse::Meta::Role::Composite; # test simple conflict dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::Foo->meta, @@ -68,7 +72,7 @@ dies_ok { # test complex conflict dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::Foo->meta, @@ -82,7 +86,7 @@ dies_ok { # test simple conflict dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::Foo->meta, @@ -92,3 +96,4 @@ dies_ok { ); } '... this fails as expected'; +done_testing; diff --git a/t/030_roles/failing/024_role_composition_methods.t b/Moose-t-failing/030_roles/024_role_composition_methods.t similarity index 86% rename from t/030_roles/failing/024_role_composition_methods.t rename to Moose-t-failing/030_roles/024_role_composition_methods.t index 2f60d0d..c214bae 100644 --- a/t/030_roles/failing/024_role_composition_methods.t +++ b/Moose-t-failing/030_roles/024_role_composition_methods.t @@ -1,12 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 19; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; -use Mouse::Meta::Role::Application::RoleSummation; +use Mouse::Meta::Role::Application; use Mouse::Meta::Role::Composite; { @@ -50,7 +54,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -73,7 +77,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::FooConflict', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -104,7 +108,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar|Role::FooConflict|Role::BarConflict', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -133,7 +137,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::AnotherFooConflict', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -149,3 +153,4 @@ use Mouse::Meta::Role::Composite; ); } +done_testing; diff --git a/t/030_roles/failing/025_role_composition_override.t b/Moose-t-failing/030_roles/025_role_composition_override.t similarity index 81% rename from t/030_roles/failing/025_role_composition_override.t rename to Moose-t-failing/030_roles/025_role_composition_override.t index 4396ce5..3b1483a 100644 --- a/t/030_roles/failing/025_role_composition_override.t +++ b/Moose-t-failing/030_roles/025_role_composition_override.t @@ -1,12 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 8; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; -use Mouse::Meta::Role::Application::RoleSummation; +use Mouse::Meta::Role::Application; use Mouse::Meta::Role::Composite; { @@ -49,7 +53,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this lives ok'; is_deeply( @@ -61,7 +65,7 @@ use Mouse::Meta::Role::Composite; # test simple overrides w/ conflicts dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::Foo->meta, @@ -73,7 +77,7 @@ dies_ok { # test simple overrides w/ conflicts dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::Foo->meta, @@ -86,7 +90,7 @@ dies_ok { # test simple overrides w/ conflicts dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::Foo->meta, @@ -100,7 +104,7 @@ dies_ok { # test simple overrides w/ conflicts dies_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply( + Mouse::Meta::Role::Application->new->apply( Mouse::Meta::Role::Composite->new( roles => [ Role::Foo->meta, @@ -110,3 +114,5 @@ dies_ok { ) ); } '... this fails as expected'; + +done_testing; diff --git a/t/030_roles/failing/026_role_composition_method_mods.t b/Moose-t-failing/030_roles/026_role_composition_method_mods.t similarity index 84% rename from t/030_roles/failing/026_role_composition_method_mods.t rename to Moose-t-failing/030_roles/026_role_composition_method_mods.t index 909c1ff..94eee11 100644 --- a/t/030_roles/failing/026_role_composition_method_mods.t +++ b/Moose-t-failing/030_roles/026_role_composition_method_mods.t @@ -1,12 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 7; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; -use Mouse::Meta::Role::Application::RoleSummation; +use Mouse::Meta::Role::Application; use Mouse::Meta::Role::Composite; { @@ -63,7 +67,7 @@ use Mouse::Meta::Role::Composite; is($c->name, 'Role::Foo|Role::Bar', '... got the composite role name'); lives_ok { - Mouse::Meta::Role::Application::RoleSummation->new->apply($c); + Mouse::Meta::Role::Application->new->apply($c); } '... this succeeds as expected'; is_deeply( @@ -84,3 +88,5 @@ use Mouse::Meta::Role::Composite; '... got the right list of methods' ); } + +done_testing; diff --git a/t/030_roles/failing/032_roles_and_method_cloning.t b/Moose-t-failing/030_roles/032_roles_and_method_cloning.t similarity index 84% rename from t/030_roles/failing/032_roles_and_method_cloning.t rename to Moose-t-failing/030_roles/032_roles_and_method_cloning.t index 2b4e615..07194de 100644 --- a/t/030_roles/failing/032_roles_and_method_cloning.t +++ b/Moose-t-failing/030_roles/032_roles_and_method_cloning.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 17; +use Test::More; +$TODO = q{Mouse is not yet completed}; { @@ -73,9 +77,7 @@ use Test::More tests => 17; isnt( ClassA->foo, "ClassB::foo", "ClassA::foo is not confused with ClassB::foo"); -{ - local $TODO = - "multiply-consumed roles' subs take on their most recently used name"; - is( ClassB->foo, 'ClassB::foo', 'ClassB::foo knows its name' ); - is( ClassA->foo, 'ClassA::foo', 'ClassA::foo knows its name' ); -} +is( ClassB->foo, 'Role::Foo::foo', 'ClassB::foo knows its name' ); +is( ClassA->foo, 'Role::Foo::foo', 'ClassA::foo knows its name' ); + +done_testing; diff --git a/Moose-t-failing/030_roles/038_new_meta_role.t b/Moose-t-failing/030_roles/038_new_meta_role.t new file mode 100644 index 0000000..c78d830 --- /dev/null +++ b/Moose-t-failing/030_roles/038_new_meta_role.t @@ -0,0 +1,23 @@ +#!/usr/bin/env perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use strict; +use warnings; +use Test::More; +$TODO = q{Mouse is not yet completed}; + +do { + package My::Meta::Role; + use Mouse; + BEGIN { extends 'Mouse::Meta::Role' }; +}; + +do { + package My::Role; + use Mouse::Role -metaclass => 'My::Meta::Role'; +}; + +is(My::Role->meta->meta->name, 'My::Meta::Role'); + +done_testing; diff --git a/t/030_roles/failing/039_application_toclass.t b/Moose-t-failing/030_roles/039_application_toclass.t similarity index 79% rename from t/030_roles/failing/039_application_toclass.t rename to Moose-t-failing/030_roles/039_application_toclass.t index e6984fc..99889eb 100644 --- a/t/030_roles/failing/039_application_toclass.t +++ b/Moose-t-failing/030_roles/039_application_toclass.t @@ -1,7 +1,11 @@ #!/usr/bin/env perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 24; +use Test::More; +$TODO = q{Mouse is not yet completed}; do { package Role::Foo; @@ -48,10 +52,10 @@ my $excludes = $excludes[0]; my $aliases = $aliases[0]; my $overrides = $overrides[0]; -isa_ok($basic, 'Mouse::Meta::Role::Application::ToClass'); -isa_ok($excludes, 'Mouse::Meta::Role::Application::ToClass'); -isa_ok($aliases, 'Mouse::Meta::Role::Application::ToClass'); -isa_ok($overrides, 'Mouse::Meta::Role::Application::ToClass'); +isa_ok($basic, 'Mouse::Meta::Role::Application'); +isa_ok($excludes, 'Mouse::Meta::Role::Application'); +isa_ok($aliases, 'Mouse::Meta::Role::Application'); +isa_ok($overrides, 'Mouse::Meta::Role::Application'); is($basic->role, Role::Foo->meta); is($excludes->role, Role::Foo->meta); @@ -73,3 +77,4 @@ is_deeply($excludes->get_method_exclusions, ['foo']); is_deeply($aliases->get_method_exclusions, []); is_deeply($overrides->get_method_exclusions, []); +done_testing; diff --git a/t/030_roles/failing/040_role_for_combination.t b/Moose-t-failing/030_roles/040_role_for_combination.t similarity index 81% rename from t/030_roles/failing/040_role_for_combination.t rename to Moose-t-failing/030_roles/040_role_for_combination.t index 3e7642d..757e4f1 100644 --- a/t/030_roles/failing/040_role_for_combination.t +++ b/Moose-t-failing/030_roles/040_role_for_combination.t @@ -1,7 +1,11 @@ #!/usr/bin/env perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 3; +use Test::More; +$TODO = q{Mouse is not yet completed}; my $OPTS; do { @@ -43,3 +47,4 @@ is(My::Class->foo, 'My::Singleton::Role', 'role_for_combination applied'); is(My::Class->bar, 'My::Usual::Role', 'collateral role'); is_deeply($OPTS, { number => 1 }); +done_testing; diff --git a/Moose-t-failing/030_roles/043_conflict_many_methods.t b/Moose-t-failing/030_roles/043_conflict_many_methods.t new file mode 100644 index 0000000..27589d9 --- /dev/null +++ b/Moose-t-failing/030_roles/043_conflict_many_methods.t @@ -0,0 +1,52 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +{ + package Bomb; + use Mouse::Role; + + sub fuse { } + sub explode { } + + package Spouse; + use Mouse::Role; + + sub fuse { } + sub explode { } + + package Caninish; + use Mouse::Role; + + sub bark { } + + package Treeve; + use Mouse::Role; + + sub bark { } +} + +{ + package PracticalJoke; + use Mouse; + + ::throws_ok { + with 'Bomb', 'Spouse'; + } qr/Due to method name conflicts in roles 'Bomb' and 'Spouse', the methods 'explode' and 'fuse' must be implemented or excluded by 'PracticalJoke'/; + + ::throws_ok { + with ( + 'Bomb', 'Spouse', + 'Caninish', 'Treeve', + ); + } qr/Due to a method name conflict in roles 'Caninish' and 'Treeve', the method 'bark' must be implemented or excluded by 'PracticalJoke'/; +} + +done_testing; diff --git a/Moose-t-failing/030_roles/044_role_attrs.t b/Moose-t-failing/030_roles/044_role_attrs.t new file mode 100644 index 0000000..06687fe --- /dev/null +++ b/Moose-t-failing/030_roles/044_role_attrs.t @@ -0,0 +1,58 @@ +use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +use Mouse (); +use Mouse::Meta::Role; +use Mouse::Util; + +my $role1 = Mouse::Meta::Role->initialize('Foo'); +$role1->add_attribute( foo => ( is => 'ro' ) ); + +ok( $role1->has_attribute('foo'), 'Foo role has a foo attribute' ); + +my $foo_attr = $role1->get_attribute('foo'); +is( + $foo_attr->associated_role->name, 'Foo', + 'associated_role for foo attr is Foo role' +); + +isa_ok( + $foo_attr->attribute_for_class('Mouse::Meta::Attribute'), + 'Mouse::Meta::Attribute', + 'attribute returned by ->attribute_for_class' +); + +my $role2 = Mouse::Meta::Role->initialize('Bar'); +$role1->apply($role2); + +ok( $role2->has_attribute('foo'), 'Bar role has a foo attribute' ); + +is( + $foo_attr->associated_role->name, 'Foo', + 'associated_role for foo attr is still Foo role' +); + +isa_ok( + $foo_attr->attribute_for_class('Mouse::Meta::Attribute'), + 'Mouse::Meta::Attribute', + 'attribute returned by ->attribute_for_class' +); + +my $role3 = Mouse::Meta::Role->initialize('Baz'); +my $combined = Mouse::Meta::Role->combine( [ $role1->name ], [ $role3->name ] ); + +ok( $combined->has_attribute('foo'), 'combined role has a foo attribute' ); + +is( + $foo_attr->associated_role->name, 'Foo', + 'associated_role for foo attr is still Foo role' +); + +done_testing; diff --git a/Moose-t-failing/030_roles/046_role_consumers.t b/Moose-t-failing/030_roles/046_role_consumers.t new file mode 100644 index 0000000..9f6509a --- /dev/null +++ b/Moose-t-failing/030_roles/046_role_consumers.t @@ -0,0 +1,58 @@ +use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; + +{ + package Foo::Role; + use Mouse::Role; +} + +{ + package Bar::Role; + use Mouse::Role; +} + +{ + package Foo; + use Mouse; + with 'Foo::Role'; +} + +{ + package Bar; + use Mouse; + extends 'Foo'; + with 'Bar::Role'; +} + +{ + package FooBar; + use Mouse; + with 'Foo::Role', 'Bar::Role'; +} + +{ + package Foo::Role::User; + use Mouse::Role; + with 'Foo::Role'; +} + +{ + package Foo::User; + use Mouse; + with 'Foo::Role::User'; +} + +is_deeply([sort Foo::Role->meta->consumers], + ['Bar', 'Foo', 'Foo::Role::User', 'Foo::User', 'FooBar']); +is_deeply([sort Bar::Role->meta->consumers], + ['Bar', 'FooBar']); +is_deeply([sort Foo::Role::User->meta->consumers], + ['Foo::User']); + +done_testing; diff --git a/Moose-t-failing/030_roles/047_role_attribute_conflict.t b/Moose-t-failing/030_roles/047_role_attribute_conflict.t new file mode 100644 index 0000000..a641ef4 --- /dev/null +++ b/Moose-t-failing/030_roles/047_role_attribute_conflict.t @@ -0,0 +1,33 @@ +use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +{ + package My::Role1; + use Mouse::Role; + + has foo => ( + is => 'ro', + ); + +} + +{ + package My::Role2; + use Mouse::Role; + + has foo => ( + is => 'ro', + ); + + ::throws_ok { with 'My::Role1' } qr/attribute conflict.+My::Role2.+foo/, + 'attribute conflict when composing one role into another'; +} + +done_testing; diff --git a/t/040_type_constraints/failing/001_util_type_constraints.t b/Moose-t-failing/040_type_constraints/001_util_type_constraints.t similarity index 95% rename from t/040_type_constraints/failing/001_util_type_constraints.t rename to Moose-t-failing/040_type_constraints/001_util_type_constraints.t index a928ff5..9c53dab 100644 --- a/t/040_type_constraints/failing/001_util_type_constraints.t +++ b/Moose-t-failing/040_type_constraints/001_util_type_constraints.t @@ -1,15 +1,17 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 85; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; use Scalar::Util (); -use lib 't/lib'; -use Test::Mouse; use Mouse::Util::TypeConstraints; @@ -106,7 +108,7 @@ ok(!$natural->has_message, '... it does not have a message'); ok(!defined($natural->validate(5)), '... validated successfully (no error)'); is($natural->validate(-5), - "Validation failed for 'Natural' failed with value -5", + "Validation failed for 'Natural' with value -5", '... validated unsuccessfully (got error)'); my $string = find_type_constraint('String'); @@ -196,6 +198,11 @@ throws_ok {$r->add_type_constraint(bless {}, 'SomeClass')} qr/not a valid type c # sugar was indistinguishable from calling directly. { + no warnings 'redefine'; + *Mouse::Deprecated::deprecated = sub { return }; +} + +{ my $type = type( 'Number2', sub { Scalar::Util::looks_like_number($_) } ); ok( $type->check(5), '... this is a Num' ); @@ -227,3 +234,4 @@ throws_ok {$r->add_type_constraint(bless {}, 'SomeClass')} qr/not a valid type c ok( ! $subtype->check('Foo'), '... this is not a Natural'); } +done_testing; diff --git a/Moose-t-failing/040_type_constraints/004_util_find_type_constraint.t b/Moose-t-failing/040_type_constraints/004_util_find_type_constraint.t new file mode 100644 index 0000000..7caf228 --- /dev/null +++ b/Moose-t-failing/040_type_constraints/004_util_find_type_constraint.t @@ -0,0 +1,44 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +BEGIN { + use_ok('Mouse::Util::TypeConstraints'); +} + +foreach my $type_name (qw( + Any + Item + Bool + Undef + Defined + Value + Num + Int + Str + Ref + ScalarRef + ArrayRef + HashRef + CodeRef + RegexpRef + Object + Role + )) { + is(find_type_constraint($type_name)->name, + $type_name, + '... got the right name for ' . $type_name); +} + +# TODO: +# add tests for is_subtype_of which confirm the hierarchy + +done_testing; diff --git a/Moose-t-failing/040_type_constraints/005_util_type_coercion.t b/Moose-t-failing/040_type_constraints/005_util_type_coercion.t new file mode 100644 index 0000000..d540102 --- /dev/null +++ b/Moose-t-failing/040_type_constraints/005_util_type_coercion.t @@ -0,0 +1,108 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +BEGIN { + use_ok('Mouse::Util::TypeConstraints'); +} + +{ + package HTTPHeader; + use Mouse; + + has 'array' => (is => 'ro'); + has 'hash' => (is => 'ro'); +} + +subtype Header => + => as Object + => where { $_->isa('HTTPHeader') }; + +coerce Header + => from ArrayRef + => via { HTTPHeader->new(array => $_[0]) } + => from HashRef + => via { HTTPHeader->new(hash => $_[0]) }; + + +Mouse::Util::TypeConstraints->export_type_constraints_as_functions(); + +my $header = HTTPHeader->new(); +isa_ok($header, 'HTTPHeader'); + +ok(Header($header), '... this passed the type test'); +ok(!Header([]), '... this did not pass the type test'); +ok(!Header({}), '... this did not pass the type test'); + +my $anon_type = subtype Object => where { $_->isa('HTTPHeader') }; + +lives_ok { + coerce $anon_type + => from ArrayRef + => via { HTTPHeader->new(array => $_[0]) } + => from HashRef + => via { HTTPHeader->new(hash => $_[0]) }; +} 'coercion of anonymous subtype succeeds'; + +foreach my $coercion ( + find_type_constraint('Header')->coercion, + $anon_type->coercion + ) { + + isa_ok($coercion, 'Mouse::Meta::TypeCoercion'); + + { + my $coerced = $coercion->coerce([ 1, 2, 3 ]); + isa_ok($coerced, 'HTTPHeader'); + + is_deeply( + $coerced->array(), + [ 1, 2, 3 ], + '... got the right array'); + is($coerced->hash(), undef, '... nothing assigned to the hash'); + } + + { + my $coerced = $coercion->coerce({ one => 1, two => 2, three => 3 }); + isa_ok($coerced, 'HTTPHeader'); + + is_deeply( + $coerced->hash(), + { one => 1, two => 2, three => 3 }, + '... got the right hash'); + is($coerced->array(), undef, '... nothing assigned to the array'); + } + + { + my $scalar_ref = \(my $var); + my $coerced = $coercion->coerce($scalar_ref); + is($coerced, $scalar_ref, '... got back what we put in'); + } + + { + my $coerced = $coercion->coerce("Foo"); + is($coerced, "Foo", '... got back what we put in'); + } +} + +subtype 'StrWithTrailingX' + => as 'Str' + => where { /X$/ }; + +coerce 'StrWithTrailingX' + => from 'Str' + => via { $_ . 'X' }; + +my $tc = find_type_constraint('StrWithTrailingX'); +is($tc->coerce("foo"), "fooX", "coerce when needed"); +is($tc->coerce("fooX"), "fooX", "do not coerce when unneeded"); + +done_testing; diff --git a/t/040_type_constraints/failing/008_union_types.t b/Moose-t-failing/040_type_constraints/008_union_types.t similarity index 63% rename from t/040_type_constraints/failing/008_union_types.t rename to Moose-t-failing/040_type_constraints/008_union_types.t index c0c9ce0..e05a5d5 100644 --- a/t/040_type_constraints/failing/008_union_types.t +++ b/Moose-t-failing/040_type_constraints/008_union_types.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 35; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; BEGIN { @@ -21,8 +25,8 @@ ok($Str->check('String'), '... Str can accept an String value'); ok(!$Undef->check('String'), '... Undef cannot accept an Str value'); ok($Undef->check(undef), '... Undef can accept an Undef value'); -my $Str_or_Undef = Mouse::Meta::TypeConstraint::Union->new(type_constraints => [$Str, $Undef]); -isa_ok($Str_or_Undef, 'Mouse::Meta::TypeConstraint::Union'); +my $Str_or_Undef = Mouse::Meta::TypeConstraint->new(type_constraints => [$Str, $Undef]); +isa_ok($Str_or_Undef, 'Mouse::Meta::TypeConstraint'); ok($Str_or_Undef->check(undef), '... (Str | Undef) can accept an Undef value'); ok($Str_or_Undef->check('String'), '... (Str | Undef) can accept a String value'); @@ -30,10 +34,14 @@ ok($Str_or_Undef->check('String'), '... (Str | Undef) can accept a String value' ok($Str_or_Undef->is_a_type_of($Str), "subtype of Str"); ok($Str_or_Undef->is_a_type_of($Undef), "subtype of Undef"); +cmp_ok($Str_or_Undef->find_type_for('String'), 'eq', 'Str', 'find_type_for Str'); +cmp_ok($Str_or_Undef->find_type_for(undef), 'eq', 'Undef', 'find_type_for Undef'); +ok(!defined($Str_or_Undef->find_type_for(sub { })), 'no find_type_for CodeRef'); + ok( !$Str_or_Undef->equals($Str), "not equal to Str" ); ok( $Str_or_Undef->equals($Str_or_Undef), "equal to self" ); -ok( $Str_or_Undef->equals(Mouse::Meta::TypeConstraint::Union->new(type_constraints => [ $Str, $Undef ])), "equal to clone" ); -ok( $Str_or_Undef->equals(Mouse::Meta::TypeConstraint::Union->new(type_constraints => [ $Undef, $Str ])), "equal to reversed clone" ); +ok( $Str_or_Undef->equals(Mouse::Meta::TypeConstraint->new(type_constraints => [ $Str, $Undef ])), "equal to clone" ); +ok( $Str_or_Undef->equals(Mouse::Meta::TypeConstraint->new(type_constraints => [ $Undef, $Str ])), "equal to reversed clone" ); ok( !$Str_or_Undef->is_a_type_of("ThisTypeDoesNotExist"), "not type of non existant type" ); ok( !$Str_or_Undef->is_subtype_of("ThisTypeDoesNotExist"), "not subtype of non existant type" ); @@ -51,8 +59,8 @@ ok(!$ArrayRef->check({}), '... ArrayRef cannot accept an {} value'); ok($HashRef->check({}), '... HashRef can accept an {} value'); ok(!$HashRef->check([]), '... HashRef cannot accept an [] value'); -my $HashOrArray = Mouse::Meta::TypeConstraint::Union->new(type_constraints => [$ArrayRef, $HashRef]); -isa_ok($HashOrArray, 'Mouse::Meta::TypeConstraint::Union'); +my $HashOrArray = Mouse::Meta::TypeConstraint->new(type_constraints => [$ArrayRef, $HashRef]); +isa_ok($HashOrArray, 'Mouse::Meta::TypeConstraint'); ok($HashOrArray->check([]), '... (ArrayRef | HashRef) can accept []'); ok($HashOrArray->check({}), '... (ArrayRef | HashRef) can accept {}'); @@ -67,14 +75,15 @@ ok(!defined($HashOrArray->validate([])), '... (ArrayRef | HashRef) can accept [] ok(!defined($HashOrArray->validate({})), '... (ArrayRef | HashRef) can accept {}'); like($HashOrArray->validate(\(my $var2)), -qr/Validation failed for \'ArrayRef\' failed with value SCALAR\(0x.+?\) and Validation failed for \'HashRef\' failed with value SCALAR\(0x.+?\) in \(ArrayRef\|HashRef\)/, +qr/Validation failed for \'ArrayRef\' with value SCALAR\(0x.+?\) and Validation failed for \'HashRef\' with value SCALAR\(0x.+?\) in \(ArrayRef\|HashRef\)/, '... (ArrayRef | HashRef) cannot accept scalar refs'); like($HashOrArray->validate(sub {}), -qr/Validation failed for \'ArrayRef\' failed with value CODE\(0x.+?\) and Validation failed for \'HashRef\' failed with value CODE\(0x.+?\) in \(ArrayRef\|HashRef\)/, +qr/Validation failed for \'ArrayRef\' with value CODE\(0x.+?\) and Validation failed for \'HashRef\' with value CODE\(0x.+?\) in \(ArrayRef\|HashRef\)/, '... (ArrayRef | HashRef) cannot accept code refs'); is($HashOrArray->validate(50), -'Validation failed for \'ArrayRef\' failed with value 50 and Validation failed for \'HashRef\' failed with value 50 in (ArrayRef|HashRef)', +'Validation failed for \'ArrayRef\' with value 50 and Validation failed for \'HashRef\' with value 50 in (ArrayRef|HashRef)', '... (ArrayRef | HashRef) cannot accept Numbers'); +done_testing; diff --git a/t/040_type_constraints/failing/012_container_type_coercion.t b/Moose-t-failing/040_type_constraints/012_container_type_coercion.t similarity index 74% rename from t/040_type_constraints/failing/012_container_type_coercion.t rename to Moose-t-failing/040_type_constraints/012_container_type_coercion.t index 798a448..b94c1ed 100644 --- a/t/040_type_constraints/failing/012_container_type_coercion.t +++ b/Moose-t-failing/040_type_constraints/012_container_type_coercion.t @@ -1,25 +1,30 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 9; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; BEGIN { use_ok('Mouse::Util::TypeConstraints'); + use_ok('Mouse::Meta::TypeConstraint'); } my $r = Mouse::Util::TypeConstraints->get_type_constraint_registry; # Array of Ints -my $array_of_ints = Mouse::Meta::TypeConstraint::Parameterized->new( +my $array_of_ints = Mouse::Meta::TypeConstraint->new( name => 'ArrayRef[Int]', parent => find_type_constraint('ArrayRef'), type_parameter => find_type_constraint('Int'), ); -isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); +isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint'); isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint'); $r->add_type_constraint($array_of_ints); @@ -28,12 +33,12 @@ is(find_type_constraint('ArrayRef[Int]'), $array_of_ints, '... found the type we # Hash of Ints -my $hash_of_ints = Mouse::Meta::TypeConstraint::Parameterized->new( +my $hash_of_ints = Mouse::Meta::TypeConstraint->new( name => 'HashRef[Int]', parent => find_type_constraint('HashRef'), type_parameter => find_type_constraint('Int'), ); -isa_ok($hash_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); +isa_ok($hash_of_ints, 'Mouse::Meta::TypeConstraint'); isa_ok($hash_of_ints, 'Mouse::Meta::TypeConstraint'); $r->add_type_constraint($hash_of_ints); @@ -64,4 +69,4 @@ isa_ok($foo, 'Foo'); is_deeply([ sort @{$foo->bar} ], [ 1, 2, 3 ], '... our coercion worked!'); - +done_testing; diff --git a/t/040_type_constraints/failing/013_advanced_type_creation.t b/Moose-t-failing/040_type_constraints/013_advanced_type_creation.t similarity index 86% rename from t/040_type_constraints/failing/013_advanced_type_creation.t rename to Moose-t-failing/040_type_constraints/013_advanced_type_creation.t index 7610baa..10c908c 100644 --- a/t/040_type_constraints/failing/013_advanced_type_creation.t +++ b/Moose-t-failing/040_type_constraints/013_advanced_type_creation.t @@ -1,14 +1,18 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 33; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; BEGIN { use_ok('Mouse::Util::TypeConstraints'); - use_ok('Mouse::Meta::TypeConstraint::Parameterized'); + use_ok('Mouse::Meta::TypeConstraint'); } my $r = Mouse::Util::TypeConstraints->get_type_constraint_registry; @@ -18,7 +22,7 @@ my $r = Mouse::Util::TypeConstraints->get_type_constraint_registry; # Array of Ints or Strings my $array_of_ints_or_strings = Mouse::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[Int|Str]'); -isa_ok($array_of_ints_or_strings, 'Mouse::Meta::TypeConstraint::Parameterized'); +isa_ok($array_of_ints_or_strings, 'Mouse::Meta::TypeConstraint'); ok($array_of_ints_or_strings->check([ 1, 'two', 3 ]), '... this passed the type check'); ok($array_of_ints_or_strings->check([ 1, 2, 3 ]), '... this passed the type check'); @@ -31,7 +35,7 @@ $r->add_type_constraint($array_of_ints_or_strings); # Array of Ints or HashRef my $array_of_ints_or_hash_ref = Mouse::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[Int | HashRef]'); -isa_ok($array_of_ints_or_hash_ref, 'Mouse::Meta::TypeConstraint::Parameterized'); +isa_ok($array_of_ints_or_hash_ref, 'Mouse::Meta::TypeConstraint'); ok($array_of_ints_or_hash_ref->check([ 1, {}, 3 ]), '... this passed the type check'); ok($array_of_ints_or_hash_ref->check([ 1, 2, 3 ]), '... this passed the type check'); @@ -47,7 +51,7 @@ $r->add_type_constraint($array_of_ints_or_hash_ref); # we have, so we have to do it by hand - SL my $pure_insanity = Mouse::Util::TypeConstraints::create_type_constraint_union('ArrayRef[Int|Str] | ArrayRef[Int | HashRef]'); -isa_ok($pure_insanity, 'Mouse::Meta::TypeConstraint::Union'); +isa_ok($pure_insanity, 'Mouse::Meta::TypeConstraint'); ok($pure_insanity->check([ 1, {}, 3 ]), '... this passed the type check'); ok($pure_insanity->check([ 1, 'Str', 3 ]), '... this passed the type check'); @@ -60,7 +64,7 @@ ok(!$pure_insanity->check([ [], {}, 1 ]), '... this didnt pass the type check'); # Array of Ints my $array_of_ints = Mouse::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[Int]'); -isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); +isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint'); isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint'); ok($array_of_ints->check([ 1, 2, 3, 4 ]), '... [ 1, 2, 3, 4 ] passed successfully'); @@ -74,7 +78,7 @@ ok(!$array_of_ints->check(sub { () }), '... sub { () } failed successfully'); # Array of Array of Ints my $array_of_array_of_ints = Mouse::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[ArrayRef[Int]]'); -isa_ok($array_of_array_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); +isa_ok($array_of_array_of_ints, 'Mouse::Meta::TypeConstraint'); isa_ok($array_of_array_of_ints, 'Mouse::Meta::TypeConstraint'); ok($array_of_array_of_ints->check( @@ -87,7 +91,7 @@ ok(!$array_of_array_of_ints->check( # Array of Array of Array of Ints my $array_of_array_of_array_of_ints = Mouse::Util::TypeConstraints::create_parameterized_type_constraint('ArrayRef[ArrayRef[ArrayRef[Int]]]'); -isa_ok($array_of_array_of_array_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); +isa_ok($array_of_array_of_array_of_ints, 'Mouse::Meta::TypeConstraint'); isa_ok($array_of_array_of_array_of_ints, 'Mouse::Meta::TypeConstraint'); ok($array_of_array_of_array_of_ints->check( @@ -97,5 +101,4 @@ ok(!$array_of_array_of_array_of_ints->check( [[[ 1, 2, 3 ]], [[ qw/foo bar/ ]]] ), '... [[[ 1, 2, 3 ]], [[ qw/foo bar/ ]]] failed successfully'); - - +done_testing; diff --git a/t/040_type_constraints/failing/014_type_notation_parser.t b/Moose-t-failing/040_type_constraints/014_type_notation_parser.t similarity index 94% rename from t/040_type_constraints/failing/014_type_notation_parser.t rename to Moose-t-failing/040_type_constraints/014_type_notation_parser.t index b2821c1..3a75815 100644 --- a/t/040_type_constraints/failing/014_type_notation_parser.t +++ b/Moose-t-failing/040_type_constraints/014_type_notation_parser.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 41; +use Test::More; +$TODO = q{Mouse is not yet completed}; BEGIN { use_ok("Mouse::Util::TypeConstraints"); @@ -103,3 +107,5 @@ ok(!Mouse::Util::TypeConstraints::_detect_type_constraint_union($_), '... this correctly split the union (' . $_ . ')' ) for keys %split_tests; } + +done_testing; diff --git a/t/040_type_constraints/failing/016_subtyping_parameterized_types.t b/Moose-t-failing/040_type_constraints/016_subtyping_parameterized_types.t similarity index 87% rename from t/040_type_constraints/failing/016_subtyping_parameterized_types.t rename to Moose-t-failing/040_type_constraints/016_subtyping_parameterized_types.t index 2fa5f60..00f9665 100644 --- a/t/040_type_constraints/failing/016_subtyping_parameterized_types.t +++ b/Moose-t-failing/040_type_constraints/016_subtyping_parameterized_types.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 39; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; BEGIN { @@ -21,7 +25,7 @@ lives_ok { is($t->name, 'MySpecialHash', '... name is correct'); my $p = $t->parent; - isa_ok($p, 'Mouse::Meta::TypeConstraint::Parameterized'); + isa_ok($p, 'Mouse::Meta::TypeConstraint'); isa_ok($p, 'Mouse::Meta::TypeConstraint'); is($p->name, 'HashRef[Int]', '... parent name is correct'); @@ -53,7 +57,7 @@ lives_ok { is($t->name, 'MySpecialHashExtended', '... name is correct'); my $p = $t->parent; - isa_ok($p, 'Mouse::Meta::TypeConstraint::Parameterized'); + isa_ok($p, 'Mouse::Meta::TypeConstraint'); isa_ok($p, 'Mouse::Meta::TypeConstraint'); is($p->name, 'HashRef[Int]', '... parent name is correct'); @@ -73,7 +77,7 @@ lives_ok { my $t = find_type_constraint('MyNonSpecialHash'); isa_ok($t, 'Mouse::Meta::TypeConstraint'); - isa_ok($t, 'Mouse::Meta::TypeConstraint::Parameterizable'); + isa_ok($t, 'Mouse::Meta::TypeConstraint'); ok( $t->check({ one => 1, two => "foo", three => [] }), "validated" ); ok( !$t->check({ one => 1 }), "failed" ); @@ -119,3 +123,13 @@ lives_ok { as 'SubOfMyArrayRef[Str]'; }, qr/Str is not a subtype of BiggerInt/, 'Failed to parameterize with a bad type parameter'; } + +{ + my $RefToInt = subtype as 'ScalarRef[Int]'; + + ok $RefToInt->check(\1), '\1 is okay'; + ok !$RefToInt->check(1), '1 is not'; + ok !$RefToInt->check(\"foo"), '\"foo" is not'; +} + +done_testing; diff --git a/t/040_type_constraints/failing/019_coerced_parameterized_types.t b/Moose-t-failing/040_type_constraints/019_coerced_parameterized_types.t similarity index 86% rename from t/040_type_constraints/failing/019_coerced_parameterized_types.t rename to Moose-t-failing/040_type_constraints/019_coerced_parameterized_types.t index 5b57ad3..f3183fd 100644 --- a/t/040_type_constraints/failing/019_coerced_parameterized_types.t +++ b/Moose-t-failing/040_type_constraints/019_coerced_parameterized_types.t @@ -1,14 +1,18 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 11; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; BEGIN { use_ok("Mouse::Util::TypeConstraints"); - use_ok('Mouse::Meta::TypeConstraint::Parameterized'); + use_ok('Mouse::Meta::TypeConstraint'); } BEGIN { @@ -56,3 +60,4 @@ ok($evenlist->check(MyList->new(10, 20, 30, 40)), '... validated it correctly (p ok(!$evenlist->check(MyList->new(10, "two")), '... validated it correctly (fail)'); ok(!$evenlist->check([10, 20]), '... validated it correctly (fail)'); +done_testing; diff --git a/t/040_type_constraints/failing/020_class_type_constraint.t b/Moose-t-failing/040_type_constraints/020_class_type_constraint.t similarity index 56% rename from t/040_type_constraints/failing/020_class_type_constraint.t rename to Moose-t-failing/040_type_constraints/020_class_type_constraint.t index 05a9320..5cb9525 100644 --- a/t/040_type_constraints/failing/020_class_type_constraint.t +++ b/Moose-t-failing/040_type_constraints/020_class_type_constraint.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 20; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; BEGIN { @@ -32,6 +36,9 @@ my $type = find_type_constraint("Foo"); is( $type->class, "Foo", "class attribute" ); +ok( !$type->is_subtype_of('Foo'), "Foo is not subtype of Foo" ); +ok( !$type->is_subtype_of($type), '$foo_type is not subtype of $foo_type' ); + ok( $type->is_subtype_of("Gorch"), "subtype of gorch" ); ok( $type->is_subtype_of("Bar"), "subtype of bar" ); @@ -53,8 +60,14 @@ like( $error, qr/is not a Boop/, 'boop gives correct error message'); ok( $type->equals($type), "equals self" ); -ok( $type->equals(Mouse::Meta::TypeConstraint::Class->new( name => "__ANON__", class => "Foo" )), "equals anon constraint of same value" ); -ok( $type->equals(Mouse::Meta::TypeConstraint::Class->new( name => "Oink", class => "Foo" )), "equals differently named constraint of same value" ); -ok( !$type->equals(Mouse::Meta::TypeConstraint::Class->new( name => "__ANON__", class => "Bar" )), "doesn't equal other anon constraint" ); -ok( $type->is_subtype_of(Mouse::Meta::TypeConstraint::Class->new( name => "__ANON__", class => "Bar" )), "subtype of other anon constraint" ); +ok( $type->equals(Mouse::Meta::TypeConstraint->new( name => "__ANON__", class => "Foo" )), "equals anon constraint of same value" ); +ok( $type->equals(Mouse::Meta::TypeConstraint->new( name => "Oink", class => "Foo" )), "equals differently named constraint of same value" ); +ok( !$type->equals(Mouse::Meta::TypeConstraint->new( name => "__ANON__", class => "Bar" )), "doesn't equal other anon constraint" ); +ok( $type->is_subtype_of(Mouse::Meta::TypeConstraint->new( name => "__ANON__", class => "Bar" )), "subtype of other anon constraint" ); + +{ + my $regexp_type = Mouse::Meta::TypeConstraint->new(name => 'Regexp', class => 'Regexp'); + ok(!$regexp_type->check(qr//), 'a Regexp is not an instance of a class, even tho perl pretends it is'); +} +done_testing; diff --git a/t/040_type_constraints/failing/021_maybe_type_constraint.t b/Moose-t-failing/040_type_constraints/021_maybe_type_constraint.t similarity index 80% rename from t/040_type_constraints/failing/021_maybe_type_constraint.t rename to Moose-t-failing/040_type_constraints/021_maybe_type_constraint.t index 85fcff9..77b05f6 100644 --- a/t/040_type_constraints/failing/021_maybe_type_constraint.t +++ b/Moose-t-failing/040_type_constraints/021_maybe_type_constraint.t @@ -1,23 +1,27 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 36; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; use Mouse::Util::TypeConstraints; my $type = Mouse::Util::TypeConstraints::find_or_parse_type_constraint('Maybe[Int]'); isa_ok($type, 'Mouse::Meta::TypeConstraint'); -isa_ok($type, 'Mouse::Meta::TypeConstraint::Parameterized'); +isa_ok($type, 'Mouse::Meta::TypeConstraint'); ok( $type->equals($type), "equals self" ); ok( !$type->equals($type->parent), "not equal to parent" ); ok( !$type->equals(find_type_constraint("Maybe")), "not equal to Maybe" ); ok( $type->parent->equals(find_type_constraint("Maybe")), "parent is Maybe" ); -ok( $type->equals( Mouse::Meta::TypeConstraint::Parameterized->new( name => "__ANON__", parent => find_type_constraint("Maybe"), type_parameter => find_type_constraint("Int") ) ), "equal to clone" ); -ok( !$type->equals( Mouse::Meta::TypeConstraint::Parameterized->new( name => "__ANON__", parent => find_type_constraint("Maybe"), type_parameter => find_type_constraint("Str") ) ), "not equal to clone with diff param" ); +ok( $type->equals( Mouse::Meta::TypeConstraint->new( name => "__ANON__", parent => find_type_constraint("Maybe"), type_parameter => find_type_constraint("Int") ) ), "equal to clone" ); +ok( !$type->equals( Mouse::Meta::TypeConstraint->new( name => "__ANON__", parent => find_type_constraint("Maybe"), type_parameter => find_type_constraint("Str") ) ), "not equal to clone with diff param" ); ok( !$type->equals( Mouse::Util::TypeConstraints::find_or_parse_type_constraint('Maybe[Str]') ), "not equal to declarative version of diff param" ); ok($type->check(10), '... checked type correctly (pass)'); @@ -76,7 +80,7 @@ dies_ok { { - package Test::MouseX::Types::Maybe; + package Test::MooseX::Types::Maybe; use Mouse; has 'Maybe_Int' => (is=>'rw', isa=>'Maybe[Int]'); @@ -86,7 +90,7 @@ dies_ok { has 'Maybe_HashRefInt' => (is=>'rw', isa=>'Maybe[HashRef[Int]]'); } -ok my $obj = Test::MouseX::Types::Maybe->new +ok my $obj = Test::MooseX::Types::Maybe->new => 'Create good test object'; ## Maybe[Int] @@ -131,3 +135,5 @@ ok !$Maybe_Int->check("a") throws_ok sub { $obj->Maybe_Int("a") }, qr/Attribute \(Maybe_Int\) does not pass the type constraint/ => 'failed assigned ("a")'; + +done_testing; diff --git a/t/040_type_constraints/failing/024_role_type_constraint.t b/Moose-t-failing/040_type_constraints/024_role_type_constraint.t similarity index 64% rename from t/040_type_constraints/failing/024_role_type_constraint.t rename to Moose-t-failing/040_type_constraints/024_role_type_constraint.t index df04adc..1a7144d 100644 --- a/t/040_type_constraints/failing/024_role_type_constraint.t +++ b/Moose-t-failing/040_type_constraints/024_role_type_constraint.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 18; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; BEGIN { @@ -59,8 +63,9 @@ like( $error, qr/is not a Boop/, 'boop gives correct error message'); ok( $type->equals($type), "equals self" ); -ok( $type->equals(Mouse::Meta::TypeConstraint::Role->new( name => "__ANON__", role => "Foo" )), "equals anon constraint of same value" ); -ok( $type->equals(Mouse::Meta::TypeConstraint::Role->new( name => "Oink", role => "Foo" )), "equals differently named constraint of same value" ); -ok( !$type->equals(Mouse::Meta::TypeConstraint::Role->new( name => "__ANON__", role => "Bar" )), "doesn't equal other anon constraint" ); -ok( $type->is_subtype_of(Mouse::Meta::TypeConstraint::Role->new( name => "__ANON__", role => "Bar" )), "subtype of other anon constraint" ); +ok( $type->equals(Mouse::Meta::TypeConstraint->new( name => "__ANON__", role => "Foo" )), "equals anon constraint of same value" ); +ok( $type->equals(Mouse::Meta::TypeConstraint->new( name => "Oink", role => "Foo" )), "equals differently named constraint of same value" ); +ok( !$type->equals(Mouse::Meta::TypeConstraint->new( name => "__ANON__", role => "Bar" )), "doesn't equal other anon constraint" ); +ok( $type->is_subtype_of(Mouse::Meta::TypeConstraint->new( name => "__ANON__", role => "Bar" )), "subtype of other anon constraint" ); +done_testing; diff --git a/t/040_type_constraints/failing/026_normalize_type_name.t b/Moose-t-failing/040_type_constraints/026_normalize_type_name.t similarity index 95% rename from t/040_type_constraints/failing/026_normalize_type_name.t rename to Moose-t-failing/040_type_constraints/026_normalize_type_name.t index e2bc02d..345d159 100644 --- a/t/040_type_constraints/failing/026_normalize_type_name.t +++ b/Moose-t-failing/040_type_constraints/026_normalize_type_name.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 37; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; BEGIN { @@ -149,3 +153,5 @@ is $union1->name, $union2->name, 'names match'; is $union1->name, $union3->name, 'names match'; is $union2->name, $union3->name, 'names match'; + +done_testing; diff --git a/t/040_type_constraints/failing/030_class_subtypes.t b/Moose-t-failing/040_type_constraints/030_class_subtypes.t similarity index 77% rename from t/040_type_constraints/failing/030_class_subtypes.t rename to Moose-t-failing/040_type_constraints/030_class_subtypes.t index 6927c3f..594c16e 100644 --- a/t/040_type_constraints/failing/030_class_subtypes.t +++ b/Moose-t-failing/040_type_constraints/030_class_subtypes.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 26; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; use Mouse::Util::TypeConstraints; @@ -13,7 +17,7 @@ use Mouse::Meta::TypeConstraint; ## Create a subclass with a custom method { - package Test::Mouse::Meta::TypeConstraint::AnySubType; + package Test::Mouse::Meta::TypeConstraint; use Mouse; extends 'Mouse::Meta::TypeConstraint'; @@ -23,11 +27,11 @@ use Mouse::Meta::TypeConstraint; } my $Int = find_type_constraint('Int'); -ok $Int, 'Got a good type contstraint'; +ok $Int, 'Got a good type constraint'; -my $parent = Test::Mouse::Meta::TypeConstraint::AnySubType->new({ - name => "Test::Mouse::Meta::TypeConstraint::AnySubType" , - parent => $Int, +my $parent = Test::Mouse::Meta::TypeConstraint->new({ + name => "Test::Mouse::Meta::TypeConstraint" , + parent => $Int, }); ok $parent, 'Created type constraint'; @@ -80,10 +84,10 @@ ok $isa_foo, 'Created subtype of Foo type'; ok $isa_foo->check( Foo->new ), 'Foo passes check'; ok $isa_foo->check( Bar->new ), 'Bar passes check'; ok ! $isa_foo->check( Baz->new ), 'Baz does not pass check'; -like $foo->get_message( Baz->new ), qr/^Validation failed for 'Foo' failed with value Baz=HASH\(0x\w+\) \(not isa Foo\)/, 'Better validation message'; +like $foo->get_message( Baz->new ), qr/^Validation failed for 'Foo' with value Baz=HASH\(0x\w+\) \(not isa Foo\)/, 'Better validation message'; # Maybe in the future this *should* inherit? -like $isa_foo->get_message( Baz->new ), qr/^Validation failed for 'IsaFoo' failed with value Baz=HASH\(0x\w+\)$/, "Subtypes do not automatically inherit parent type's message"; +like $isa_foo->get_message( Baz->new ), qr/^Validation failed for 'IsaFoo' with value Baz=HASH\(0x\w+\)$/, "Subtypes do not automatically inherit parent type's message"; # Implicit types @@ -100,7 +104,7 @@ like $isa_foo->get_message( Baz->new ), qr/^Validation failed for 'IsaFoo' faile throws_ok { Quux->new(age => 3) -} qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' failed with value 3 \(not isa Positive\)/; +} qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/; lives_ok { Quux->new(age => (bless {}, 'Positive')); @@ -113,7 +117,7 @@ eval " throws_ok { Quux->new(age => 3) -} qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' failed with value 3 \(not isa Positive\)/; +} qr/^Attribute \(age\) does not pass the type constraint because: Validation failed for 'Positive' with value 3 \(not isa Positive\)/; lives_ok { Quux->new(age => Positive->new) @@ -139,3 +143,5 @@ throws_ok { lives_ok { Quux::Ier->new(age => (bless {}, 'Negative')) }; + +done_testing; diff --git a/t/040_type_constraints/failing/033_type_names.t b/Moose-t-failing/040_type_constraints/033_type_names.t similarity index 83% rename from t/040_type_constraints/failing/033_type_names.t rename to Moose-t-failing/040_type_constraints/033_type_names.t index cdfee29..414f2e2 100644 --- a/t/040_type_constraints/failing/033_type_names.t +++ b/Moose-t-failing/040_type_constraints/033_type_names.t @@ -1,7 +1,11 @@ use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use warnings; -use Test::More tests => 6; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; use Mouse::Meta::TypeConstraint; @@ -34,3 +38,5 @@ is( Mouse::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[In-val is( Mouse::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[Va.lid]'), 'ArrayRef[Va.lid]', 'find_or_parse_type_constraint returns name for valid name' ); + +done_testing; diff --git a/t/040_type_constraints/failing/035_duck_type_handles.t b/Moose-t-failing/040_type_constraints/035_duck_type_handles.t similarity index 77% rename from t/040_type_constraints/failing/035_duck_type_handles.t rename to Moose-t-failing/040_type_constraints/035_duck_type_handles.t index 40fe414..6a8f896 100644 --- a/t/040_type_constraints/failing/035_duck_type_handles.t +++ b/Moose-t-failing/040_type_constraints/035_duck_type_handles.t @@ -1,8 +1,12 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 2; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; my @phonograph; @@ -44,3 +48,4 @@ is_deeply([splice @phonograph], ['quack']); $t->walk; is_deeply([splice @phonograph], ['footsteps']); +done_testing; diff --git a/t/040_type_constraints/failing/036_match_type_operator.t b/Moose-t-failing/040_type_constraints/036_match_type_operator.t similarity index 96% rename from t/040_type_constraints/failing/036_match_type_operator.t rename to Moose-t-failing/040_type_constraints/036_match_type_operator.t index 524c42d..7da38e0 100644 --- a/t/040_type_constraints/failing/036_match_type_operator.t +++ b/Moose-t-failing/040_type_constraints/036_match_type_operator.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 25; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; use Mouse::Util::TypeConstraints; @@ -223,6 +227,4 @@ throws_ok { not_enough_matches( [] ) } qr/No cases matched for /, '... not enough matches'; - - - +done_testing; diff --git a/t/050_metaclasses/failing/003_moose_w_metaclass.t b/Moose-t-failing/050_metaclasses/003_moose_w_metaclass.t similarity index 78% rename from t/050_metaclasses/failing/003_moose_w_metaclass.t rename to Moose-t-failing/050_metaclasses/003_moose_w_metaclass.t index 19fd54e..22640b2 100644 --- a/t/050_metaclasses/failing/003_moose_w_metaclass.t +++ b/Moose-t-failing/050_metaclasses/003_moose_w_metaclass.t @@ -1,13 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 4; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; - =pod This test demonstrates that Mouse will respect @@ -42,7 +45,7 @@ isa_ok(Foo->meta, 'Foo::Meta'); use strict; use warnings; - use base 'Class::MOP::Class'; + use base 'Mouse::Meta::Class'; package Bar; use strict; @@ -54,3 +57,5 @@ isa_ok(Foo->meta, 'Foo::Meta'); qr/^Bar already has a metaclass, but it does not inherit Mouse::Meta::Class/, '... got the right error too'); } + +done_testing; diff --git a/t/050_metaclasses/failing/010_extending_and_embedding_back_compat.t b/Moose-t-failing/050_metaclasses/010_extending_and_embedding_back_compat.t similarity index 78% rename from t/050_metaclasses/failing/010_extending_and_embedding_back_compat.t rename to Moose-t-failing/050_metaclasses/010_extending_and_embedding_back_compat.t index d1e05d5..4a49b1a 100644 --- a/t/050_metaclasses/failing/010_extending_and_embedding_back_compat.t +++ b/Moose-t-failing/050_metaclasses/010_extending_and_embedding_back_compat.t @@ -1,13 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 7; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; - BEGIN { package MyFramework::Base; use Mouse; @@ -19,6 +22,7 @@ BEGIN { package MyFramework; use Mouse; + use Mouse::Deprecated -api_version => '0.55'; sub import { my $CALLER = caller(); @@ -53,6 +57,4 @@ isa_ok($obj, 'Mouse::Object'); is($obj->foo, 10, '... got the right value'); - - - +done_testing; diff --git a/t/050_metaclasses/failing/014_goto_moose_import.t b/Moose-t-failing/050_metaclasses/014_goto_moose_import.t similarity index 61% rename from t/050_metaclasses/failing/014_goto_moose_import.t rename to Moose-t-failing/050_metaclasses/014_goto_moose_import.t index 063d4f0..4b5ea9e 100644 --- a/t/050_metaclasses/failing/014_goto_moose_import.t +++ b/Moose-t-failing/050_metaclasses/014_goto_moose_import.t @@ -1,16 +1,20 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 8; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; # Some packages out in the wild cooperate with Mouse by using goto # &Mouse::import. we want to make sure it still works. { - package MouseAlike1; + package MooseAlike1; use strict; use warnings; @@ -29,23 +33,23 @@ use Test::Exception; { package Foo; - MouseAlike1->import(); + MooseAlike1->import(); ::lives_ok( sub { has( 'size', is => 'bare' ) }, - 'has was exported via MouseAlike1' ); + 'has was exported via MooseAlike1' ); - MouseAlike1->unimport(); + MooseAlike1->unimport(); } ok( ! Foo->can('has'), - 'No has sub in Foo after MouseAlike1 is unimported' ); + 'No has sub in Foo after MooseAlike1 is unimported' ); ok( Foo->can('meta'), 'Foo has a meta method' ); isa_ok( Foo->meta(), 'Mouse::Meta::Class' ); { - package MouseAlike2; + package MooseAlike2; use strict; use warnings; @@ -66,17 +70,19 @@ isa_ok( Foo->meta(), 'Mouse::Meta::Class' ); { package Bar; - MouseAlike2->import(); + MooseAlike2->import(); ::lives_ok( sub { has( 'size', is => 'bare' ) }, - 'has was exported via MouseAlike2' ); + 'has was exported via MooseAlike2' ); - MouseAlike2->unimport(); + MooseAlike2->unimport(); } ok( ! Bar->can('has'), - 'No has sub in Bar after MouseAlike2 is unimported' ); + 'No has sub in Bar after MooseAlike2 is unimported' ); ok( Bar->can('meta'), 'Bar has a meta method' ); isa_ok( Bar->meta(), 'Mouse::Meta::Class' ); + +done_testing; diff --git a/t/050_metaclasses/failing/015_metarole.t b/Moose-t-failing/050_metaclasses/015_metarole.t similarity index 73% copy from t/050_metaclasses/failing/015_metarole.t copy to Moose-t-failing/050_metaclasses/015_metarole.t index 95f9e47..36e7fd0 100644 --- a/t/050_metaclasses/failing/015_metarole.t +++ b/Moose-t-failing/050_metaclasses/015_metarole.t @@ -1,11 +1,15 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; use lib 't/lib', 'lib'; -use Test::More 'no_plan'; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; use Mouse::Util::MetaRole; @@ -35,9 +39,9 @@ use Mouse::Util::MetaRole; } { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => My::Class->meta, - metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => My::Class->meta, + class_metaroles => { class => ['Role::Foo'] }, ); ok( My::Class->meta()->meta()->does_role('Role::Foo'), @@ -47,9 +51,9 @@ use Mouse::Util::MetaRole; } { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class', - attribute_metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class', + class_metaroles => { attribute => ['Role::Foo'] }, ); ok( My::Class->meta()->attribute_metaclass()->meta()->does_role('Role::Foo'), @@ -63,9 +67,9 @@ use Mouse::Util::MetaRole; } { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class', - method_metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class', + class_metaroles => { method => ['Role::Foo'] }, ); ok( My::Class->meta()->method_metaclass()->meta()->does_role('Role::Foo'), @@ -81,10 +85,9 @@ use Mouse::Util::MetaRole; } { - last; # skip - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class', - wrapped_method_metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class', + class_metaroles => { wrapped_method => ['Role::Foo'] }, ); ok( My::Class->meta()->wrapped_method_metaclass()->meta()->does_role('Role::Foo'), @@ -102,11 +105,9 @@ use Mouse::Util::MetaRole; } { - last; # skip - - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class', - instance_metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class', + class_metaroles => { instance => ['Role::Foo'] }, ); ok( My::Class->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), @@ -123,9 +124,9 @@ use Mouse::Util::MetaRole; } { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class', - constructor_class_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class', + class_metaroles => { constructor => ['Role::Foo'] }, ); ok( My::Class->meta()->constructor_class()->meta()->does_role('Role::Foo'), @@ -136,8 +137,8 @@ use Mouse::Util::MetaRole; q{... My::Class->meta()'s attribute metaclass still does Role::Foo} ); ok( My::Class->meta()->method_metaclass()->meta()->does_role('Role::Foo'), q{... My::Class->meta()'s method metaclass still does Role::Foo} ); -# ok( My::Class->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), -# q{... My::Class->meta()'s instance metaclass still does Role::Foo} ); + ok( My::Class->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), + q{... My::Class->meta()'s instance metaclass still does Role::Foo} ); # Actually instantiating the constructor class is too freaking hard! ok( My::Class->meta()->constructor_class()->can('foo'), @@ -145,9 +146,9 @@ use Mouse::Util::MetaRole; } { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class', - destructor_class_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class', + class_metaroles => { destructor => ['Role::Foo'] }, ); ok( My::Class->meta()->destructor_class()->meta()->does_role('Role::Foo'), @@ -158,8 +159,8 @@ use Mouse::Util::MetaRole; q{... My::Class->meta()'s attribute metaclass still does Role::Foo} ); ok( My::Class->meta()->method_metaclass()->meta()->does_role('Role::Foo'), q{... My::Class->meta()'s method metaclass still does Role::Foo} ); -# ok( My::Class->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), -# q{... My::Class->meta()'s instance metaclass still does Role::Foo} ); + ok( My::Class->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), + q{... My::Class->meta()'s instance metaclass still does Role::Foo} ); ok( My::Class->meta()->constructor_class()->meta()->does_role('Role::Foo'), q{... My::Class->meta()'s constructor class still does Role::Foo} ); @@ -169,11 +170,9 @@ use Mouse::Util::MetaRole; } { - last; # skip - - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Role', - application_to_class_class_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Role', + role_metaroles => { application_to_class => ['Role::Foo'] }, ); ok( My::Role->meta->application_to_class_class->meta->does_role('Role::Foo'), @@ -184,11 +183,9 @@ use Mouse::Util::MetaRole; } { - last; # skip - - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Role', - application_to_role_class_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Role', + role_metaroles => { application_to_role => ['Role::Foo'] }, ); ok( My::Role->meta->application_to_role_class->meta->does_role('Role::Foo'), @@ -201,11 +198,9 @@ use Mouse::Util::MetaRole; } { - last; # skip - - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Role', - application_to_instance_class_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Role', + role_metaroles => { application_to_instance => ['Role::Foo'] }, ); ok( My::Role->meta->application_to_instance_class->meta->does_role('Role::Foo'), @@ -221,8 +216,8 @@ use Mouse::Util::MetaRole; { Mouse::Util::MetaRole::apply_base_class_roles( - for_class => 'My::Class', - roles => ['Role::Foo'], + for => 'My::Class', + roles => ['Role::Foo'], ); ok( My::Class->meta()->does_role('Role::Foo'), @@ -238,14 +233,16 @@ use Mouse::Util::MetaRole; } { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class2', - metaclass_roles => ['Role::Foo'], - attribute_metaclass_roles => ['Role::Foo'], - method_metaclass_roles => ['Role::Foo'], - instance_metaclass_roles => ['Role::Foo'], - constructor_class_roles => ['Role::Foo'], - destructor_class_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class2', + class_metaroles => { + class => ['Role::Foo'], + attribute => ['Role::Foo'], + method => ['Role::Foo'], + instance => ['Role::Foo'], + constructor => ['Role::Foo'], + destructor => ['Role::Foo'], + }, ); ok( My::Class2->meta()->meta()->does_role('Role::Foo'), @@ -266,10 +263,10 @@ use Mouse::Util::MetaRole; is( My::Class2->meta()->get_method('bar')->foo(), 10, '... call foo() on a method metaclass object' ); -# ok( My::Class2->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), -# q{apply Role::Foo to My::Class2->meta()'s instance metaclass} ); -# is( My::Class2->meta()->get_meta_instance()->foo(), 10, -# '... call foo() on an instance metaclass object' ); + ok( My::Class2->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), + q{apply Role::Foo to My::Class2->meta()'s instance metaclass} ); + is( My::Class2->meta()->get_meta_instance()->foo(), 10, + '... call foo() on an instance metaclass object' ); ok( My::Class2->meta()->constructor_class()->meta()->does_role('Role::Foo'), q{apply Role::Foo to My::Class2->meta()'s constructor class} ); @@ -305,9 +302,9 @@ use Mouse::Util::MetaRole; { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class3', - metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class3', + class_metaroles => { class => ['Role::Foo'] }, ); ok( My::Class3->meta()->meta()->does_role('Role::Foo'), @@ -315,7 +312,7 @@ use Mouse::Util::MetaRole; is( My::Class3->meta()->foo(), 10, '... and call foo() on that meta object' ); ok( ( grep { $_ eq 'My::Meta::Class' } My::Class3->meta()->meta()->superclasses() ), - 'apply_metaclass_roles() does not interfere with metaclass set via Mouse->init_meta()' ); + 'apply_metaroles() does not interfere with metaclass set via Mouse->init_meta()' ); } { @@ -330,17 +327,17 @@ use Mouse::Util::MetaRole; } { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class4', - metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class4', + class_metaroles => { class => ['Role::Foo'] }, ); ok( My::Class4->meta()->meta()->does_role('Role::Foo'), 'apply Role::Foo to My::Class4->meta()' ); - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class4', - metaclass_roles => ['Role::Bar'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class4', + class_metaroles => { class => ['Role::Bar'] }, ); ok( My::Class4->meta()->meta()->does_role('Role::Bar'), @@ -352,7 +349,7 @@ use Mouse::Util::MetaRole; { package My::Class5; use Mouse; - + extends 'My::Class'; } @@ -370,11 +367,11 @@ use Mouse::Util::MetaRole; ok( My::Class5->meta()->destructor_class()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s destructor class also does Role::Foo} ); } -exit; + { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class5', - metaclass_roles => ['Role::Bar'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class5', + class_metaroles => { class => ['Role::Bar'] }, ); ok( My::Class5->meta()->meta()->does_role('Role::Bar'), @@ -387,9 +384,9 @@ exit; package My::Class6; use Mouse; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class6', - metaclass_roles => ['Role::Bar'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class6', + class_metaroles => { class => ['Role::Bar'] }, ); extends 'My::Class'; @@ -412,12 +409,12 @@ exit; use Mouse; # In real usage this would go in a BEGIN block so it happened - # before apply_metaclass_roles was called by an extension. + # before apply_metaroles was called by an extension. extends 'My::Class'; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class7', - metaclass_roles => ['Role::Bar'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class7', + class_metaroles => { class => ['Role::Bar'] }, ); } @@ -432,10 +429,12 @@ exit; package My::Class8; use Mouse; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class8', - metaclass_roles => ['Role::Bar'], - attribute_metaclass_roles => ['Role::Bar'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class8', + class_metaroles => { + class => ['Role::Bar'], + attribute => ['Role::Bar'], + }, ); extends 'My::Class'; @@ -457,9 +456,9 @@ exit; package My::Class9; use Mouse; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class9', - attribute_metaclass_roles => ['Role::Bar'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class9', + class_metaroles => { attribute => ['Role::Bar'] }, ); extends 'My::Class'; @@ -477,7 +476,7 @@ exit; # This tests applying meta roles to a metaclass's metaclass. This is # completely insane, but is exactly what happens with # Fey::Meta::Class::Table. It's a subclass of Mouse::Meta::Class -# itself, and then it _uses_ MouseX::ClassAttribute, so the metaclass +# itself, and then it _uses_ MooseX::ClassAttribute, so the metaclass # for Fey::Meta::Class::Table does a role. # # At one point this caused a metaclass incompatibility error down @@ -488,9 +487,9 @@ exit; use Mouse; extends 'Mouse::Meta::Class'; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Meta::Class2', - metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Meta::Class2', + class_metaroles => { class => ['Role::Foo'] }, ); } @@ -522,9 +521,9 @@ exit; package My::Class10; My::Meta2->import; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class10', - metaclass_roles => ['Role::Bar'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class10', + class_metaroles => { class => ['Role::Bar'] }, ); } @@ -542,7 +541,7 @@ exit; { package My::Constructor; - use base 'Mouse::Meta::Method::Constructor'; + use base 'Mouse::Meta::Method'; } { @@ -552,9 +551,9 @@ exit; __PACKAGE__->meta->constructor_class('My::Constructor'); - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class11', - metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class11', + class_metaroles => { class => ['Role::Foo'] }, ); } @@ -566,28 +565,28 @@ exit; } { - package ExportsMouse; + package ExportsMoose; Mouse::Exporter->setup_import_methods( - also => 'Mouse', + also => 'Mouse', ); sub init_meta { shift; my %p = @_; Mouse->init_meta(%p); - return Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => $p{for_class}, + return Mouse::Util::MetaRole::apply_metaroles( + for => $p{for_class}, # Causes us to recurse through init_meta, as we have to # load MyMetaclassRole from disk. - metaclass_roles => [qw/MyMetaclassRole/], + class_metaroles => { class => [qw/MyMetaclassRole/] }, ); } } lives_ok { - package UsesExportedMouse; - ExportsMouse->import; + package UsesExportedMoose; + ExportsMoose->import; } 'import module which loads a role from disk during init_meta'; { @@ -595,23 +594,27 @@ lives_ok { use Mouse::Role; } + { package Foo::Role; Mouse::Exporter->setup_import_methods( - also => 'Mouse::Role', + also => 'Mouse::Role', ); sub init_meta { shift; my %p = @_; + Mouse::Role->init_meta(%p); - return Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => $p{for_class}, - method_metaclass_roles => [ 'Foo::Meta::Role', ], + + return Mouse::Util::MetaRole::apply_metaroles( + for => $p{for_class}, + role_metaroles => { method => ['Foo::Meta::Role'] }, ); } } + { package Role::Baz; @@ -619,6 +622,7 @@ lives_ok { sub bla {} } + { package My::Class12; @@ -626,11 +630,13 @@ lives_ok { with( 'Role::Baz' ); } + { ok( My::Class12->meta->does_role( 'Role::Baz' ), 'role applied' ); + my $method = My::Class12->meta->get_method( 'bla' ); ok( $method->meta->does_role( 'Foo::Meta::Role' ), @@ -642,9 +648,9 @@ lives_ok { package Parent; use Mouse; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => __PACKAGE__, - constructor_class_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => __PACKAGE__, + class_metaroles => { constructor => ['Role::Foo'] }, ); } @@ -662,15 +668,12 @@ lives_ok { 'Parent constructor class has metarole from Parent' ); -TODO: - { - local $TODO - = 'Mouse does not see that the child differs from the parent because it only checks the class and instance metaclasses do determine compatibility'; - ok( - Child->meta->constructor_class->meta->can('does_role') - && Child->meta->constructor_class->meta->does_role( - 'Role::Foo'), - 'Child constructor class has metarole from Parent' - ); - } + ok( + Child->meta->constructor_class->meta->can('does_role') + && Child->meta->constructor_class->meta->does_role( + 'Role::Foo'), + 'Child constructor class has metarole from Parent' + ); } + +done_testing; diff --git a/t/050_metaclasses/failing/016_metarole_w_metaclass_pm.t b/Moose-t-failing/050_metaclasses/016_metarole_w_metaclass_pm.t similarity index 78% rename from t/050_metaclasses/failing/016_metarole_w_metaclass_pm.t rename to Moose-t-failing/050_metaclasses/016_metarole_w_metaclass_pm.t index e899624..00cf161 100644 --- a/t/050_metaclasses/failing/016_metarole_w_metaclass_pm.t +++ b/Moose-t-failing/050_metaclasses/016_metarole_w_metaclass_pm.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 8; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Mouse::Util::MetaRole; @@ -62,23 +66,25 @@ BEGIN } { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class', - metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class', + class_metaroles => { class => ['Role::Foo'] }, ); ok( My::Class->meta()->meta()->does_role('Role::Foo'), 'apply Role::Foo to My::Class->meta()' ); has_superclass( My::Class->meta(), 'My::Meta::Class', - 'apply_metaclass_roles works with metaclass.pm' ); + 'apply_metaroles works with metaclass.pm' ); } { - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => 'My::Class2', - attribute_metaclass_roles => ['Role::Foo'], - method_metaclass_roles => ['Role::Foo'], - instance_metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => 'My::Class2', + class_metaroles => { + attribute => ['Role::Foo'], + method => ['Role::Foo'], + instance => ['Role::Foo'], + }, ); ok( My::Class2->meta()->attribute_metaclass()->meta()->does_role('Role::Foo'), @@ -107,3 +113,5 @@ sub has_superclass { ok( $supers{$parent}, $desc ); } + +done_testing; diff --git a/t/050_metaclasses/failing/018_throw_error.t b/Moose-t-failing/050_metaclasses/018_throw_error.t similarity index 70% rename from t/050_metaclasses/failing/018_throw_error.t rename to Moose-t-failing/050_metaclasses/018_throw_error.t index 1be8cb5..837c6dd 100644 --- a/t/050_metaclasses/failing/018_throw_error.t +++ b/Moose-t-failing/050_metaclasses/018_throw_error.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 24; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; { @@ -22,17 +26,20 @@ use Test::Exception; has foo => ( is => "ro" ); - package Baz::Error; - use Mouse; - - has message => ( isa => "Str", is => "ro" ); - has attr => ( isa => "Mouse::Meta::Attribute", is => "ro" ); - has method => ( isa => "Mouse::Meta::Method", is => "ro" ); - has metaclass => ( isa => "Mouse::Meta::Class", is => "ro" ); - has data => ( is => "ro" ); - has line => ( isa => "Int", is => "ro" ); - has file => ( isa => "Str", is => "ro" ); - has last_error => ( isa => "Any", is => "ro" ); + BEGIN { + package Baz::Error; + use Mouse; + extends 'Mouse::Object', 'Mouse::Error::Default'; + + has message => ( isa => "Str", is => "ro" ); + has attr => ( isa => "Mouse::Meta::Attribute", is => "ro" ); + has method => ( isa => "Mouse::Meta::Method", is => "ro" ); + has metaclass => ( isa => "Mouse::Meta::Class", is => "ro" ); + has data => ( is => "ro" ); + has line => ( isa => "Int", is => "ro" ); + has file => ( isa => "Str", is => "ro" ); + has last_error => ( isa => "Any", is => "ro" ); + } package Baz; use metaclass ( @@ -102,9 +109,9 @@ sub create_error { use Mouse; extends 'Baz'; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => __PACKAGE__, - metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => __PACKAGE__, + class_metaroles => { class => ['Role::Foo'] }, ); } @@ -129,9 +136,9 @@ sub create_error { use Mouse; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => __PACKAGE__, - metaclass_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => __PACKAGE__, + class_metaroles => { class => ['Role::Foo'] }, ); } @@ -144,9 +151,9 @@ ok( Foo::Sub->meta->error_class->isa('Mouse::Error::Croak'), ::lives_ok { extends 'Foo::Sub' } 'error_class differs by role so incompat is handled'; - Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => __PACKAGE__, - error_class_roles => ['Role::Foo'], + Mouse::Util::MetaRole::apply_metaroles( + for => __PACKAGE__, + class_metaroles => { error => ['Role::Foo'] }, ); } @@ -154,3 +161,5 @@ ok( Foo::Sub::Sub->meta->error_class->meta->does_role('Role::Foo'), q{Foo::Sub::Sub's error_class does Role::Foo} ); ok( Foo::Sub::Sub->meta->error_class->isa('Mouse::Error::Croak'), q{Foo::Sub::Sub's error_class now subclasses Mouse::Error::Croak} ); + +done_testing; diff --git a/t/050_metaclasses/failing/019_create_anon_with_required_attr.t b/Moose-t-failing/050_metaclasses/019_create_anon_with_required_attr.t similarity index 90% rename from t/050_metaclasses/failing/019_create_anon_with_required_attr.t rename to Moose-t-failing/050_metaclasses/019_create_anon_with_required_attr.t index 3f4d227..aecf1d4 100644 --- a/t/050_metaclasses/failing/019_create_anon_with_required_attr.t +++ b/Moose-t-failing/050_metaclasses/019_create_anon_with_required_attr.t @@ -1,4 +1,7 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; # this functionality may be pushing toward parametric roles/classes # it's off in a corner and may not be that important @@ -6,7 +9,8 @@ use strict; use warnings; -use Test::More tests => 15; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; { @@ -85,3 +89,4 @@ dies_ok { die $@ if $@; } 'failed to use trait without required attr'; +done_testing; diff --git a/t/050_metaclasses/failing/022_new_metaclass.t b/Moose-t-failing/050_metaclasses/022_new_metaclass.t similarity index 71% rename from t/050_metaclasses/failing/022_new_metaclass.t rename to Moose-t-failing/050_metaclasses/022_new_metaclass.t index 059d9d5..d4b6597 100644 --- a/t/050_metaclasses/failing/022_new_metaclass.t +++ b/Moose-t-failing/050_metaclasses/022_new_metaclass.t @@ -1,7 +1,11 @@ #!/usr/bin/env perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 2; +use Test::More; +$TODO = q{Mouse is not yet completed}; do { package My::Meta::Class; @@ -25,3 +29,4 @@ do { is(My::Class->meta->meta->name, 'My::Meta::Class'); is(My::Class::Aliased->meta->meta->name, 'My::Meta::Class'); +done_testing; diff --git a/t/050_metaclasses/failing/023_easy_init_meta.t b/Moose-t-failing/050_metaclasses/023_easy_init_meta.t similarity index 57% rename from t/050_metaclasses/failing/023_easy_init_meta.t rename to Moose-t-failing/050_metaclasses/023_easy_init_meta.t index 6da26d8..ed85866 100644 --- a/t/050_metaclasses/failing/023_easy_init_meta.t +++ b/Moose-t-failing/050_metaclasses/023_easy_init_meta.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 13; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Mouse qw(does_ok); { @@ -26,9 +30,12 @@ use Test::Mouse qw(does_ok); use Mouse::Exporter; Mouse::Exporter->setup_import_methods( - metaclass_roles => ['Foo::Trait::Class'], - attribute_metaclass_roles => ['Foo::Trait::Attribute'], - base_class_roles => ['Foo::Role::Base'], + class_metaroles => { + class => ['Foo::Trait::Class'], + attribute => ['Foo::Trait::Attribute'], + }, + role_metaroles => { role => ['Foo::Trait::Class'] }, + base_class_roles => ['Foo::Role::Base'], ); } @@ -45,17 +52,19 @@ use Test::Mouse qw(does_ok); } { - package Foo::Exporter::WithMouse; + package Foo::Exporter::WithMoose; use Mouse (); use Mouse::Exporter; - my ($import, $unimport, $init_meta) = - Mouse::Exporter->build_import_methods( - also => 'Mouse', - metaclass_roles => ['Foo::Trait::Class'], - attribute_metaclass_roles => ['Foo::Trait::Attribute'], - base_class_roles => ['Foo::Role::Base'], - install => [qw(import unimport)], + my ( $import, $unimport, $init_meta ) + = Mouse::Exporter->build_import_methods( + also => 'Mouse', + class_metaroles => { + class => ['Foo::Trait::Class'], + attribute => ['Foo::Trait::Attribute'], + }, + base_class_roles => ['Foo::Role::Base'], + install => [qw(import unimport)], ); sub init_meta { @@ -69,7 +78,7 @@ use Test::Mouse qw(does_ok); { package Foo2; - Foo::Exporter::WithMouse->import; + Foo::Exporter::WithMoose->import; has(foo => (is => 'ro')); @@ -89,17 +98,18 @@ use Test::Mouse qw(does_ok); } { - package Foo::Exporter::WithMouseRole; + package Foo::Exporter::WithMooseRole; use Mouse::Role (); use Mouse::Exporter; - my ($import, $unimport, $init_meta) = - Mouse::Exporter->build_import_methods( - also => 'Mouse::Role', - metaclass_roles => ['Foo::Trait::Class'], - attribute_metaclass_roles => ['Foo::Trait::Attribute'], - base_class_roles => ['Foo::Role::Base'], - install => [qw(import unimport)], + my ( $import, $unimport, $init_meta ) + = Mouse::Exporter->build_import_methods( + also => 'Mouse::Role', + role_metaroles => { + role => ['Foo::Trait::Class'], + attribute => ['Foo::Trait::Attribute'], + }, + install => [qw(import unimport)], ); sub init_meta { @@ -113,8 +123,10 @@ use Test::Mouse qw(does_ok); { package Foo2::Role; - Foo::Exporter::WithMouseRole->import; + Foo::Exporter::WithMooseRole->import; ::isa_ok(Foo2::Role->meta, 'Mouse::Meta::Role'); ::does_ok(Foo2::Role->meta, 'Foo::Trait::Class'); } + +done_testing; diff --git a/t/050_metaclasses/failing/030_metarole_combination.t b/Moose-t-failing/050_metaclasses/030_metarole_combination.t similarity index 77% rename from t/050_metaclasses/failing/030_metarole_combination.t rename to Moose-t-failing/050_metaclasses/030_metarole_combination.t index b2fc134..0801149 100644 --- a/t/050_metaclasses/failing/030_metarole_combination.t +++ b/Moose-t-failing/050_metaclasses/030_metarole_combination.t @@ -1,6 +1,10 @@ use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use warnings; use Test::More; +$TODO = q{Mouse is not yet completed}; our @applications; @@ -81,14 +85,16 @@ our @applications; around apply_params => sub { my ( $next, $self, @args ) = @_; - return Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => $self->$next(@args), - application_to_class_class_roles => - ['CustomApplication::Composite::ToClass'], - application_to_role_class_roles => - ['CustomApplication::Composite::ToRole'], - application_to_instance_class_roles => - ['CustomApplication::Composite::ToInstance'], + return Mouse::Util::MetaRole::apply_metaroles( + for => $self->$next(@args), + role_metaroles => { + application_to_class => + ['CustomApplication::Composite::ToClass'], + application_to_role => + ['CustomApplication::Composite::ToRole'], + application_to_instance => + ['CustomApplication::Composite::ToInstance'], + }, ); }; } @@ -97,9 +103,10 @@ our @applications; package Role::WithCustomApplication; use Mouse::Role; - has '+composition_class_roles' => ( - default => ['Role::Composite'], - ); + around composition_class_roles => sub { + my ($orig, $self) = @_; + return $self->$orig, 'Role::Composite'; + }; } { @@ -110,14 +117,16 @@ our @applications; sub init_meta { my ( $self, %options ) = @_; - return Mouse::Util::MetaRole::apply_metaclass_roles( - for_class => Mouse::Role->init_meta(%options), - metaclass_roles => ['Role::WithCustomApplication'], - application_to_class_class_roles => - ['CustomApplication::ToClass'], - application_to_role_class_roles => ['CustomApplication::ToRole'], - application_to_instance_class_roles => - ['CustomApplication::ToInstance'], + return Mouse::Util::MetaRole::apply_metaroles( + for => Mouse::Role->init_meta(%options), + role_metaroles => { + role => ['Role::WithCustomApplication'], + application_to_class => + ['CustomApplication::ToClass'], + application_to_role => ['CustomApplication::ToRole'], + application_to_instance => + ['CustomApplication::ToInstance'], + }, ); } } @@ -138,7 +147,7 @@ ok( My::Role::Special->meta->isa('Mouse::Meta::Role'), ); ok( My::Role::Special->meta->meta->does_role('Role::WithCustomApplication'), "the role's metaobject has custom applications" ); -is_deeply( My::Role::Special->meta->composition_class_roles, +is_deeply( [My::Role::Special->meta->composition_class_roles], ['Role::Composite'], "the role knows about the specified composition class" ); diff --git a/t/050_metaclasses/failing/015_metarole.t b/Moose-t-failing/050_metaclasses/050_metarole_backcompat.t similarity index 93% rename from t/050_metaclasses/failing/015_metarole.t rename to Moose-t-failing/050_metaclasses/050_metarole_backcompat.t index 95f9e47..ef06636 100644 --- a/t/050_metaclasses/failing/015_metarole.t +++ b/Moose-t-failing/050_metaclasses/050_metarole_backcompat.t @@ -1,15 +1,26 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +# This is a copy of 015_metarole.t taken on 01/01/2010. It provides a +# comprehensive test of backwards compatibility in the MetaRole API. use strict; use warnings; use lib 't/lib', 'lib'; -use Test::More 'no_plan'; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; use Mouse::Util::MetaRole; +{ + no warnings 'redefine'; + *Mouse::Deprecated::deprecated = sub { return }; +} { package My::Meta::Class; @@ -81,7 +92,6 @@ use Mouse::Util::MetaRole; } { - last; # skip Mouse::Util::MetaRole::apply_metaclass_roles( for_class => 'My::Class', wrapped_method_metaclass_roles => ['Role::Foo'], @@ -102,8 +112,6 @@ use Mouse::Util::MetaRole; } { - last; # skip - Mouse::Util::MetaRole::apply_metaclass_roles( for_class => 'My::Class', instance_metaclass_roles => ['Role::Foo'], @@ -136,8 +144,8 @@ use Mouse::Util::MetaRole; q{... My::Class->meta()'s attribute metaclass still does Role::Foo} ); ok( My::Class->meta()->method_metaclass()->meta()->does_role('Role::Foo'), q{... My::Class->meta()'s method metaclass still does Role::Foo} ); -# ok( My::Class->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), -# q{... My::Class->meta()'s instance metaclass still does Role::Foo} ); + ok( My::Class->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), + q{... My::Class->meta()'s instance metaclass still does Role::Foo} ); # Actually instantiating the constructor class is too freaking hard! ok( My::Class->meta()->constructor_class()->can('foo'), @@ -158,8 +166,8 @@ use Mouse::Util::MetaRole; q{... My::Class->meta()'s attribute metaclass still does Role::Foo} ); ok( My::Class->meta()->method_metaclass()->meta()->does_role('Role::Foo'), q{... My::Class->meta()'s method metaclass still does Role::Foo} ); -# ok( My::Class->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), -# q{... My::Class->meta()'s instance metaclass still does Role::Foo} ); + ok( My::Class->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), + q{... My::Class->meta()'s instance metaclass still does Role::Foo} ); ok( My::Class->meta()->constructor_class()->meta()->does_role('Role::Foo'), q{... My::Class->meta()'s constructor class still does Role::Foo} ); @@ -169,8 +177,6 @@ use Mouse::Util::MetaRole; } { - last; # skip - Mouse::Util::MetaRole::apply_metaclass_roles( for_class => 'My::Role', application_to_class_class_roles => ['Role::Foo'], @@ -184,8 +190,6 @@ use Mouse::Util::MetaRole; } { - last; # skip - Mouse::Util::MetaRole::apply_metaclass_roles( for_class => 'My::Role', application_to_role_class_roles => ['Role::Foo'], @@ -201,8 +205,6 @@ use Mouse::Util::MetaRole; } { - last; # skip - Mouse::Util::MetaRole::apply_metaclass_roles( for_class => 'My::Role', application_to_instance_class_roles => ['Role::Foo'], @@ -266,10 +268,10 @@ use Mouse::Util::MetaRole; is( My::Class2->meta()->get_method('bar')->foo(), 10, '... call foo() on a method metaclass object' ); -# ok( My::Class2->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), -# q{apply Role::Foo to My::Class2->meta()'s instance metaclass} ); -# is( My::Class2->meta()->get_meta_instance()->foo(), 10, -# '... call foo() on an instance metaclass object' ); + ok( My::Class2->meta()->instance_metaclass()->meta()->does_role('Role::Foo'), + q{apply Role::Foo to My::Class2->meta()'s instance metaclass} ); + is( My::Class2->meta()->get_meta_instance()->foo(), 10, + '... call foo() on an instance metaclass object' ); ok( My::Class2->meta()->constructor_class()->meta()->does_role('Role::Foo'), q{apply Role::Foo to My::Class2->meta()'s constructor class} ); @@ -352,7 +354,7 @@ use Mouse::Util::MetaRole; { package My::Class5; use Mouse; - + extends 'My::Class'; } @@ -370,7 +372,7 @@ use Mouse::Util::MetaRole; ok( My::Class5->meta()->destructor_class()->meta()->does_role('Role::Foo'), q{My::Class5->meta()'s destructor class also does Role::Foo} ); } -exit; + { Mouse::Util::MetaRole::apply_metaclass_roles( for_class => 'My::Class5', @@ -477,7 +479,7 @@ exit; # This tests applying meta roles to a metaclass's metaclass. This is # completely insane, but is exactly what happens with # Fey::Meta::Class::Table. It's a subclass of Mouse::Meta::Class -# itself, and then it _uses_ MouseX::ClassAttribute, so the metaclass +# itself, and then it _uses_ MooseX::ClassAttribute, so the metaclass # for Fey::Meta::Class::Table does a role. # # At one point this caused a metaclass incompatibility error down @@ -542,7 +544,7 @@ exit; { package My::Constructor; - use base 'Mouse::Meta::Method::Constructor'; + use base 'Mouse::Meta::Method'; } { @@ -566,7 +568,7 @@ exit; } { - package ExportsMouse; + package ExportsMoose; Mouse::Exporter->setup_import_methods( also => 'Mouse', @@ -586,8 +588,8 @@ exit; } lives_ok { - package UsesExportedMouse; - ExportsMouse->import; + package UsesExportedMoose; + ExportsMoose->import; } 'import module which loads a role from disk during init_meta'; { @@ -662,15 +664,12 @@ lives_ok { 'Parent constructor class has metarole from Parent' ); -TODO: - { - local $TODO - = 'Mouse does not see that the child differs from the parent because it only checks the class and instance metaclasses do determine compatibility'; - ok( - Child->meta->constructor_class->meta->can('does_role') - && Child->meta->constructor_class->meta->does_role( - 'Role::Foo'), - 'Child constructor class has metarole from Parent' - ); - } + ok( + Child->meta->constructor_class->meta->can('does_role') + && Child->meta->constructor_class->meta->does_role( + 'Role::Foo'), + 'Child constructor class has metarole from Parent' + ); } + +done_testing; diff --git a/Moose-t-failing/050_metaclasses/052_metaclass_compat.t b/Moose-t-failing/050_metaclasses/052_metaclass_compat.t new file mode 100644 index 0000000..f3179d3 --- /dev/null +++ b/Moose-t-failing/050_metaclasses/052_metaclass_compat.t @@ -0,0 +1,309 @@ +#!/usr/bin/env perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use strict; +use warnings; +use lib 't/lib'; +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +our $called = 0; +{ + package Foo::Trait::Constructor; + use Mouse::Role; + + around _generate_BUILDALL => sub { + my $orig = shift; + my $self = shift; + return $self->$orig(@_) . '$::called++;'; + } +} + +{ + package Foo; + use Mouse; + Mouse::Util::MetaRole::apply_metaroles( + for => __PACKAGE__, + class_metaroles => { + constructor => ['Foo::Trait::Constructor'], + } + ); +} + +Foo->new; +is($called, 0, "no calls before inlining"); +Foo->meta->make_immutable; + +Foo->new; +is($called, 1, "inlined constructor has trait modifications"); + +ok(Foo->meta->constructor_class->meta->does_role('Foo::Trait::Constructor'), + "class has correct constructor traits"); + +{ + package Foo::Sub; + use Mouse; + extends 'Foo'; +} + +$called = 0; + +Foo::Sub->new; +is($called, 0, "no calls before inlining"); + +Foo::Sub->meta->make_immutable; + +Foo::Sub->new; +is($called, 1, "inherits constructor trait properly"); + +ok(Foo::Sub->meta->constructor_class->meta->can('does_role') +&& Foo::Sub->meta->constructor_class->meta->does_role('Foo::Trait::Constructor'), + "subclass inherits constructor traits"); + +{ + package Foo2::Role; + use Mouse::Role; +} +{ + package Foo2; + use Mouse -traits => ['Foo2::Role']; +} +{ + package Bar2; + use Mouse; +} +{ + package Baz2; + use Mouse; + my $meta = __PACKAGE__->meta; + ::lives_ok { $meta->superclasses('Foo2') } "can set superclasses once"; + ::isa_ok($meta, Foo2->meta->meta->name); + ::lives_ok { $meta->superclasses('Bar2') } "can still set superclasses"; + ::isa_ok($meta, Bar2->meta->meta->name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo2::Role'], + "still have the role attached"); + ::ok(!$meta->is_immutable, + "immutable superclass doesn't make this class immutable"); + ::lives_ok { $meta->make_immutable } "can still make immutable"; +} +{ + package Foo3::Role; + use Mouse::Role; +} +{ + package Bar3; + use Mouse -traits => ['Foo3::Role']; +} +{ + package Baz3; + use Mouse -traits => ['Foo3::Role']; + my $meta = __PACKAGE__->meta; + ::lives_ok { $meta->superclasses('Foo2') } "can set superclasses once"; + ::isa_ok($meta, Foo2->meta->meta->name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo2::Role', 'Foo3::Role'], + "reconciled roles correctly"); + ::lives_ok { $meta->superclasses('Bar3') } "can still set superclasses"; + ::isa_ok($meta, Bar3->meta->meta->name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo2::Role', 'Foo3::Role'], + "roles still the same"); + ::ok(!$meta->is_immutable, + "immutable superclass doesn't make this class immutable"); + ::lives_ok { $meta->make_immutable } "can still make immutable"; +} +{ + package Quux3; + use Mouse; +} +{ + package Quuux3; + use Mouse -traits => ['Foo3::Role']; + my $meta = __PACKAGE__->meta; + ::lives_ok { $meta->superclasses('Foo2') } "can set superclasses once"; + ::isa_ok($meta, Foo2->meta->meta->name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo2::Role', 'Foo3::Role'], + "reconciled roles correctly"); + ::lives_ok { $meta->superclasses('Quux3') } "can still set superclasses"; + ::isa_ok($meta, Quux3->meta->meta->name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo2::Role', 'Foo3::Role'], + "roles still the same"); + ::ok(!$meta->is_immutable, + "immutable superclass doesn't make this class immutable"); + ::lives_ok { $meta->make_immutable } "can still make immutable"; +} + +{ + package Foo4::Role; + use Mouse::Role; +} +{ + package Foo4; + use Mouse -traits => ['Foo4::Role']; + __PACKAGE__->meta->make_immutable; +} +{ + package Bar4; + use Mouse; +} +{ + package Baz4; + use Mouse; + my $meta = __PACKAGE__->meta; + ::lives_ok { $meta->superclasses('Foo4') } "can set superclasses once"; + ::isa_ok($meta, Foo4->meta->_get_mutable_metaclass_name); + ::lives_ok { $meta->superclasses('Bar4') } "can still set superclasses"; + ::isa_ok($meta, Bar4->meta->meta->name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo4::Role'], + "still have the role attached"); + ::ok(!$meta->is_immutable, + "immutable superclass doesn't make this class immutable"); + ::lives_ok { $meta->make_immutable } "can still make immutable"; +} +{ + package Foo5::Role; + use Mouse::Role; +} +{ + package Bar5; + use Mouse -traits => ['Foo5::Role']; +} +{ + package Baz5; + use Mouse -traits => ['Foo5::Role']; + my $meta = __PACKAGE__->meta; + ::lives_ok { $meta->superclasses('Foo4') } "can set superclasses once"; + ::isa_ok($meta, Foo4->meta->_get_mutable_metaclass_name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo4::Role', 'Foo5::Role'], + "reconciled roles correctly"); + ::lives_ok { $meta->superclasses('Bar5') } "can still set superclasses"; + ::isa_ok($meta, Bar5->meta->meta->name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo4::Role', 'Foo5::Role'], + "roles still the same"); + ::ok(!$meta->is_immutable, + "immutable superclass doesn't make this class immutable"); + ::lives_ok { $meta->make_immutable } "can still make immutable"; +} +{ + package Quux5; + use Mouse; +} +{ + package Quuux5; + use Mouse -traits => ['Foo5::Role']; + my $meta = __PACKAGE__->meta; + ::lives_ok { $meta->superclasses('Foo4') } "can set superclasses once"; + ::isa_ok($meta, Foo4->meta->_get_mutable_metaclass_name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo4::Role', 'Foo5::Role'], + "reconciled roles correctly"); + ::lives_ok { $meta->superclasses('Quux5') } "can still set superclasses"; + ::isa_ok($meta, Quux5->meta->meta->name); + ::is_deeply([sort map { $_->name } $meta->meta->calculate_all_roles_with_inheritance], + ['Foo4::Role', 'Foo5::Role'], + "roles still the same"); + ::ok(!$meta->is_immutable, + "immutable superclass doesn't make this class immutable"); + ::lives_ok { $meta->make_immutable } "can still make immutable"; +} + +{ + package Foo5::Meta::Role; + use Mouse::Role; +} +{ + package Foo5::SuperClass::WithMetaRole; + use Mouse -traits =>'Foo5::Meta::Role'; +} +{ + package Foo5::SuperClass::After::Attribute; + use Mouse; +} +{ + package Foo5; + use Mouse; + my @superclasses = ('Foo5::SuperClass::WithMetaRole'); + extends @superclasses; + + has an_attribute_generating_methods => ( is => 'ro' ); + + push(@superclasses, 'Foo5::SuperClass::After::Attribute'); + + ::lives_ok { + extends @superclasses; + } 'MI extends after_generated_methods with metaclass roles'; + ::lives_ok { + extends reverse @superclasses; + } + 'MI extends after_generated_methods with metaclass roles (reverse)'; +} + +{ + package Foo6::Meta::Role; + use Mouse::Role; +} +{ + package Foo6::SuperClass::WithMetaRole; + use Mouse -traits =>'Foo6::Meta::Role'; +} +{ + package Foo6::Meta::OtherRole; + use Mouse::Role; +} +{ + package Foo6::SuperClass::After::Attribute; + use Mouse -traits =>'Foo6::Meta::OtherRole'; +} +{ + package Foo6; + use Mouse; + my @superclasses = ('Foo6::SuperClass::WithMetaRole'); + extends @superclasses; + + has an_attribute_generating_methods => ( is => 'ro' ); + + push(@superclasses, 'Foo6::SuperClass::After::Attribute'); + + ::throws_ok { + extends @superclasses; + } qr/compat.*pristine/, + 'unsafe MI extends after_generated_methods with metaclass roles'; + ::throws_ok { + extends reverse @superclasses; + } qr/compat.*pristine/, + 'unsafe MI extends after_generated_methods with metaclass roles (reverse)'; +} + +{ + package Foo7::Meta::Trait; + use Mouse::Role; +} + +{ + package Foo7; + use Mouse -traits => ['Foo7::Meta::Trait']; +} + +{ + package Bar7; + # in an external file + use Mouse -traits => ['Bar7::Meta::Trait']; + ::lives_ok { extends 'Foo7' } "role reconciliation works"; +} + +{ + package Bar72; + # in an external file + use Mouse -traits => ['Bar7::Meta::Trait2']; + ::lives_ok { extends 'Foo7' } "role reconciliation works"; +} + +done_testing; diff --git a/Moose-t-failing/060_compat/003_foreign_inheritence.t b/Moose-t-failing/060_compat/003_foreign_inheritence.t new file mode 100644 index 0000000..ed1cc6a --- /dev/null +++ b/Moose-t-failing/060_compat/003_foreign_inheritence.t @@ -0,0 +1,96 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + + +{ + + package Elk; + use strict; + use warnings; + + sub new { + my $class = shift; + bless { no_moose => "Elk" } => $class; + } + + sub no_moose { $_[0]->{no_moose} } + + package Foo::Mouse; + use Mouse; + + extends 'Elk'; + + has 'moose' => ( is => 'ro', default => 'Foo' ); + + sub new { + my $class = shift; + my $super = $class->SUPER::new(@_); + return $class->meta->new_object( '__INSTANCE__' => $super, @_ ); + } + + __PACKAGE__->meta->make_immutable( inline_constructor => 0, debug => 0 ); + + package Bucket; + use metaclass 'Mouse::Meta::Class'; + + __PACKAGE__->meta->add_attribute( + 'squeegee' => ( accessor => 'squeegee' ) ); + + package Old::Bucket::Nose; + + # see http://www.moosefoundation.org/moose_facts.htm + use Mouse; + + extends 'Bucket'; + + package MyBase; + sub foo { } + + package Custom::Meta1; + use base qw(Mouse::Meta::Class); + + package Custom::Meta2; + use base qw(Mouse::Meta::Class); + + package SubClass1; + use metaclass 'Custom::Meta1'; + use Mouse; + + extends 'MyBase'; + + package SubClass2; + use metaclass 'Custom::Meta2'; + use Mouse; + + # XXX FIXME subclassing meta-attrs and immutable-ing the subclass fails +} + +my $foo_moose = Foo::Mouse->new(); +isa_ok( $foo_moose, 'Foo::Mouse' ); +isa_ok( $foo_moose, 'Elk' ); + +is( $foo_moose->no_moose, 'Elk', + '... got the right value from the Elk method' ); +is( $foo_moose->moose, 'Foo', + '... got the right value from the Foo::Mouse method' ); + +lives_ok { + Old::Bucket::Nose->meta->make_immutable( debug => 0 ); +} +'Immutability on Mouse class extending Mouse::Meta class ok'; + +lives_ok { + SubClass2->meta->superclasses('MyBase'); +} +'Can subclass the same non-Mouse class twice with different metaclasses'; + +done_testing; diff --git a/Moose-t-failing/060_compat/004_entimwm b/Moose-t-failing/060_compat/004_entimwm new file mode 100644 index 0000000..c35bba6 --- /dev/null +++ b/Moose-t-failing/060_compat/004_entimwm @@ -0,0 +1,226 @@ +use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use warnings; +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Mouse::Meta (); + +{ + package My::Role; + use Mouse::Role; +} + +{ + package SomeClass; + use Mouse -traits => 'My::Role'; +} + +{ + package SubClassUseBase; + use base qw/SomeClass/; +} + +{ + package SubSubClassUseBase; + use Mouse; + use Test::More; +$TODO = q{Mouse is not yet completed}; + use Test::Exception; + lives_ok { + extends 'SubClassUseBase'; + } + 'Can extend non-Mouse class with parent class that is a Mouse class with a meta role'; +} + +{ + ok( SubSubClassUseBase->meta->meta->can('does_role') + && SubSubClassUseBase->meta->meta->does_role('My::Role'), + 'SubSubClassUseBase meta metaclass does the My::Role role' ); +} + +# Note, remove metaclasses of the 'use base' classes after each test, +# so that they have to be re-initialized - otherwise latter tests +# would not demonstrate the original issue. +Mouse::Util::remove_metaclass_by_name('SubClassUseBase'); + +{ + package OtherClass; + use Mouse; +} + +{ + package OtherSubClassUseBase; + use base 'OtherClass'; +} + +{ + package MultiParent1; + use Mouse; + use Test::More; +$TODO = q{Mouse is not yet completed}; + use Test::Exception; + lives_ok { + extends qw( SubClassUseBase OtherSubClassUseBase ); + } + 'Can extend two non-Mouse classes with parents that are different Mouse metaclasses'; +} + +{ + ok( MultiParent1->meta->meta->can('does_role') + && MultiParent1->meta->meta->does_role('My::Role'), + 'MultiParent1 meta metaclass does the My::Role role' ); +} + +Mouse::Util::remove_metaclass_by_name($_) + for qw( SubClassUseBase OtherSubClassUseBase ); + +{ + package MultiParent2; + use Mouse; + use Test::More; +$TODO = q{Mouse is not yet completed}; + use Test::Exception; + lives_ok { + extends qw( OtherSubClassUseBase SubClassUseBase ); + } + 'Can extend two non-Mouse classes with parents that are different Mouse metaclasses (reverse order)'; +} + +{ + ok( MultiParent2->meta->meta->can('does_role') + && MultiParent2->meta->meta->does_role('My::Role'), + 'MultiParent2 meta metaclass does the My::Role role' ); +} + +Mouse::Util::remove_metaclass_by_name($_) + for qw( SubClassUseBase OtherSubClassUseBase ); + +{ + package MultiParent3; + use Mouse; + use Test::More; +$TODO = q{Mouse is not yet completed}; + use Test::Exception; + lives_ok { + extends qw( OtherClass SubClassUseBase ); + } + 'Can extend one Mouse class and one non-Mouse class'; +} + +{ + ok( MultiParent3->meta->meta->can('does_role') + && MultiParent3->meta->meta->does_role('My::Role'), + 'MultiParent3 meta metaclass does the My::Role role' ); +} + +Mouse::Util::remove_metaclass_by_name($_) + for qw( SubClassUseBase OtherSubClassUseBase ); + +{ + package MultiParent4; + use Mouse; + use Test::More; +$TODO = q{Mouse is not yet completed}; + use Test::Exception; + lives_ok { + extends qw( SubClassUseBase OtherClass ); + } + 'Can extend one non-Mouse class and one Mouse class'; +} + +{ + ok( MultiParent4->meta->meta->can('does_role') + && MultiParent4->meta->meta->does_role('My::Role'), + 'MultiParent4 meta metaclass does the My::Role role' ); +} + +Mouse::Util::remove_metaclass_by_name($_) + for qw( SubClassUseBase OtherSubClassUseBase ); + +{ + package MultiChild1; + use Mouse; + use Test::More; +$TODO = q{Mouse is not yet completed}; + use Test::Exception; + lives_ok { + extends 'MultiParent1'; + } + 'Can extend class that itself extends two non-Mouse classes with Mouse parents'; +} + +{ + ok( MultiChild1->meta->meta->can('does_role') + && MultiChild1->meta->meta->does_role('My::Role'), + 'MultiChild1 meta metaclass does the My::Role role' ); +} + +Mouse::Util::remove_metaclass_by_name($_) + for qw( SubClassUseBase OtherSubClassUseBase ); + +{ + package MultiChild2; + use Mouse; + use Test::More; +$TODO = q{Mouse is not yet completed}; + use Test::Exception; + lives_ok { + extends 'MultiParent2'; + } + 'Can extend class that itself extends two non-Mouse classes with Mouse parents (reverse order)'; +} + +{ + ok( MultiChild2->meta->meta->can('does_role') + && MultiChild2->meta->meta->does_role('My::Role'), + 'MultiChild2 meta metaclass does the My::Role role' ); +} + +Mouse::Util::remove_metaclass_by_name($_) + for qw( SubClassUseBase OtherSubClassUseBase ); + +{ + package MultiChild3; + use Mouse; + use Test::More; +$TODO = q{Mouse is not yet completed}; + use Test::Exception; + lives_ok { + extends 'MultiParent3'; + } + 'Can extend class that itself extends one Mouse and one non-Mouse parent'; +} + +{ + ok( MultiChild3->meta->meta->can('does_role') + && MultiChild3->meta->meta->does_role('My::Role'), + 'MultiChild3 meta metaclass does the My::Role role' ); +} + +Mouse::Util::remove_metaclass_by_name($_) + for qw( SubClassUseBase OtherSubClassUseBase ); + +{ + package MultiChild4; + use Mouse; + use Test::More; +$TODO = q{Mouse is not yet completed}; + use Test::Exception; + lives_ok { + extends 'MultiParent4'; + } + 'Can extend class that itself extends one non-Mouse and one Mouse parent'; +} + +{ + ok( MultiChild4->meta->meta->can('does_role') + && MultiChild4->meta->meta->does_role('My::Role'), + 'MultiChild4 meta metaclass does the My::Role role' ); +} + +Mouse::Util::remove_metaclass_by_name($_) + for qw( SubClassUseBase OtherSubClassUseBase ); + +done_testing; diff --git a/Moose-t-failing/070_native_traits/000_load.t b/Moose-t-failing/070_native_traits/000_load.t new file mode 100644 index 0000000..96880cb --- /dev/null +++ b/Moose-t-failing/070_native_traits/000_load.t @@ -0,0 +1,23 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Mouse (); + +BEGIN { + use_ok('Mouse::Meta::Attribute::Native'); + use_ok('Mouse::Meta::Attribute::Native::Trait::Bool'); + use_ok('Mouse::Meta::Attribute::Native::Trait::Hash'); + use_ok('Mouse::Meta::Attribute::Native::Trait::Array'); + use_ok('Mouse::Meta::Attribute::Native::Trait::Counter'); + use_ok('Mouse::Meta::Attribute::Native::Trait::Number'); + use_ok('Mouse::Meta::Attribute::Native::Trait::String'); +} + +done_testing; diff --git a/Moose-t-failing/070_native_traits/204_trait_number.t b/Moose-t-failing/070_native_traits/204_trait_number.t new file mode 100644 index 0000000..c40757e --- /dev/null +++ b/Moose-t-failing/070_native_traits/204_trait_number.t @@ -0,0 +1,117 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Mouse; + +{ + package Real; + use Mouse; + + has 'integer' => ( + traits => ['Number'], + is => 'ro', + isa => 'Int', + default => 5, + handles => { + set => 'set', + add => 'add', + sub => 'sub', + mul => 'mul', + div => 'div', + mod => 'mod', + abs => 'abs', + inc => [ add => 1 ], + dec => [ sub => 1 ], + odd => [ mod => 2 ], + cut_in_half => [ div => 2 ], + + }, + ); +} + +my $real = Real->new; +isa_ok( $real, 'Real' ); + +can_ok( $real, $_ ) for qw[ + set add sub mul div mod abs inc dec odd cut_in_half +]; + +is $real->integer, 5, 'Default to five'; + +$real->add(10); + +is $real->integer, 15, 'Add ten for fithteen'; + +$real->sub(3); + +is $real->integer, 12, 'Subtract three for 12'; + +$real->set(10); + +is $real->integer, 10, 'Set to ten'; + +$real->div(2); + +is $real->integer, 5, 'divide by 2'; + +$real->mul(2); + +is $real->integer, 10, 'multiplied by 2'; + +$real->mod(2); + +is $real->integer, 0, 'Mod by 2'; + +$real->set(7); + +$real->mod(5); + +is $real->integer, 2, 'Mod by 5'; + +$real->set(-1); + +$real->abs; + +is $real->integer, 1, 'abs 1'; + +$real->set(12); + +$real->inc; + +is $real->integer, 13, 'inc 12'; + +$real->dec; + +is $real->integer, 12, 'dec 13'; + +## test the meta + +my $attr = $real->meta->get_attribute('integer'); +does_ok( $attr, 'Mouse::Meta::Attribute::Native::Trait::Number' ); + +is_deeply( + $attr->handles, + { + set => 'set', + add => 'add', + sub => 'sub', + mul => 'mul', + div => 'div', + mod => 'mod', + abs => 'abs', + inc => [ add => 1 ], + dec => [ sub => 1 ], + odd => [ mod => 2 ], + cut_in_half => [ div => 2 ], + }, + '... got the right handles mapping' +); + +done_testing; diff --git a/Moose-t-failing/070_native_traits/205_trait_list.t b/Moose-t-failing/070_native_traits/205_trait_list.t new file mode 100644 index 0000000..1a58502 --- /dev/null +++ b/Moose-t-failing/070_native_traits/205_trait_list.t @@ -0,0 +1,172 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; +use Test::Mouse 'does_ok'; + +my $sort; +my $less; +my $up; +my $prod; +{ + package Stuff; + use Mouse; + + has '_options' => ( + traits => ['Array'], + is => 'ro', + isa => 'ArrayRef[Int]', + init_arg => 'options', + default => sub { [] }, + handles => { + 'num_options' => 'count', + 'has_no_options' => 'is_empty', + 'map_options', => 'map', + 'filter_options' => 'grep', + 'find_option' => 'first', + 'options' => 'elements', + 'join_options' => 'join', + 'get_option_at' => 'get', + 'sorted_options' => 'sort', + 'randomized_options' => 'shuffle', + 'unique_options' => 'uniq', + 'less_than_five' => [ grep => ($less = sub { $_ < 5 }) ], + 'up_by_one' => [ map => ($up = sub { $_ + 1 }) ], + 'pairwise_options' => [ natatime => 2 ], + 'dashify' => [ join => '-' ], + 'descending' => [ sort => ($sort = sub { $_[1] <=> $_[0] }) ], + 'product' => [ reduce => ($prod = sub { $_[0] * $_[1] }) ], + }, + ); + +} + +my $stuff = Stuff->new( options => [ 1 .. 10 ] ); +isa_ok( $stuff, 'Stuff' ); + +can_ok( $stuff, $_ ) for qw[ + _options + num_options + has_no_options + map_options + filter_options + find_option + options + join_options + get_option_at + sorted_options + randomized_options + unique_options + less_than_five + up_by_one + pairwise_options + dashify + descending + product +]; + +is_deeply( $stuff->_options, [ 1 .. 10 ], '... got options' ); + +ok( !$stuff->has_no_options, '... we have options' ); +is( $stuff->num_options, 10, '... got 2 options' ); +cmp_ok( $stuff->get_option_at(0), '==', 1, '... get option 0' ); + +is_deeply( + [ $stuff->filter_options( sub { $_ % 2 == 0 } ) ], + [ 2, 4, 6, 8, 10 ], + '... got the right filtered values' +); + +is_deeply( + [ $stuff->map_options( sub { $_ * 2 } ) ], + [ 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 ], + '... got the right mapped values' +); + +is( $stuff->find_option( sub { $_ % 2 == 0 } ), 2, + '.. found the right option' ); + +is_deeply( [ $stuff->options ], [ 1 .. 10 ], '... got the list of options' ); + +is( $stuff->join_options(':'), '1:2:3:4:5:6:7:8:9:10', + '... joined the list of options by :' ); + +is_deeply( + [ $stuff->sorted_options ], [ sort ( 1 .. 10 ) ], + '... got sorted options (default sort order)' +); +is_deeply( + [ $stuff->sorted_options( sub { $_[1] <=> $_[0] } ) ], + [ sort { $b <=> $a } ( 1 .. 10 ) ], + '... got sorted options (descending sort order) ' +); + +throws_ok { $stuff->sorted_options('foo') } +qr/Argument must be a code reference/, + 'error when sort receives a non-coderef argument'; + +is_deeply( [ sort { $a <=> $b } $stuff->randomized_options ], [ 1 .. 10 ] ); + +my @pairs; +$stuff->pairwise_options(sub { push @pairs, [@_] }); +is_deeply( \@pairs, [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7, 8 ], [ 9, 10 ] ] ); + +# test the currying +is_deeply( [ $stuff->less_than_five() ], [ 1 .. 4 ] ); + +is_deeply( [ $stuff->up_by_one() ], [ 2 .. 11 ] ); + +is( $stuff->dashify, '1-2-3-4-5-6-7-8-9-10' ); + +is_deeply( [ $stuff->descending ], [ reverse 1 .. 10 ] ); + +is( $stuff->product, 3628800 ); + +my $other_stuff = Stuff->new( options => [ 1, 1, 2, 3, 5 ] ); +is_deeply( [ $other_stuff->unique_options ], [1, 2, 3, 5] ); + +## test the meta + +my $options = $stuff->meta->get_attribute('_options'); +does_ok( $options, 'Mouse::Meta::Attribute::Native::Trait::Array' ); + +is_deeply( + $options->handles, + { + 'num_options' => 'count', + 'has_no_options' => 'is_empty', + 'map_options', => 'map', + 'filter_options' => 'grep', + 'find_option' => 'first', + 'options' => 'elements', + 'join_options' => 'join', + 'get_option_at' => 'get', + 'sorted_options' => 'sort', + 'randomized_options' => 'shuffle', + 'unique_options' => 'uniq', + 'less_than_five' => [ grep => $less ], + 'up_by_one' => [ map => $up ], + 'pairwise_options' => [ natatime => 2 ], + 'dashify' => [ join => '-' ], + 'descending' => [ sort => $sort ], + 'product' => [ reduce => $prod ], + }, + '... got the right handles mapping' +); + +is( $options->type_constraint->type_parameter, 'Int', + '... got the right container type' ); + +dies_ok { + $stuff->sort_in_place_options(undef); +} +'... sort rejects arg of invalid type'; + +done_testing; diff --git a/t/100_bugs/failing/006_handles_foreign_class_bug.t b/Moose-t-failing/100_bugs/006_handles_foreign_class_bug.t similarity index 89% rename from t/100_bugs/failing/006_handles_foreign_class_bug.t rename to Moose-t-failing/100_bugs/006_handles_foreign_class_bug.t index c48d9d5..53804cf 100644 --- a/t/100_bugs/failing/006_handles_foreign_class_bug.t +++ b/Moose-t-failing/100_bugs/006_handles_foreign_class_bug.t @@ -1,9 +1,13 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 15; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; { @@ -108,4 +112,4 @@ isa_ok($blart, 'Blart'); is($blart->a, 'Foo::a', '... got the right delgated value'); - +done_testing; diff --git a/t/100_bugs/failing/018_immutable_metaclass_does_role.t b/Moose-t-failing/100_bugs/018_immutable_metaclass_does_role.t similarity index 90% rename from t/100_bugs/failing/018_immutable_metaclass_does_role.t rename to Moose-t-failing/100_bugs/018_immutable_metaclass_does_role.t index 4f4b03f..0766b6a 100644 --- a/t/100_bugs/failing/018_immutable_metaclass_does_role.t +++ b/Moose-t-failing/100_bugs/018_immutable_metaclass_does_role.t @@ -1,13 +1,16 @@ #!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use strict; use warnings; -use Test::More tests => 36; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; - BEGIN { package MyRole; use Mouse::Role; @@ -68,7 +71,7 @@ is( MyClass->meta->foo, 'i am foo', '... foo method returns expected value' ); lives_ok { MyMetaclass->meta->make_immutable; -} '... make MyClass immutable okay'; +} '... make MyMetaclass immutable okay'; is(MyClass->meta, $mc, '... these metas are still the same thing'); is(MyClass->meta->meta, $mc->meta, '... these meta-metas are the same thing'); @@ -80,7 +83,7 @@ is( MyClass->meta->foo, 'i am foo', '... foo method returns expected value' ); lives_ok { MyClass->meta->make_immutable; -} '... make MyClass immutable okay'; +} '... make MyClass immutable (again) okay'; is(MyClass->meta, $mc, '... these metas are still the same thing'); is(MyClass->meta->meta, $mc->meta, '... these meta-metas are the same thing'); @@ -90,3 +93,4 @@ is( $a->meta->foo, 'i am foo', '... foo method returns expected value' ); ok( MyClass->meta->meta->does_role('MyRole'), 'metaclass does MyRole' ); is( MyClass->meta->foo, 'i am foo', '... foo method returns expected value' ); +done_testing; diff --git a/t/100_bugs/failing/023_DEMOLISH_fails_without_metaclass.t b/Moose-t-failing/100_bugs/023_DEMOLISH_fails_without_metaclass.t similarity index 66% rename from t/100_bugs/failing/023_DEMOLISH_fails_without_metaclass.t rename to Moose-t-failing/100_bugs/023_DEMOLISH_fails_without_metaclass.t index a038456..1bd625b 100644 --- a/t/100_bugs/failing/023_DEMOLISH_fails_without_metaclass.t +++ b/Moose-t-failing/100_bugs/023_DEMOLISH_fails_without_metaclass.t @@ -1,7 +1,11 @@ use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use warnings; -use Test::More tests => 2; +use Test::More; +$TODO = q{Mouse is not yet completed}; use Test::Exception; { @@ -16,19 +20,21 @@ my $object = MyClass->new; # Removing the metaclass simulates the case where the metaclass object # goes out of scope _before_ the object itself, which under normal # circumstances only happens during global destruction. -Class::MOP::remove_metaclass_by_name('MyClass'); +Mouse::Util::remove_metaclass_by_name('MyClass'); # The bug happened when DEMOLISHALL called -# Class::MOP::class_of($object) and did not get a metaclass object +# Mouse::Util::class_of($object) and did not get a metaclass object # back. lives_ok { $object->DESTROY } 'can call DESTROY on an object without a metaclass object in the CMOP cache'; MyClass->meta->make_immutable; -Class::MOP::remove_metaclass_by_name('MyClass'); +Mouse::Util::remove_metaclass_by_name('MyClass'); # The bug didn't manifest for immutable objects, but this test should # help us prevent it happening in the future. lives_ok { $object->DESTROY } 'can call DESTROY on an object without a metaclass object in the CMOP cache (immutable version)'; + +done_testing; diff --git a/t/100_bugs/failing/024_anon_method_metaclass.t b/Moose-t-failing/100_bugs/024_anon_method_metaclass.t similarity index 84% rename from t/100_bugs/failing/024_anon_method_metaclass.t rename to Moose-t-failing/100_bugs/024_anon_method_metaclass.t index e8f639b..2977c6f 100644 --- a/t/100_bugs/failing/024_anon_method_metaclass.t +++ b/Moose-t-failing/100_bugs/024_anon_method_metaclass.t @@ -1,6 +1,10 @@ use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; use warnings; -use Test::More tests => 10; +use Test::More; +$TODO = q{Mouse is not yet completed}; { package Ball; @@ -46,3 +50,5 @@ for ( 1, 2 ) { undef $method_meta; } + +done_testing; diff --git a/Moose-t-failing/200_examples/006_example_Protomoose.t b/Moose-t-failing/200_examples/006_example_Protomoose.t new file mode 100644 index 0000000..e33167c --- /dev/null +++ b/Moose-t-failing/200_examples/006_example_Protomoose.t @@ -0,0 +1,287 @@ +#!/usr/local/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; + +=pod + +This is an example of making Mouse behave +more like a prototype based object system. + +Why? + +Well cause merlyn asked if it could :) + +=cut + +## ------------------------------------------------------------------ +## make some metaclasses + +{ + package ProtoMoose::Meta::Instance; + use Mouse; + + BEGIN { extends 'Mouse::Meta::Instance' }; + + # NOTE: + # do not let things be inlined by + # the attribute or accessor generator + sub is_inlinable { 0 } +} + +{ + package ProtoMoose::Meta::Method::Accessor; + use Mouse; + + BEGIN { extends 'Mouse::Meta::Method' }; + + # customize the accessors to always grab + # the correct instance in the accessors + + sub find_instance { + my ($self, $candidate, $accessor_type) = @_; + + my $instance = $candidate; + my $attr = $self->associated_attribute; + + # if it is a class calling it ... + unless (blessed($instance)) { + # then grab the class prototype + $instance = $attr->associated_class->prototype_instance; + } + # if its an instance ... + else { + # and there is no value currently + # associated with the instance and + # we are trying to read it, then ... + if ($accessor_type eq 'r' && !defined($attr->get_value($instance))) { + # again, defer the prototype in + # the class in which is was defined + $instance = $attr->associated_class->prototype_instance; + } + # otherwise, you want to assign + # to your local copy ... + } + return $instance; + } + + sub _generate_accessor_method { + my $self = shift; + my $attr = $self->associated_attribute; + return sub { + if (scalar(@_) == 2) { + $attr->set_value( + $self->find_instance($_[0], 'w'), + $_[1] + ); + } + $attr->get_value($self->find_instance($_[0], 'r')); + }; + } + + sub _generate_reader_method { + my $self = shift; + my $attr = $self->associated_attribute; + return sub { + confess "Cannot assign a value to a read-only accessor" if @_ > 1; + $attr->get_value($self->find_instance($_[0], 'r')); + }; + } + + sub _generate_writer_method { + my $self = shift; + my $attr = $self->associated_attribute; + return sub { + $attr->set_value( + $self->find_instance($_[0], 'w'), + $_[1] + ); + }; + } + + # deal with these later ... + sub generate_predicate_method {} + sub generate_clearer_method {} + +} + +{ + package ProtoMoose::Meta::Attribute; + use Mouse; + + BEGIN { extends 'Mouse::Meta::Attribute' }; + + sub accessor_metaclass { 'ProtoMoose::Meta::Method::Accessor' } +} + +{ + package ProtoMoose::Meta::Class; + use Mouse; + + BEGIN { extends 'Mouse::Meta::Class' }; + + has 'prototype_instance' => ( + is => 'rw', + isa => 'Object', + predicate => 'has_prototypical_instance', + lazy => 1, + default => sub { (shift)->new_object } + ); + + sub initialize { + # NOTE: + # I am not sure why 'around' does + # not work here, have to investigate + # it later - SL + (shift)->SUPER::initialize(@_, + instance_metaclass => 'ProtoMoose::Meta::Instance', + attribute_metaclass => 'ProtoMoose::Meta::Attribute', + ); + } + + around 'construct_instance' => sub { + my $next = shift; + my $self = shift; + # NOTE: + # we actually have to do this here + # to tie-the-knot, if you take it + # out, then you get deep recursion + # several levels deep :) + $self->prototype_instance($next->($self, @_)) + unless $self->has_prototypical_instance; + return $self->prototype_instance; + }; + +} + +{ + package ProtoMoose::Object; + use metaclass 'ProtoMoose::Meta::Class'; + use Mouse; + + sub new { + my $prototype = blessed($_[0]) + ? $_[0] + : $_[0]->meta->prototype_instance; + my (undef, %params) = @_; + my $self = $prototype->meta->clone_object($prototype, %params); + $self->BUILDALL(\%params); + return $self; + } +} + +## ------------------------------------------------------------------ +## make some classes now + +{ + package Foo; + use Mouse; + + extends 'ProtoMoose::Object'; + + has 'bar' => (is => 'rw'); +} + +{ + package Bar; + use Mouse; + + extends 'Foo'; + + has 'baz' => (is => 'rw'); +} + +## ------------------------------------------------------------------ + +## ------------------------------------------------------------------ +## Check that metaclasses are working/inheriting properly + +foreach my $class (qw/ProtoMoose::Object Foo Bar/) { + isa_ok($class->meta, + 'ProtoMoose::Meta::Class', + '... got the right metaclass for ' . $class . ' ->'); + + is($class->meta->instance_metaclass, + 'ProtoMoose::Meta::Instance', + '... got the right instance meta for ' . $class); + + is($class->meta->attribute_metaclass, + 'ProtoMoose::Meta::Attribute', + '... got the right attribute meta for ' . $class); +} + +## ------------------------------------------------------------------ + +# get the prototype for Foo +my $foo_prototype = Foo->meta->prototype_instance; +isa_ok($foo_prototype, 'Foo'); + +# set a value in the prototype +$foo_prototype->bar(100); +is($foo_prototype->bar, 100, '... got the value stored in the prototype'); + +# the "class" defers to the +# the prototype when asked +# about attributes +is(Foo->bar, 100, '... got the value stored in the prototype (through the Foo class)'); + +# now make an instance, which +# is basically a clone of the +# prototype +my $foo = Foo->new; +isa_ok($foo, 'Foo'); + +# the instance is *not* the prototype +isnt($foo, $foo_prototype, '... got a new instance of Foo'); + +# but it has the same values ... +is($foo->bar, 100, '... got the value stored in the instance (inherited from the prototype)'); + +# we can even change the values +# in the instance +$foo->bar(300); +is($foo->bar, 300, '... got the value stored in the instance (overwriting the one inherited from the prototype)'); + +# and not change the one in the prototype +is($foo_prototype->bar, 100, '... got the value stored in the prototype'); +is(Foo->bar, 100, '... got the value stored in the prototype (through the Foo class)'); + +## subclasses + +# now we can check that the subclass +# will seek out the correct prototypical +# value from it's "parent" +is(Bar->bar, 100, '... got the value stored in the Foo prototype (through the Bar class)'); + +# we can then also set it's local attrs +Bar->baz(50); +is(Bar->baz, 50, '... got the value stored in the prototype (through the Bar class)'); + +# now we clone the Bar prototype +my $bar = Bar->new; +isa_ok($bar, 'Bar'); +isa_ok($bar, 'Foo'); + +# and we see that we got the right values +# in the instance/clone +is($bar->bar, 100, '... got the value stored in the instance (inherited from the Foo prototype)'); +is($bar->baz, 50, '... got the value stored in the instance (inherited from the Bar prototype)'); + +# nowe we can change the value +$bar->bar(200); +is($bar->bar, 200, '... got the value stored in the instance (overriding the one inherited from the Foo prototype)'); + +# and all our original and +# prototypical values are still +# the same +is($foo->bar, 300, '... still got the original value stored in the instance (inherited from the prototype)'); +is(Foo->bar, 100, '... still got the original value stored in the prototype (through the Foo class)'); +is(Bar->bar, 100, '... still got the original value stored in the prototype (through the Bar class)'); + +done_testing; diff --git a/Moose-t-failing/400_moose_util/003_moose_util_search_class_by_role.t b/Moose-t-failing/400_moose_util/003_moose_util_search_class_by_role.t new file mode 100644 index 0000000..0ab84b8 --- /dev/null +++ b/Moose-t-failing/400_moose_util/003_moose_util_search_class_by_role.t @@ -0,0 +1,49 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; + +BEGIN { + use_ok('Mouse::Util', ':all'); +} + +{ package SCBR::Role; + use Mouse::Role; +} + +{ package SCBR::A; + use Mouse; +} +is search_class_by_role('SCBR::A', 'SCBR::Role'), undef, '... not found role returns undef'; +is search_class_by_role('SCBR::A', SCBR::Role->meta), undef, '... not found role returns undef'; + +{ package SCBR::B; + use Mouse; + extends 'SCBR::A'; + with 'SCBR::Role'; +} +is search_class_by_role('SCBR::B', 'SCBR::Role'), 'SCBR::B', '... class itself returned if it does role'; +is search_class_by_role('SCBR::B', SCBR::Role->meta), 'SCBR::B', '... class itself returned if it does role'; + +{ package SCBR::C; + use Mouse; + extends 'SCBR::B'; +} +is search_class_by_role('SCBR::C', 'SCBR::Role'), 'SCBR::B', '... nearest class doing role returned'; +is search_class_by_role('SCBR::C', SCBR::Role->meta), 'SCBR::B', '... nearest class doing role returned'; + +{ package SCBR::D; + use Mouse; + extends 'SCBR::C'; + with 'SCBR::Role'; +} +is search_class_by_role('SCBR::D', 'SCBR::Role'), 'SCBR::D', '... nearest class being direct class returned'; +is search_class_by_role('SCBR::D', SCBR::Role->meta), 'SCBR::D', '... nearest class being direct class returned'; + +done_testing; diff --git a/Moose-t-failing/400_moose_util/004_resolve_alias.t b/Moose-t-failing/400_moose_util/004_resolve_alias.t new file mode 100644 index 0000000..3e5c287 --- /dev/null +++ b/Moose-t-failing/400_moose_util/004_resolve_alias.t @@ -0,0 +1,83 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; + +use Mouse::Util qw( resolve_metaclass_alias resolve_metatrait_alias ); + +use lib 't/lib'; + +# Doing each test twice is intended to make sure that the caching +# doesn't break name resolution. It doesn't actually test that +# anything is cached. +is( resolve_metaclass_alias( 'Attribute', 'Mouse::Meta::Attribute::Custom::Foo' ), + 'Mouse::Meta::Attribute::Custom::Foo', + 'resolve_metaclass_alias finds Mouse::Meta::Attribute::Custom::Foo' ); + +is( resolve_metaclass_alias( 'Attribute', 'Mouse::Meta::Attribute::Custom::Foo' ), + 'Mouse::Meta::Attribute::Custom::Foo', + 'resolve_metaclass_alias finds Mouse::Meta::Attribute::Custom::Foo second time' ); + +is( resolve_metaclass_alias( 'Attribute', 'Foo' ), + 'Mouse::Meta::Attribute::Custom::Foo', + 'resolve_metaclass_alias finds Mouse::Meta::Attribute::Custom::Foo via alias (Foo)' ); + +is( resolve_metaclass_alias( 'Attribute', 'Foo' ), + 'Mouse::Meta::Attribute::Custom::Foo', + 'resolve_metaclass_alias finds Mouse::Meta::Attribute::Custom::Foo via alias (Foo) a second time' ); + +is( resolve_metaclass_alias( 'Attribute', 'Mouse::Meta::Attribute::Custom::Bar' ), + 'My::Bar', + 'resolve_metaclass_alias finds Mouse::Meta::Attribute::Custom::Bar as My::Bar' ); + +is( resolve_metaclass_alias( 'Attribute', 'Mouse::Meta::Attribute::Custom::Bar' ), + 'My::Bar', + 'resolve_metaclass_alias finds Mouse::Meta::Attribute::Custom::Bar as My::Bar a second time' ); + +is( resolve_metaclass_alias( 'Attribute', 'Bar' ), + 'My::Bar', + 'resolve_metaclass_alias finds Mouse::Meta::Attribute::Custom::Bar as My::Bar via alias (Bar)' ); + +is( resolve_metaclass_alias( 'Attribute', 'Bar' ), + 'My::Bar', + 'resolve_metaclass_alias finds Mouse::Meta::Attribute::Custom::Bar as My::Bar via alias (Bar) a second time' ); + +is( resolve_metatrait_alias( 'Attribute', 'Mouse::Meta::Attribute::Custom::Trait::Foo' ), + 'Mouse::Meta::Attribute::Custom::Trait::Foo', + 'resolve_metatrait_alias finds Mouse::Meta::Attribute::Custom::Trait::Foo' ); + +is( resolve_metatrait_alias( 'Attribute', 'Mouse::Meta::Attribute::Custom::Trait::Foo' ), + 'Mouse::Meta::Attribute::Custom::Trait::Foo', + 'resolve_metatrait_alias finds Mouse::Meta::Attribute::Custom::Trait::Foo second time' ); + +is( resolve_metatrait_alias( 'Attribute', 'Foo' ), + 'Mouse::Meta::Attribute::Custom::Trait::Foo', + 'resolve_metatrait_alias finds Mouse::Meta::Attribute::Custom::Trait::Foo via alias (Foo)' ); + +is( resolve_metatrait_alias( 'Attribute', 'Foo' ), + 'Mouse::Meta::Attribute::Custom::Trait::Foo', + 'resolve_metatrait_alias finds Mouse::Meta::Attribute::Custom::Trait::Foo via alias (Foo) a second time' ); + +is( resolve_metatrait_alias( 'Attribute', 'Mouse::Meta::Attribute::Custom::Trait::Bar' ), + 'My::Trait::Bar', + 'resolve_metatrait_alias finds Mouse::Meta::Attribute::Custom::Trait::Bar as My::Trait::Bar' ); + +is( resolve_metatrait_alias( 'Attribute', 'Mouse::Meta::Attribute::Custom::Trait::Bar' ), + 'My::Trait::Bar', + 'resolve_metatrait_alias finds Mouse::Meta::Attribute::Custom::Trait::Bar as My::Trait::Bar a second time' ); + +is( resolve_metatrait_alias( 'Attribute', 'Bar' ), + 'My::Trait::Bar', + 'resolve_metatrait_alias finds Mouse::Meta::Attribute::Custom::Trait::Bar as My::Trait::Bar via alias (Bar)' ); + +is( resolve_metatrait_alias( 'Attribute', 'Bar' ), + 'My::Trait::Bar', + 'resolve_metatrait_alias finds Mouse::Meta::Attribute::Custom::Trait::Bar as My::Trait::Bar via alias (Bar) a second time' ); + +done_testing; diff --git a/Moose-t-failing/400_moose_util/005_ensure_all_roles.t b/Moose-t-failing/400_moose_util/005_ensure_all_roles.t new file mode 100644 index 0000000..aac2c07 --- /dev/null +++ b/Moose-t-failing/400_moose_util/005_ensure_all_roles.t @@ -0,0 +1,70 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; + +BEGIN { + use_ok('Mouse::Util', ':all'); +} + +{ + package Foo; + use Mouse::Role; +} + +{ + package Bar; + use Mouse::Role; +} + +{ + package Quux; + use Mouse; +} + +is_deeply( + Quux->meta->roles, + [], + "no roles yet", +); + +Foo->meta->apply(Quux->meta); + +is_deeply( + Quux->meta->roles, + [ Foo->meta ], + "applied Foo", +); + +Foo->meta->apply(Quux->meta); +Bar->meta->apply(Quux->meta); +is_deeply( + Quux->meta->roles, + [ Foo->meta, Foo->meta, Bar->meta ], + "duplicated Foo", +); + +is(does_role('Quux', 'Foo'), 1, "Quux does Foo"); +is(does_role('Quux', 'Bar'), 1, "Quux does Bar"); +ensure_all_roles('Quux', qw(Foo Bar)); +is_deeply( + Quux->meta->roles, + [ Foo->meta, Foo->meta, Bar->meta ], + "unchanged, since all roles are already applied", +); + +my $obj = Quux->new; +ensure_all_roles($obj, qw(Foo Bar)); +is_deeply( + $obj->meta->roles, + [ Foo->meta, Foo->meta, Bar->meta ], + "unchanged, since all roles are already applied", +); + +done_testing; diff --git a/Moose-t-failing/400_moose_util/006_create_alias.t b/Moose-t-failing/400_moose_util/006_create_alias.t new file mode 100644 index 0000000..7f0db46 --- /dev/null +++ b/Moose-t-failing/400_moose_util/006_create_alias.t @@ -0,0 +1,108 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Mouse qw(does_ok); + +BEGIN { + package Foo::Meta::Role; + use Mouse::Role; + Mouse::Util::meta_class_alias + FooRole => 'Foo::Meta::Role'; + + package Foo::Meta::Class; + use Mouse; + extends 'Mouse::Meta::Class'; + with 'Foo::Meta::Role'; + Mouse::Util::meta_class_alias + FooClass => 'Foo::Meta::Class'; + + package Foo::Meta::Role::Attribute; + use Mouse::Role; + Mouse::Util::meta_attribute_alias + FooAttrRole => 'Foo::Meta::Role::Attribute'; + + package Foo::Meta::Attribute; + use Mouse; + extends 'Mouse::Meta::Attribute'; + with 'Foo::Meta::Role::Attribute'; + Mouse::Util::meta_attribute_alias + FooAttrClass => 'Foo::Meta::Attribute'; + + package Bar::Meta::Role; + use Mouse::Role; + Mouse::Util::meta_class_alias 'BarRole'; + + package Bar::Meta::Class; + use Mouse; + extends 'Mouse::Meta::Class'; + with 'Bar::Meta::Role'; + Mouse::Util::meta_class_alias 'BarClass'; + + package Bar::Meta::Role::Attribute; + use Mouse::Role; + Mouse::Util::meta_attribute_alias 'BarAttrRole'; + + package Bar::Meta::Attribute; + use Mouse; + extends 'Mouse::Meta::Attribute'; + with 'Bar::Meta::Role::Attribute'; + Mouse::Util::meta_attribute_alias 'BarAttrClass'; +} + +package FooWithMetaClass; +use Mouse -metaclass => 'FooClass'; + +has bar => ( + metaclass => 'FooAttrClass', + is => 'ro', +); + + +package FooWithMetaTrait; +use Mouse -traits => 'FooRole'; + +has bar => ( + traits => [qw(FooAttrRole)], + is => 'ro', +); + +package BarWithMetaClass; +use Mouse -metaclass => 'BarClass'; + +has bar => ( + metaclass => 'BarAttrClass', + is => 'ro', +); + + +package BarWithMetaTrait; +use Mouse -traits => 'BarRole'; + +has bar => ( + traits => [qw(BarAttrRole)], + is => 'ro', +); + +package main; +my $fwmc_meta = FooWithMetaClass->meta; +my $fwmt_meta = FooWithMetaTrait->meta; +isa_ok($fwmc_meta, 'Foo::Meta::Class'); +isa_ok($fwmc_meta->get_attribute('bar'), 'Foo::Meta::Attribute'); +does_ok($fwmt_meta, 'Foo::Meta::Role'); +does_ok($fwmt_meta->get_attribute('bar'), 'Foo::Meta::Role::Attribute'); + +my $bwmc_meta = BarWithMetaClass->meta; +my $bwmt_meta = BarWithMetaTrait->meta; +isa_ok($bwmc_meta, 'Bar::Meta::Class'); +isa_ok($bwmc_meta->get_attribute('bar'), 'Bar::Meta::Attribute'); +does_ok($bwmt_meta, 'Bar::Meta::Role'); +does_ok($bwmt_meta->get_attribute('bar'), 'Bar::Meta::Role::Attribute'); + +done_testing; diff --git a/Moose-t-failing/400_moose_util/008_method_mod_args.t b/Moose-t-failing/400_moose_util/008_method_mod_args.t new file mode 100644 index 0000000..5942f44 --- /dev/null +++ b/Moose-t-failing/400_moose_util/008_method_mod_args.t @@ -0,0 +1,35 @@ +use strict; +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; +use Mouse::Util qw( add_method_modifier ); + +my $COUNT = 0; +{ + package Foo; + use Mouse; + + sub foo { } + sub bar { } +} + +lives_ok { + add_method_modifier('Foo', 'before', [ ['foo', 'bar'], sub { $COUNT++ } ]); +} 'method modifier with an arrayref'; + +dies_ok { + add_method_modifier('Foo', 'before', [ {'foo' => 'bar'}, sub { $COUNT++ } ]); +} 'method modifier with a hashref'; + +my $foo = Foo->new; +$foo->foo; +$foo->bar; +is($COUNT, 2, "checking that the modifiers were installed."); + + +done_testing; diff --git a/Moose-t-failing/400_moose_util/009_with_traits.t b/Moose-t-failing/400_moose_util/009_with_traits.t new file mode 100644 index 0000000..e8d1244 --- /dev/null +++ b/Moose-t-failing/400_moose_util/009_with_traits.t @@ -0,0 +1,55 @@ +#!/usr/bin/env perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use strict; +use warnings; +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Mouse; + +use Mouse (); +use Mouse::Util qw(with_traits); + +{ + package Foo; + use Mouse; +} + +{ + package Foo::Role; + use Mouse::Role; +} + +{ + package Foo::Role2; + use Mouse::Role; +} + +{ + my $traited_class = with_traits('Foo', 'Foo::Role'); + ok($traited_class->meta->is_anon_class, "we get an anon class"); + isa_ok($traited_class, 'Foo'); + does_ok($traited_class, 'Foo::Role'); +} + +{ + my $traited_class = with_traits('Foo', 'Foo::Role', 'Foo::Role2'); + ok($traited_class->meta->is_anon_class, "we get an anon class"); + isa_ok($traited_class, 'Foo'); + does_ok($traited_class, 'Foo::Role'); + does_ok($traited_class, 'Foo::Role2'); +} + +{ + my $traited_class = with_traits('Foo'); + is($traited_class, 'Foo', "don't apply anything if we don't get any traits"); +} + +{ + my $traited_class = with_traits('Foo', 'Foo::Role'); + my $traited_class2 = with_traits('Foo', 'Foo::Role'); + is($traited_class, $traited_class2, "get the same class back when passing the same roles"); +} + +done_testing; diff --git a/Moose-t-failing/600_todo_tests/002_various_role_features.t b/Moose-t-failing/600_todo_tests/002_various_role_features.t new file mode 100644 index 0000000..a8afc95 --- /dev/null +++ b/Moose-t-failing/600_todo_tests/002_various_role_features.t @@ -0,0 +1,279 @@ +#!/usr/bin/perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; + +use strict; +use warnings; + +use Test::More; +$TODO = q{Mouse is not yet completed}; +use Test::Exception; + +sub req_or_has ($$) { + my ( $role, $method ) = @_; + local $Test::Builder::Level = $Test::Builder::Level + 1; + if ( $role ) { + ok( + $role->has_method($method) || $role->requires_method($method), + $role->name . " has or requires method $method" + ); + } else { + fail("role has or requires method $method"); + } +} + +{ + package Bar; + use Mouse::Role; + + # this role eventually adds three methods, qw(foo bar xxy), but only one is + # known when it's still a role + + has foo => ( is => "rw" ); + + has gorch => ( reader => "bar" ); + + sub xxy { "BAAAD" } + + package Gorch; + use Mouse::Role; + + # similarly this role gives attr and gorch_method + + has attr => ( is => "rw" ); + + sub gorch_method { "gorch method" } + + around dandy => sub { shift->(@_) . "bar" }; + + package Quxx; + use Mouse; + + sub dandy { "foo" } + + # this object will be used in an attr of Foo to test that Foo can do the + # Gorch interface + + with qw(Gorch); + + package Dancer; + use Mouse::Role; + + requires "twist"; + + package Dancer::Ballerina; + use Mouse; + + with qw(Dancer); + + sub twist { } + + sub pirouette { } + + package Dancer::Robot; + use Mouse::Role; + + # this doesn't fail but it produces a requires in the role + # the order doesn't matter + has twist => ( is => "rw" ); + ::lives_ok { with qw(Dancer) }; + + package Dancer::Something; + use Mouse; + + # this fail even though the method already exists + + has twist => ( is => "rw" ); + + { + ::lives_ok { with qw(Dancer) }; + } + + package Dancer::80s; + use Mouse; + + # this should pass because ::Robot has the attribute to fill in the requires + # but due to the deferrence logic that doesn't actually work + { + local our $TODO = "attribute accessor in role doesn't satisfy role requires"; + ::lives_ok { with qw(Dancer::Robot) }; + } + + package Foo; + use Mouse; + + with qw(Bar); + + has oink => ( + is => "rw", + handles => "Gorch", # should handles take the same arguments as 'with'? Meta::Role::Application::Delegation? + default => sub { Quxx->new }, + ); + + has dancer => ( + is => "rw", + does => "Dancer", + handles => "Dancer", + default => sub { Dancer::Ballerina->new }, + ); + + sub foo { 42 } + + sub bar { 33 } + + sub xxy { 7 } + + package Tree; + use Mouse::Role; + + has bark => ( is => "rw" ); + + package Dog; + use Mouse::Role; + + sub bark { warn "woof!" }; + + package EntPuppy; + use Mouse; + + { + local our $TODO = "attrs and methods from a role should clash"; + ::dies_ok { with qw(Tree Dog) } + } +} + +# these fail because of the deferral logic winning over actual methods +# this might be tricky to fix due to the 'sub foo {}; has foo => ( )' hack +# we've been doing for a long while, though I doubt people relied on it for +# anything other than fulfilling 'requires' +{ + local $TODO = "attributes from role overwrite class methods"; + is( Foo->new->foo, 42, "attr did not zap overriding method" ); + is( Foo->new->bar, 33, "attr did not zap overriding method" ); +} +is( Foo->new->xxy, 7, "method did not zap overriding method" ); # duh + +# these pass, simple delegate +# mostly they are here to contrast the next blck +can_ok( Foo->new->oink, "dandy" ); +can_ok( Foo->new->oink, "attr" ); +can_ok( Foo->new->oink, "gorch_method" ); + +ok( Foo->new->oink->does("Gorch"), "Quxx does Gorch" ); + + +# these are broken because 'attr' is not technically part of the interface +can_ok( Foo->new, "gorch_method" ); +{ + local $TODO = "accessor methods from a role are omitted in handles role"; + can_ok( Foo->new, "attr" ); +} + +{ + local $TODO = "handles role doesn't add the role to the ->does of the delegate's parent class"; + ok( Foo->new->does("Gorch"), "Foo does Gorch" ); +} + + +# these work +can_ok( Foo->new->dancer, "pirouette" ); +can_ok( Foo->new->dancer, "twist" ); + +can_ok( Foo->new, "twist" ); +ok( !Foo->new->can("pirouette"), "can't pirouette, not part of the iface" ); + +{ + local $TODO = "handles role doesn't add the role to the ->does of the delegate's parent class"; + ok( Foo->new->does("Dancer") ); +} + + + + +my $gorch = Gorch->meta; + +isa_ok( $gorch, "Mouse::Meta::Role" ); + +ok( $gorch->has_attribute("attr"), "has attribute 'attr'" ); +isa_ok( $gorch->get_attribute("attr"), "Mouse::Meta::Role::Attribute" ); + +req_or_has($gorch, "gorch_method"); +ok( $gorch->has_method("gorch_method"), "has_method gorch_method" ); +ok( !$gorch->requires_method("gorch_method"), "requires gorch method" ); +isa_ok( $gorch->get_method("gorch_method"), "Mouse::Meta::Method" ); + +{ + local $TODO = "method modifier doesn't yet create a method requirement or meta object"; + req_or_has($gorch, "dandy" ); + + # this specific test is maybe not backwards compat, but in theory it *does* + # require that method to exist + ok( $gorch->requires_method("dandy"), "requires the dandy method for the modifier" ); +} + +{ + local $TODO = "attribute related methods are not yet known by the role"; + # we want this to be a part of the interface, somehow + req_or_has($gorch, "attr"); + ok( $gorch->has_method("attr"), "has_method attr" ); + isa_ok( $gorch->get_method("attr"), "Mouse::Meta::Method" ); + isa_ok( $gorch->get_method("attr"), "Mouse::Meta::Method" ); +} + +my $robot = Dancer::Robot->meta; + +isa_ok( $robot, "Mouse::Meta::Role" ); + +ok( $robot->has_attribute("twist"), "has attr 'twist'" ); +isa_ok( $robot->get_attribute("twist"), "Mouse::Meta::Role::Attribute" ); + +{ + req_or_has($robot, "twist"); + + local $TODO = "attribute related methods are not yet known by the role"; + ok( $robot->has_method("twist"), "has twist method" ); + isa_ok( $robot->get_method("twist"), "Mouse::Meta::Method" ); + isa_ok( $robot->get_method("twist"), "Mouse::Meta::Method" ); +} + +done_testing; + +__END__ + +I think Attribute needs to be refactored in some way to better support roles. + +There are several possible ways to do this, all of them seem plausible to me. + +The first approach would be to change the attribute class to allow it to be +queried about the methods it would install. + +Then we instantiate the attribute in the role, and instead of deferring the +arguments, we just make an Cish method. + +Then we can interrogate the attr when adding it to the role, and generate stub +methods for all the methods it would produce. + +A second approach is kinda like the Immutable hack: wrap the attr in an +anonmyous class that disables part of its interface. + +A third method would be to create an Attribute::Partial object that would +provide a more role-ish behavior, and to do this independently of the actual +Attribute class. + +Something similar can be done for method modifiers, but I think that's even simpler. + + + +The benefits of doing this are: + +* Much better introspection of roles + +* More correctness in many cases (in my opinion anyway) + +* More roles are more usable as interface declarations, without having to split + them into two pieces (one for the interface with a bunch of requires(), and + another for the actual impl with the problematic attrs (and stub methods to + fix the accessors) and method modifiers (dunno if this can even work at all) + + diff --git a/Moose-t-failing/600_todo_tests/004_role_insertion_order.t b/Moose-t-failing/600_todo_tests/004_role_insertion_order.t new file mode 100644 index 0000000..7be8d3c --- /dev/null +++ b/Moose-t-failing/600_todo_tests/004_role_insertion_order.t @@ -0,0 +1,46 @@ +#!/usr/bin/env perl +# This is automatically generated by author/import-moose-test.pl. +# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!! +use t::lib::MooseCompat; +use strict; +use warnings; +use Test::More; +$TODO = q{Mouse is not yet completed}; + +{ + package Foo::Role; + use Mouse::Role; + has 'a' => (is => 'ro'); + has 'b' => (is => 'ro'); + has 'c' => (is => 'ro'); +} + +{ + package Foo; + use Mouse; + has 'd' => (is => 'ro'); + with 'Foo::Role'; + has 'e' => (is => 'ro'); +} + +my %role_insertion_order = ( + a => 0, + b => 1, + c => 2, +); + +is_deeply({ map { $_->name => $_->insertion_order } map { Foo::Role->meta->get_attribute($_) } Foo::Role->meta->get_attribute_list }, \%role_insertion_order, "right insertion order within the role"); + +my %class_insertion_order = ( + d => 0, + a => 1, + b => 2, + c => 3, + e => 4, +); + +{ local $TODO = "insertion order is lost during role application"; +is_deeply({ map { $_->name => $_->insertion_order } Foo->meta->get_all_attributes }, \%class_insertion_order, "right insertion order within the class"); +} + +done_testing; diff --git a/t/020_attributes/failing/019_attribute_lazy_initializer.t b/t/020_attributes/failing/019_attribute_lazy_initializer.t deleted file mode 100644 index 5e72276..0000000 --- a/t/020_attributes/failing/019_attribute_lazy_initializer.t +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 23; -use Test::Exception; - - - -{ - package Foo; - use Mouse; - - has 'foo' => ( - reader => 'get_foo', - writer => 'set_foo', - initializer => sub { - my ($self, $value, $callback, $attr) = @_; - - ::isa_ok($attr, 'Mouse::Meta::Attribute'); - ::is($attr->name, 'foo', '... got the right name'); - - $callback->($value * 2); - }, - ); - - has 'lazy_foo' => ( - reader => 'get_lazy_foo', - lazy => 1, - default => 10, - initializer => sub { - my ($self, $value, $callback, $attr) = @_; - - ::isa_ok($attr, 'Mouse::Meta::Attribute'); - ::is($attr->name, 'lazy_foo', '... got the right name'); - - $callback->($value * 2); - }, - ); - - has 'lazy_foo_w_type' => ( - reader => 'get_lazy_foo_w_type', - isa => 'Int', - lazy => 1, - default => 20, - initializer => sub { - my ($self, $value, $callback, $attr) = @_; - - ::isa_ok($attr, 'Mouse::Meta::Attribute'); - ::is($attr->name, 'lazy_foo_w_type', '... got the right name'); - - $callback->($value * 2); - }, - ); - - has 'lazy_foo_builder' => ( - reader => 'get_lazy_foo_builder', - builder => 'get_foo_builder', - initializer => sub { - my ($self, $value, $callback, $attr) = @_; - - ::isa_ok($attr, 'Mouse::Meta::Attribute'); - ::is($attr->name, 'lazy_foo_builder', '... got the right name'); - - $callback->($value * 2); - }, - ); - - has 'lazy_foo_builder_w_type' => ( - reader => 'get_lazy_foo_builder_w_type', - isa => 'Int', - builder => 'get_foo_builder_w_type', - initializer => sub { - my ($self, $value, $callback, $attr) = @_; - - ::isa_ok($attr, 'Mouse::Meta::Attribute'); - ::is($attr->name, 'lazy_foo_builder_w_type', '... got the right name'); - - $callback->($value * 2); - }, - ); - - sub get_foo_builder { 100 } - sub get_foo_builder_w_type { 1000 } -} - -{ - my $foo = Foo->new(foo => 10); - isa_ok($foo, 'Foo'); - - is($foo->get_foo, 20, 'initial value set to 2x given value'); - is($foo->get_lazy_foo, 20, 'initial lazy value set to 2x given value'); - is($foo->get_lazy_foo_w_type, 40, 'initial lazy value with type set to 2x given value'); - is($foo->get_lazy_foo_builder, 200, 'initial lazy value with builder set to 2x given value'); - is($foo->get_lazy_foo_builder_w_type, 2000, 'initial lazy value with builder and type set to 2x given value'); -} - -{ - package Bar; - use Mouse; - - has 'foo' => ( - reader => 'get_foo', - writer => 'set_foo', - initializer => sub { - my ($self, $value, $callback, $attr) = @_; - - ::isa_ok($attr, 'Mouse::Meta::Attribute'); - ::is($attr->name, 'foo', '... got the right name'); - - $callback->($value * 2); - }, - ); - - __PACKAGE__->meta->make_immutable; -} - -{ - my $bar = Bar->new(foo => 10); - isa_ok($bar, 'Bar'); - - is($bar->get_foo, 20, 'initial value set to 2x given value'); -} - -{ - package Fail::Bar; - use Mouse; - - has 'foo' => ( - reader => 'get_foo', - writer => 'set_foo', - isa => 'Int', - initializer => sub { - my ($self, $value, $callback, $attr) = @_; - - ::isa_ok($attr, 'Mouse::Meta::Attribute'); - ::is($attr->name, 'foo', '... got the right name'); - - $callback->("Hello $value World"); - }, - ); - - __PACKAGE__->meta->make_immutable; -} - -dies_ok { - Fail::Bar->new(foo => 10) -} '... this fails, because initializer returns a bad type'; - diff --git a/t/020_attributes/failing/027_accessor_override_method.t b/t/020_attributes/failing/027_accessor_override_method.t deleted file mode 100644 index 8285b69..0000000 --- a/t/020_attributes/failing/027_accessor_override_method.t +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More; - -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; - plan tests => 5; -} - -{ - package Foo; - use Mouse; - - sub get_a { } - sub set_b { } - sub has_c { } - sub clear_d { } - sub e { } -} - -my $foo_meta = Foo->meta; -stderr_like(sub { $foo_meta->add_attribute(a => (reader => 'get_a')) }, - qr/^You are overwriting a locally defined method \(get_a\) with an accessor/, 'reader overriding gives proper warning'); -stderr_like(sub { $foo_meta->add_attribute(b => (writer => 'set_b')) }, - qr/^You are overwriting a locally defined method \(set_b\) with an accessor/, 'writer overriding gives proper warning'); -stderr_like(sub { $foo_meta->add_attribute(c => (predicate => 'has_c')) }, - qr/^You are overwriting a locally defined method \(has_c\) with an accessor/, 'predicate overriding gives proper warning'); -stderr_like(sub { $foo_meta->add_attribute(d => (clearer => 'clear_d')) }, - qr/^You are overwriting a locally defined method \(clear_d\) with an accessor/, 'clearer overriding gives proper warning'); -stderr_like(sub { $foo_meta->add_attribute(e => (is => 'rw')) }, - qr/^You are overwriting a locally defined method \(e\) with an accessor/, 'accessor overriding gives proper warning'); diff --git a/t/020_attributes/failing/031_delegation_and_modifiers.t b/t/020_attributes/failing/031_delegation_and_modifiers.t deleted file mode 100644 index 2a8d62a..0000000 --- a/t/020_attributes/failing/031_delegation_and_modifiers.t +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 5; -use Test::Exception; - -{ - package Bar; - use Mouse; - - sub baz { 'Bar::baz' } - sub gorch { 'Bar::gorch' } - - package Foo; - use Mouse; - - has 'bar' => ( - is => 'ro', - isa => 'Bar', - lazy => 1, - default => sub { Bar->new }, - handles => [qw[ baz gorch ]] - ); - - package Foo::Extended; - use Mouse; - - extends 'Foo'; - - has 'test' => ( - is => 'rw', - isa => 'Bool', - default => sub { 0 }, - ); - - around 'bar' => sub { - my $next = shift; - my $self = shift; - - $self->test(1); - $self->$next(); - }; -} - -my $foo = Foo::Extended->new; -isa_ok($foo, 'Foo::Extended'); -isa_ok($foo, 'Foo'); - -ok(!$foo->test, '... the test value has not been changed'); - -is($foo->baz, 'Bar::baz', '... got the right delegated method'); - -ok($foo->test, '... the test value has now been changed'); - - - - - - - - diff --git a/t/030_roles/failing/038_new_meta_role.t b/t/030_roles/failing/038_new_meta_role.t deleted file mode 100644 index e0ebe03..0000000 --- a/t/030_roles/failing/038_new_meta_role.t +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use Test::More tests => 1; - -do { - package My::Meta::Role; - use Mouse; - BEGIN { extends 'Mouse::Meta::Role' }; -}; - -do { - package My::Role; - use Mouse::Role -metaclass => 'My::Meta::Role'; -}; - -is(My::Role->meta->meta->name, 'My::Meta::Role'); - diff --git a/t/030_roles/failing/043_conflict_many_methods.t b/t/030_roles/failing/043_conflict_many_methods.t deleted file mode 100644 index b8eb2c9..0000000 --- a/t/030_roles/failing/043_conflict_many_methods.t +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; - -use Test::More tests => 2; -use Test::Exception; - -{ - package Bomb; - use Mouse::Role; - - sub fuse { } - sub explode { } - - package Spouse; - use Mouse::Role; - - sub fuse { } - sub explode { } - - package Caninish; - use Mouse::Role; - - sub bark { } - - package Treeve; - use Mouse::Role; - - sub bark { } -} - -package PracticalJoke; -use Mouse; - -::throws_ok { - with 'Bomb', 'Spouse'; -} qr/Due to method name conflicts in roles 'Bomb' and 'Spouse', the methods 'explode' and 'fuse' must be implemented or excluded by 'PracticalJoke'/; - -::throws_ok { - with ( - 'Bomb', 'Spouse', - 'Caninish', 'Treeve', - ); -} qr/Due to a method name conflict in roles 'Caninish' and 'Treeve', the method 'bark' must be implemented or excluded by 'PracticalJoke'/; - diff --git a/t/040_type_constraints/failing/002_util_type_constraints_export.t b/t/040_type_constraints/failing/002_util_type_constraints_export.t deleted file mode 100644 index 5d5612c..0000000 --- a/t/040_type_constraints/failing/002_util_type_constraints_export.t +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 4; -use Test::Exception; - -{ - package Foo; - - use Mouse::Util::TypeConstraints; - - eval { - type MyRef => where { ref($_) }; - }; - ::ok( !$@, '... successfully exported &type to Foo package' ); - - eval { - subtype MyArrayRef => as MyRef => where { ref($_) eq 'ARRAY' }; - }; - ::ok( !$@, '... successfully exported &subtype to Foo package' ); - - Mouse::Util::TypeConstraints->export_type_constraints_as_functions(); - - ::ok( MyRef( {} ), '... Ref worked correctly' ); - ::ok( MyArrayRef( [] ), '... ArrayRef worked correctly' ); -} diff --git a/t/040_type_constraints/failing/006_util_type_reloading.t b/t/040_type_constraints/failing/006_util_type_reloading.t deleted file mode 100644 index 4cde153..0000000 --- a/t/040_type_constraints/failing/006_util_type_reloading.t +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use lib 't/lib', 'lib'; - -use Test::More tests => 4; -use Test::Exception; - - - -$SIG{__WARN__} = sub { 0 }; - -eval { require Foo; }; -ok(!$@, '... loaded Foo successfully') || diag $@; - -delete $INC{'Foo.pm'}; - -eval { require Foo; }; -ok(!$@, '... re-loaded Foo successfully') || diag $@; - -eval { require Bar; }; -ok(!$@, '... loaded Bar successfully') || diag $@; - -delete $INC{'Bar.pm'}; - -eval { require Bar; }; -ok(!$@, '... re-loaded Bar successfully') || diag $@; \ No newline at end of file diff --git a/t/040_type_constraints/failing/011_container_type_constraint.t b/t/040_type_constraints/failing/011_container_type_constraint.t deleted file mode 100644 index 82f1b99..0000000 --- a/t/040_type_constraints/failing/011_container_type_constraint.t +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 24; -use Test::Exception; - -BEGIN { - use_ok('Mouse::Util::TypeConstraints'); - use_ok('Mouse::Meta::TypeConstraint::Parameterized'); -} - -# Array of Ints - -my $array_of_ints = Mouse::Meta::TypeConstraint::Parameterized->new( - name => 'ArrayRef[Int]', - parent => find_type_constraint('ArrayRef'), - type_parameter => find_type_constraint('Int'), -); -isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); -isa_ok($array_of_ints, 'Mouse::Meta::TypeConstraint'); - -ok($array_of_ints->check([ 1, 2, 3, 4 ]), '... [ 1, 2, 3, 4 ] passed successfully'); -ok(!$array_of_ints->check([qw/foo bar baz/]), '... [qw/foo bar baz/] failed successfully'); -ok(!$array_of_ints->check([ 1, 2, 3, qw/foo bar/]), '... [ 1, 2, 3, qw/foo bar/] failed successfully'); - -ok(!$array_of_ints->check(1), '... 1 failed successfully'); -ok(!$array_of_ints->check({}), '... {} failed successfully'); -ok(!$array_of_ints->check(sub { () }), '... sub { () } failed successfully'); - -# Hash of Ints - -my $hash_of_ints = Mouse::Meta::TypeConstraint::Parameterized->new( - name => 'HashRef[Int]', - parent => find_type_constraint('HashRef'), - type_parameter => find_type_constraint('Int'), -); -isa_ok($hash_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); -isa_ok($hash_of_ints, 'Mouse::Meta::TypeConstraint'); - -ok($hash_of_ints->check({ one => 1, two => 2, three => 3 }), '... { one => 1, two => 2, three => 3 } passed successfully'); -ok(!$hash_of_ints->check({ 1 => 'one', 2 => 'two', 3 => 'three' }), '... { 1 => one, 2 => two, 3 => three } failed successfully'); -ok(!$hash_of_ints->check({ 1 => 'one', 2 => 'two', three => 3 }), '... { 1 => one, 2 => two, three => 3 } failed successfully'); - -ok(!$hash_of_ints->check(1), '... 1 failed successfully'); -ok(!$hash_of_ints->check([]), '... [] failed successfully'); -ok(!$hash_of_ints->check(sub { () }), '... sub { () } failed successfully'); - -# Array of Array of Ints - -my $array_of_array_of_ints = Mouse::Meta::TypeConstraint::Parameterized->new( - name => 'ArrayRef[ArrayRef[Int]]', - parent => find_type_constraint('ArrayRef'), - type_parameter => $array_of_ints, -); -isa_ok($array_of_array_of_ints, 'Mouse::Meta::TypeConstraint::Parameterized'); -isa_ok($array_of_array_of_ints, 'Mouse::Meta::TypeConstraint'); - -ok($array_of_array_of_ints->check( - [[ 1, 2, 3 ], [ 4, 5, 6 ]] -), '... [[ 1, 2, 3 ], [ 4, 5, 6 ]] passed successfully'); -ok(!$array_of_array_of_ints->check( - [[ 1, 2, 3 ], [ qw/foo bar/ ]] -), '... [[ 1, 2, 3 ], [ qw/foo bar/ ]] failed successfully'); - -{ - my $anon_type = Mouse::Util::TypeConstraints::find_or_parse_type_constraint('ArrayRef[Foo]'); - isa_ok( $anon_type, 'Mouse::Meta::TypeConstraint::Parameterized' ); - - my $param_type = $anon_type->type_parameter; - isa_ok( $param_type, 'Mouse::Meta::TypeConstraint::Class' ); -} diff --git a/t/040_type_constraints/failing/018_custom_parameterized_types.t b/t/040_type_constraints/failing/018_custom_parameterized_types.t deleted file mode 100644 index c00bda9..0000000 --- a/t/040_type_constraints/failing/018_custom_parameterized_types.t +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 28; -use Test::Exception; - -BEGIN { - use_ok("Mouse::Util::TypeConstraints"); - use_ok('Mouse::Meta::TypeConstraint::Parameterized'); -} - -lives_ok { - subtype 'AlphaKeyHash' => as 'HashRef' - => where { - # no keys match non-alpha - (grep { /[^a-zA-Z]/ } keys %$_) == 0 - }; -} '... created the subtype special okay'; - -lives_ok { - subtype 'Trihash' => as 'AlphaKeyHash' - => where { - keys(%$_) == 3 - }; -} '... created the subtype special okay'; - -lives_ok { - subtype 'Noncon' => as 'Item'; -} '... created the subtype special okay'; - -{ - my $t = find_type_constraint('AlphaKeyHash'); - isa_ok($t, 'Mouse::Meta::TypeConstraint'); - - is($t->name, 'AlphaKeyHash', '... name is correct'); - - my $p = $t->parent; - isa_ok($p, 'Mouse::Meta::TypeConstraint'); - - is($p->name, 'HashRef', '... parent name is correct'); - - ok($t->check({ one => 1, two => 2 }), '... validated it correctly'); - ok(!$t->check({ one1 => 1, two2 => 2 }), '... validated it correctly'); - - ok( $t->equals($t), "equals to self" ); - ok( !$t->equals($t->parent), "not equal to parent" ); -} - -my $hoi = Mouse::Util::TypeConstraints::find_or_parse_type_constraint('AlphaKeyHash[Int]'); - -ok($hoi->check({ one => 1, two => 2 }), '... validated it correctly'); -ok(!$hoi->check({ one1 => 1, two2 => 2 }), '... validated it correctly'); -ok(!$hoi->check({ one => 'uno', two => 'dos' }), '... validated it correctly'); -ok(!$hoi->check({ one1 => 'un', two2 => 'deux' }), '... validated it correctly'); - -ok( $hoi->equals($hoi), "equals to self" ); -ok( !$hoi->equals($hoi->parent), "equals to self" ); -ok( !$hoi->equals(find_type_constraint('AlphaKeyHash')), "not equal to unparametrized self" ); -ok( $hoi->equals( Mouse::Meta::TypeConstraint::Parameterized->new( name => "Blah", parent => find_type_constraint("AlphaKeyHash"), type_parameter => find_type_constraint("Int") ) ), "equal to clone" ); -ok( !$hoi->equals( Mouse::Meta::TypeConstraint::Parameterized->new( name => "Oink", parent => find_type_constraint("AlphaKeyHash"), type_parameter => find_type_constraint("Str") ) ), "not equal to different parameter" ); - -my $th = Mouse::Util::TypeConstraints::find_or_parse_type_constraint('Trihash[Bool]'); - -ok(!$th->check({ one => 1, two => 1 }), '... validated it correctly'); -ok($th->check({ one => 1, two => 0, three => 1 }), '... validated it correctly'); -ok(!$th->check({ one => 1, two => 2, three => 1 }), '... validated it correctly'); -ok(!$th->check({foo1 => 1, bar2 => 0, baz3 => 1}), '... validated it correctly'); - -dies_ok { - Mouse::Meta::TypeConstraint::Parameterized->new( - name => 'Str[Int]', - parent => find_type_constraint('Str'), - type_parameter => find_type_constraint('Int'), - ); -} 'non-containers cannot be parameterized'; - -dies_ok { - Mouse::Meta::TypeConstraint::Parameterized->new( - name => 'Noncon[Int]', - parent => find_type_constraint('Noncon'), - type_parameter => find_type_constraint('Int'), - ); -} 'non-containers cannot be parameterized'; - diff --git a/t/040_type_constraints/failing/027_parameterize_from.t b/t/040_type_constraints/failing/027_parameterize_from.t deleted file mode 100644 index 7ff3d0a..0000000 --- a/t/040_type_constraints/failing/027_parameterize_from.t +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 12; -use Test::Exception; - -BEGIN { - use_ok('Mouse::Util::TypeConstraints'); -} - -# testing the parameterize method - -{ - my $parameterizable = subtype 'parameterizable_hashref', as 'HashRef'; - - my $parameterized = subtype 'parameterized_hashref', as 'HashRef[Int]'; - - my $int = Mouse::Util::TypeConstraints::find_type_constraint('Int'); - - my $from_parameterizable = $parameterizable->parameterize($int); - - isa_ok $parameterizable, - 'Mouse::Meta::TypeConstraint::Parameterizable', => - 'Got expected type instance'; - - package Test::Mouse::Meta::TypeConstraint::Parameterizable; - use Mouse; - - has parameterizable => ( is => 'rw', isa => $parameterizable ); - has parameterized => ( is => 'rw', isa => $parameterized ); - has from_parameterizable => ( is => 'rw', isa => $from_parameterizable ); -} - -# Create and check a dummy object - -ok my $params = Test::Mouse::Meta::TypeConstraint::Parameterizable->new() => - 'Create Dummy object for testing'; - -isa_ok $params, 'Test::Mouse::Meta::TypeConstraint::Parameterizable' => - 'isa correct type'; - -# test parameterizable - -lives_ok sub { - $params->parameterizable( { a => 'Hello', b => 'World' } ); -} => 'No problem setting parameterizable'; - -is_deeply $params->parameterizable, - { a => 'Hello', b => 'World' } => 'Got expected values'; - -# test parameterized - -lives_ok sub { - $params->parameterized( { a => 1, b => 2 } ); -} => 'No problem setting parameterized'; - -is_deeply $params->parameterized, { a => 1, b => 2 } => 'Got expected values'; - -throws_ok sub { - $params->parameterized( { a => 'Hello', b => 'World' } ); - }, qr/Attribute \(parameterized\) does not pass the type constraint/ => - 'parameterized throws expected error'; - -# test from_parameterizable - -lives_ok sub { - $params->from_parameterizable( { a => 1, b => 2 } ); -} => 'No problem setting from_parameterizable'; - -is_deeply $params->from_parameterizable, - { a => 1, b => 2 } => 'Got expected values'; - -throws_ok sub { - $params->from_parameterizable( { a => 'Hello', b => 'World' } ); - }, - qr/Attribute \(from_parameterizable\) does not pass the type constraint/ - => 'from_parameterizable throws expected error'; diff --git a/t/040_type_constraints/failing/031_subtype_auto_vivify_parent.t b/t/040_type_constraints/failing/031_subtype_auto_vivify_parent.t deleted file mode 100644 index e245ab8..0000000 --- a/t/040_type_constraints/failing/031_subtype_auto_vivify_parent.t +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 4; - -use Mouse::Util::TypeConstraints; - - -{ - package Foo; - - sub new { - my $class = shift; - - return bless {@_}, $class; - } -} - -subtype 'FooWithSize' - => as 'Foo' - => where { $_[0]->{size} }; - - -my $type = find_type_constraint('FooWithSize'); -ok( $type, 'made a FooWithSize constraint' ); -ok( $type->parent, 'type has a parent type' ); -is( $type->parent->name, 'Foo', 'parent type is Foo' ); -isa_ok( $type->parent, 'Mouse::Meta::TypeConstraint::Class', - 'parent type constraint is a class type' ); diff --git a/t/040_type_constraints/failing/032_throw_error.t b/t/040_type_constraints/failing/032_throw_error.t deleted file mode 100644 index d9c992b..0000000 --- a/t/040_type_constraints/failing/032_throw_error.t +++ /dev/null @@ -1,12 +0,0 @@ -use strict; -use warnings; - -use Test::More tests => 1; - -use Mouse::Util::TypeConstraints; - - -eval { Mouse::Util::TypeConstraints::create_type_constraint_union() }; - -like( $@, qr/\QYou must pass in at least 2 type names to make a union/, - 'can throw a proper error without Mouse being loaded by the caller' ); diff --git a/t/040_type_constraints/failing/034_duck_types.t b/t/040_type_constraints/failing/034_duck_types.t deleted file mode 100644 index e5b467b..0000000 --- a/t/040_type_constraints/failing/034_duck_types.t +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/perl -use strict; -use warnings; - -use Test::More tests => 5; -use Test::Exception; - -{ - - package Duck; - use Mouse; - - sub quack { } - -} - -{ - - package Swan; - use Mouse; - - sub honk { } - -} - -{ - - package RubberDuck; - use Mouse; - - sub quack { } - -} - -{ - - package DucktypeTest; - use Mouse; - use Mouse::Util::TypeConstraints; - - duck_type 'DuckType' => qw(quack); - duck_type 'SwanType' => [qw(honk)]; - - has duck => ( - isa => 'DuckType', - is => 'ro', - lazy_build => 1, - ); - - sub _build_duck { Duck->new } - - has swan => ( - isa => duck_type( [qw(honk)] ), - is => 'ro', - ); - - has other_swan => ( - isa => 'SwanType', - is => 'ro', - ); - -} - -# try giving it a duck -lives_ok { DucktypeTest->new( duck => Duck->new ) } 'the Duck lives okay'; - -# try giving it a swan which is like a duck, but not close enough -throws_ok { DucktypeTest->new( duck => Swan->new ) } -qr/Swan is missing methods 'quack'/, - "the Swan doesn't quack"; - -# try giving it a rubber RubberDuckey -lives_ok { DucktypeTest->new( swan => Swan->new ) } 'but a Swan can honk'; - -# try giving it a rubber RubberDuckey -lives_ok { DucktypeTest->new( duck => RubberDuck->new ) } -'the RubberDuck lives okay'; - -# try with the other constraint form -lives_ok { DucktypeTest->new( other_swan => Swan->new ) } 'but a Swan can honk'; diff --git a/t/050_metaclasses/failing/004_moose_for_meta.t b/t/050_metaclasses/failing/004_moose_for_meta.t deleted file mode 100644 index 21d3a9a..0000000 --- a/t/050_metaclasses/failing/004_moose_for_meta.t +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More tests => 16; -use Test::Exception; - - - -=pod - -This test demonstrates the ability to extend -Mouse meta-level classes using Mouse itself. - -=cut - -{ - package My::Meta::Class; - use Mouse; - - extends 'Mouse::Meta::Class'; - - around 'create_anon_class' => sub { - my $next = shift; - my ($self, %options) = @_; - $options{superclasses} = [ 'Mouse::Object' ] - unless exists $options{superclasses}; - $next->($self, %options); - }; -} - -my $anon = My::Meta::Class->create_anon_class(); -isa_ok($anon, 'My::Meta::Class'); -isa_ok($anon, 'Mouse::Meta::Class'); -isa_ok($anon, 'Class::MOP::Class'); - -is_deeply( - [ $anon->superclasses ], - [ 'Mouse::Object' ], - '... got the default superclasses'); - -{ - package My::Meta::Attribute::DefaultReadOnly; - use Mouse; - - extends 'Mouse::Meta::Attribute'; - - around 'new' => sub { - my $next = shift; - my ($self, $name, %options) = @_; - $options{is} = 'ro' - unless exists $options{is}; - $next->($self, $name, %options); - }; -} - -{ - my $attr = My::Meta::Attribute::DefaultReadOnly->new('foo'); - isa_ok($attr, 'My::Meta::Attribute::DefaultReadOnly'); - isa_ok($attr, 'Mouse::Meta::Attribute'); - isa_ok($attr, 'Class::MOP::Attribute'); - - ok($attr->has_reader, '... the attribute has a reader (as expected)'); - ok(!$attr->has_writer, '... the attribute does not have a writer (as expected)'); - ok(!$attr->has_accessor, '... the attribute does not have an accessor (as expected)'); -} - -{ - my $attr = My::Meta::Attribute::DefaultReadOnly->new('foo', (is => 'rw')); - isa_ok($attr, 'My::Meta::Attribute::DefaultReadOnly'); - isa_ok($attr, 'Mouse::Meta::Attribute'); - isa_ok($attr, 'Class::MOP::Attribute'); - - ok(!$attr->has_reader, '... the attribute does not have a reader (as expected)'); - ok(!$attr->has_writer, '... the attribute does not have a writer (as expected)'); - ok($attr->has_accessor, '... the attribute does have an accessor (as expected)'); -} - diff --git a/t/050_metaclasses/failing/012_moose_exporter.t b/t/050_metaclasses/failing/012_moose_exporter.t deleted file mode 100644 index 63126aa..0000000 --- a/t/050_metaclasses/failing/012_moose_exporter.t +++ /dev/null @@ -1,391 +0,0 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use Test::More; -use Test::Exception; -BEGIN { - eval "use Test::Output;"; - plan skip_all => "Test::Output is required for this test" if $@; - plan tests => 65; -} - - -{ - package HasOwnImmutable; - - use Mouse; - - no Mouse; - - ::stderr_is( sub { eval q[sub make_immutable { return 'foo' }] }, - '', - 'no warning when defining our own make_immutable sub' ); -} - -{ - is( HasOwnImmutable->make_immutable(), 'foo', - 'HasOwnImmutable->make_immutable does not get overwritten' ); -} - -{ - package MouseX::Empty; - - use Mouse (); - Mouse::Exporter->setup_import_methods( also => 'Mouse' ); -} - -{ - package WantsMouse; - - MouseX::Empty->import(); - - sub foo { 1 } - - ::can_ok( 'WantsMouse', 'has' ); - ::can_ok( 'WantsMouse', 'with' ); - ::can_ok( 'WantsMouse', 'foo' ); - - MouseX::Empty->unimport(); -} - -{ - # Note: it's important that these methods be out of scope _now_, - # after unimport was called. We tried a - # namespace::clean(0.08)-based solution, but had to abandon it - # because it cleans the namespace _later_ (when the file scope - # ends). - ok( ! WantsMouse->can('has'), 'WantsMouse::has() has been cleaned' ); - ok( ! WantsMouse->can('with'), 'WantsMouse::with() has been cleaned' ); - can_ok( 'WantsMouse', 'foo' ); - - # This makes sure that Mouse->init_meta() happens properly - isa_ok( WantsMouse->meta(), 'Mouse::Meta::Class' ); - isa_ok( WantsMouse->new(), 'Mouse::Object' ); - -} - -{ - package MouseX::Sugar; - - use Mouse (); - - sub wrapped1 { - my $meta = shift; - return $meta->name . ' called wrapped1'; - } - - Mouse::Exporter->setup_import_methods( - with_meta => ['wrapped1'], - also => 'Mouse', - ); -} - -{ - package WantsSugar; - - MouseX::Sugar->import(); - - sub foo { 1 } - - ::can_ok( 'WantsSugar', 'has' ); - ::can_ok( 'WantsSugar', 'with' ); - ::can_ok( 'WantsSugar', 'wrapped1' ); - ::can_ok( 'WantsSugar', 'foo' ); - ::is( wrapped1(), 'WantsSugar called wrapped1', - 'wrapped1 identifies the caller correctly' ); - - MouseX::Sugar->unimport(); -} - -{ - ok( ! WantsSugar->can('has'), 'WantsSugar::has() has been cleaned' ); - ok( ! WantsSugar->can('with'), 'WantsSugar::with() has been cleaned' ); - ok( ! WantsSugar->can('wrapped1'), 'WantsSugar::wrapped1() has been cleaned' ); - can_ok( 'WantsSugar', 'foo' ); -} - -{ - package MouseX::MoreSugar; - - use Mouse (); - - sub wrapped2 { - my $caller = shift; - return $caller . ' called wrapped2'; - } - - sub as_is1 { - return 'as_is1'; - } - - Mouse::Exporter->setup_import_methods( - with_caller => ['wrapped2'], - as_is => ['as_is1'], - also => 'MouseX::Sugar', - ); -} - -{ - package WantsMoreSugar; - - MouseX::MoreSugar->import(); - - sub foo { 1 } - - ::can_ok( 'WantsMoreSugar', 'has' ); - ::can_ok( 'WantsMoreSugar', 'with' ); - ::can_ok( 'WantsMoreSugar', 'wrapped1' ); - ::can_ok( 'WantsMoreSugar', 'wrapped2' ); - ::can_ok( 'WantsMoreSugar', 'as_is1' ); - ::can_ok( 'WantsMoreSugar', 'foo' ); - ::is( wrapped1(), 'WantsMoreSugar called wrapped1', - 'wrapped1 identifies the caller correctly' ); - ::is( wrapped2(), 'WantsMoreSugar called wrapped2', - 'wrapped2 identifies the caller correctly' ); - ::is( as_is1(), 'as_is1', - 'as_is1 works as expected' ); - - MouseX::MoreSugar->unimport(); -} - -{ - ok( ! WantsMoreSugar->can('has'), 'WantsMoreSugar::has() has been cleaned' ); - ok( ! WantsMoreSugar->can('with'), 'WantsMoreSugar::with() has been cleaned' ); - ok( ! WantsMoreSugar->can('wrapped1'), 'WantsMoreSugar::wrapped1() has been cleaned' ); - ok( ! WantsMoreSugar->can('wrapped2'), 'WantsMoreSugar::wrapped2() has been cleaned' ); - ok( ! WantsMoreSugar->can('as_is1'), 'WantsMoreSugar::as_is1() has been cleaned' ); - can_ok( 'WantsMoreSugar', 'foo' ); -} - -{ - package My::Metaclass; - use Mouse; - BEGIN { extends 'Mouse::Meta::Class' } - - package My::Object; - use Mouse; - BEGIN { extends 'Mouse::Object' } - - package HasInitMeta; - - use Mouse (); - - sub init_meta { - shift; - return Mouse->init_meta( @_, - metaclass => 'My::Metaclass', - base_class => 'My::Object', - ); - } - - Mouse::Exporter->setup_import_methods( also => 'Mouse' ); -} - -{ - package NewMeta; - - HasInitMeta->import(); -} - -{ - isa_ok( NewMeta->meta(), 'My::Metaclass' ); - isa_ok( NewMeta->new(), 'My::Object' ); -} - -{ - package MouseX::CircularAlso; - - use Mouse (); - - ::dies_ok( - sub { - Mouse::Exporter->setup_import_methods( - also => [ 'Mouse', 'MouseX::CircularAlso' ], - ); - }, - 'a circular reference in also dies with an error' - ); - - ::like( - $@, - qr/\QCircular reference in 'also' parameter to Mouse::Exporter between MouseX::CircularAlso and MouseX::CircularAlso/, - 'got the expected error from circular reference in also' - ); -} - -{ - package MouseX::NoAlso; - - use Mouse (); - - ::dies_ok( - sub { - Mouse::Exporter->setup_import_methods( - also => [ 'NoSuchThing' ], - ); - }, - 'a package which does not use Mouse::Exporter in also dies with an error' - ); - - ::like( - $@, - qr/\QPackage in also (NoSuchThing) does not seem to use Mouse::Exporter (is it loaded?) at /, - 'got the expected error from a reference in also to a package which is not loaded' - ); -} - -{ - package MouseX::NotExporter; - - use Mouse (); - - ::dies_ok( - sub { - Mouse::Exporter->setup_import_methods( - also => [ 'Mouse::Meta::Method' ], - ); - }, - 'a package which does not use Mouse::Exporter in also dies with an error' - ); - - ::like( - $@, - qr/\QPackage in also (Mouse::Meta::Method) does not seem to use Mouse::Exporter at /, - 'got the expected error from a reference in also to a package which does not use Mouse::Exporter' - ); -} - -{ - package MouseX::OverridingSugar; - - use Mouse (); - - sub has { - my $caller = shift; - return $caller . ' called has'; - } - - Mouse::Exporter->setup_import_methods( - with_caller => ['has'], - also => 'Mouse', - ); -} - -{ - package WantsOverridingSugar; - - MouseX::OverridingSugar->import(); - - ::can_ok( 'WantsOverridingSugar', 'has' ); - ::can_ok( 'WantsOverridingSugar', 'with' ); - ::is( has('foo'), 'WantsOverridingSugar called has', - 'has from MouseX::OverridingSugar is called, not has from Mouse' ); - - MouseX::OverridingSugar->unimport(); -} - -{ - ok( ! WantsSugar->can('has'), 'WantsSugar::has() has been cleaned' ); - ok( ! WantsSugar->can('with'), 'WantsSugar::with() has been cleaned' ); -} - -{ - package NonExistentExport; - - use Mouse (); - - ::stderr_like { - Mouse::Exporter->setup_import_methods( - also => ['Mouse'], - with_caller => ['does_not_exist'], - ); - } qr/^Trying to export undefined sub NonExistentExport::does_not_exist/, - "warns when a non-existent method is requested to be exported"; -} - -{ - package WantsNonExistentExport; - - NonExistentExport->import; - - ::ok(!__PACKAGE__->can('does_not_exist'), - "undefined subs do not get exported"); -} - -{ - package AllOptions; - use Mouse (); - use Mouse::Exporter; - - Mouse::Exporter->setup_import_methods( - also => ['Mouse'], - with_meta => [ 'with_meta1', 'with_meta2' ], - with_caller => [ 'with_caller1', 'with_caller2' ], - as_is => ['as_is1'], - ); - - sub with_caller1 { - return @_; - } - - sub with_caller2 (&) { - return @_; - } - - sub as_is1 {2} - - sub with_meta1 { - return @_; - } - - sub with_meta2 (&) { - return @_; - } -} - -{ - package UseAllOptions; - - AllOptions->import(); -} - -{ - can_ok( 'UseAllOptions', $_ ) - for qw( with_meta1 with_meta2 with_caller1 with_caller2 as_is1 ); - - { - my ( $caller, $arg1 ) = UseAllOptions::with_caller1(42); - is( $caller, 'UseAllOptions', 'with_caller wrapped sub gets the right caller' ); - is( $arg1, 42, 'with_caller wrapped sub returns argument it was passed' ); - } - - { - my ( $meta, $arg1 ) = UseAllOptions::with_meta1(42); - isa_ok( $meta, 'Mouse::Meta::Class', 'with_meta first argument' ); - is( $arg1, 42, 'with_meta1 returns argument it was passed' ); - } - - is( - prototype( UseAllOptions->can('with_caller2') ), - prototype( AllOptions->can('with_caller2') ), - 'using correct prototype on with_meta function' - ); - - is( - prototype( UseAllOptions->can('with_meta2') ), - prototype( AllOptions->can('with_meta2') ), - 'using correct prototype on with_meta function' - ); -} - -{ - package UseAllOptions; - AllOptions->unimport(); -} - -{ - ok( ! UseAllOptions->can($_), "UseAllOptions::$_ has been unimported" ) - for qw( with_meta1 with_meta2 with_caller1 with_caller2 as_is1 ); -} diff --git a/t/050_metaclasses/failing/021_export_with_prototype.t b/t/050_metaclasses/failing/021_export_with_prototype.t deleted file mode 100644 index 469585c..0000000 --- a/t/050_metaclasses/failing/021_export_with_prototype.t +++ /dev/null @@ -1,20 +0,0 @@ -use lib "t/lib"; -package MyExporter::User; -use MyExporter; - -use Test::More (tests => 4); -use Test::Exception; - -lives_and { - with_prototype { - my $caller = caller(0); - is($caller, 'MyExporter', "With_caller prototype code gets called from MyMouseX"); - }; -} "check function with prototype"; - -lives_and { - as_is_prototype { - my $caller = caller(0); - is($caller, 'MyExporter', "As-is prototype code gets called from MyMouseX"); - }; -} "check function with prototype"; diff --git a/t/050_metaclasses/failing/040_moose_nonmoose_metatrait_init_order.t b/t/050_metaclasses/failing/040_moose_nonmoose_metatrait_init_order.t deleted file mode 100644 index 309937f..0000000 --- a/t/050_metaclasses/failing/040_moose_nonmoose_metatrait_init_order.t +++ /dev/null @@ -1,28 +0,0 @@ -use strict; -use warnings; -{ - package My::Role; - use Mouse::Role; -} -{ - package SomeClass; - use Mouse -traits => 'My::Role'; -} -{ - package SubClassUseBase; - use base qw/SomeClass/; -} -{ - package SubSubClassUseBase; - use base qw/SubClassUseBase/; -} - -use Test::More tests => 2; -use Mouse::Util qw/find_meta does_role/; - -my $subsubclass_meta = Mouse->init_meta( for_class => 'SubSubClassUseBase' ); -ok does_role($subsubclass_meta, 'My::Role'), - 'SubSubClass metaclass does role from grandparent metaclass'; -my $subclass_meta = find_meta('SubClassUseBase'); -ok does_role($subclass_meta, 'My::Role'), - 'SubClass metaclass does role from parent metaclass';