From: Arthur Axel 'fREW' Schmidt Date: Fri, 11 Dec 2009 05:47:29 +0000 (-0600) Subject: update to latest moose X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1cbb9633adb9e9b00c688c2a7e55f408e2e48e08;p=gitmo%2FMoose.git update to latest moose --- 1cbb9633adb9e9b00c688c2a7e55f408e2e48e08 diff --cc t/010_basics/001_basic_class_setup.t index a184ecd,7d5aaf7..8b7bd4b --- a/t/010_basics/001_basic_class_setup.t +++ b/t/010_basics/001_basic_class_setup.t @@@ -2,10 -2,11 +2,11 @@@ use strict; use warnings; +use lib 'lib', 't/lib'; - use Test::More tests => 23; ++use Test::More; + -use Test::More tests => 29; use Test::Exception; - - +use MetaTest; { package Foo; @@@ -13,37 -14,38 +14,51 @@@ use Moose::Util::TypeConstraints; } -can_ok('Foo', 'meta'); -isa_ok(Foo->meta, 'Moose::Meta::Class'); +skip_meta { + can_ok('Foo', 'meta'); + isa_ok(Foo->meta, 'Moose::Meta::Class'); +} 2; + -ok(Foo->meta->has_method('meta'), '... we got the &meta method'); +meta_can_ok('Foo', 'meta', '... we got the &meta method'); ok(Foo->isa('Moose::Object'), '... Foo is automagically a Moose::Object'); -dies_ok { - Foo->meta->has_method() -} '... has_method requires an arg'; +skip_meta { + dies_ok { + Foo->meta->has_method() + } '... has_method requires an arg'; + + dies_ok { + Foo->meta->has_method('') + } '... has_method requires an arg'; +} 2; + can_ok('Foo', 'does'); -foreach my $function (qw( - extends - has - before after around - blessed confess - type subtype as where - coerce from via - find_type_constraint - )) { - ok(!Foo->meta->has_method($function), '... the meta does not treat "' . $function . '" as a method'); -} +skip_meta { + foreach my $function (qw( + extends + has + before after around + blessed confess + type subtype as where + coerce from via + find_type_constraint + )) { + ok(!Foo->meta->has_method($function), '... the meta does not treat "' . $function . '" as a method'); + } +} 15; + foreach my $import (qw( + blessed + try + catch + in_global_destruction + )) { + ok(!Moose::Object->can($import), "no namespace pollution in Moose::Object ($import)" ); + + local $TODO = $import eq 'blessed' ? "no automatic namespace cleaning yet" : undef; + ok(!Foo->can($import), "no namespace pollution in Moose::Object ($import)" ); + } ++ ++done_testing; diff --cc t/020_attributes/004_attribute_triggers.t index 7433b02,974879d..59b417d --- a/t/020_attributes/004_attribute_triggers.t +++ b/t/020_attributes/004_attribute_triggers.t @@@ -3,15 -3,11 +3,15 @@@ use strict; use warnings; +use lib 't/lib'; + use Scalar::Util 'isweak'; - use Test::More tests => 42; + use Test::More tests => 43; use Test::Exception; +use MetaTest; + { diff --cc t/020_attributes/011_more_attr_delegation.t index afa2237,34fdb45..c2053d7 --- a/t/020_attributes/011_more_attr_delegation.t +++ b/t/020_attributes/011_more_attr_delegation.t @@@ -3,13 -3,9 +3,13 @@@ use strict; use warnings; -use Test::More tests => 48; +use lib 't/lib'; + - use Test::More tests => 39; ++use Test::More; use Test::Exception; +use MetaTest; + =pod This tests the more complex @@@ -220,3 -256,6 +261,7 @@@ is( $p->child_e_method_2, "e2", "delega 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 --cc t/030_roles/013_method_aliasing_in_composition.t index 62bb8ff,3f518ee..1153708 --- a/t/030_roles/013_method_aliasing_in_composition.t +++ b/t/030_roles/013_method_aliasing_in_composition.t @@@ -3,12 -3,9 +3,12 @@@ use strict; use warnings; -use Test::More tests => 46; +use lib 't/lib'; + - use Test::More tests => 35; ++use Test::More; use Test::Exception; +use MetaTest; { @@@ -62,11 -57,9 +62,11 @@@ skip_meta 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'); +skip_meta { + 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 not required'); ++ 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'); +} 5; { package My::AliasingRole; @@@ -77,10 -70,8 +77,10 @@@ } '... 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'); +skip_meta { + 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 required'); ++ ok(!My::AliasingRole->meta->requires_method('bar'), '... and the &bar method is not required'); +} 4; { package Foo::Role; @@@ -154,8 -143,72 +154,75 @@@ skip_meta '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'); +skip_meta { + 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'); +} 2; + { + package My::Foo::AliasOnly; + use Moose; + + ::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 Moose::Role; + + sub x1 {} + sub y1 {} + } + + { + package Role::Bar; + use Moose::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 Moose::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 --cc t/050_metaclasses/012_moose_exporter.t index 13293c1,93ec1bb..8e80cee --- a/t/050_metaclasses/012_moose_exporter.t +++ b/t/050_metaclasses/012_moose_exporter.t @@@ -13,7 -8,7 +13,7 @@@ use MetaTest BEGIN { eval "use Test::Output;"; plan skip_all => "Test::Output is required for this test" if $@; - skip_all_meta 47; - plan tests => 65; ++ skip_all_meta 65; } diff --cc t/050_metaclasses/015_metarole.t index e8d6d7b,5cd2dd7..21f2d09 --- a/t/050_metaclasses/015_metarole.t +++ b/t/050_metaclasses/015_metarole.t @@@ -10,10 -10,6 +10,10 @@@ use Test::Exception use Moose::Util::MetaRole; +use MetaTest; + - skip_all_meta 89; ++skip_all_meta 91; + { package My::Meta::Class; diff --cc t/070_native_traits/203_trait_hash.t index 44bc775,a7d77f4..1345a5b --- a/t/070_native_traits/203_trait_hash.t +++ b/t/070_native_traits/203_trait_hash.t @@@ -143,40 -137,39 +141,40 @@@ dies_ok '... bad constructor params'; ## test the meta - -my $options = $stuff->meta->get_attribute('options'); -does_ok( $options, 'Moose::Meta::Attribute::Native::Trait::Hash' ); - -is_deeply( - $options->handles, - { - 'set_option' => 'set', - 'get_option' => 'get', - 'has_no_options' => 'is_empty', - 'num_options' => 'count', - 'clear_options' => 'clear', - 'delete_option' => 'delete', - 'has_option' => 'exists', - 'is_defined' => 'defined', - 'option_accessor' => 'accessor', - 'key_value' => 'kv', - 'options_elements' => 'elements', - 'quantity' => [ accessor => 'quantity' ], - }, - '... got the right handles mapping' -); - -is( $options->type_constraint->type_parameter, 'Str', - '... got the right container type' ); +skip_meta { + my $options = $stuff->meta->get_attribute('options'); + does_ok( $options, 'Moose::Meta::Attribute::Native::Trait::Hash' ); + + is_deeply( + $options->handles, + { + 'set_option' => 'set', + 'get_option' => 'get', - 'has_no_options' => 'empty', ++ 'has_no_options' => 'is_empty', + 'num_options' => 'count', + 'clear_options' => 'clear', + 'delete_option' => 'delete', + 'has_option' => 'exists', + 'is_defined' => 'defined', + 'option_accessor' => 'accessor', + 'key_value' => 'kv', + 'options_elements' => 'elements', + 'quantity' => [ accessor => 'quantity' ], + }, + '... got the right handles mapping' + ); + + is( $options->type_constraint->type_parameter, 'Str', + '... got the right container type' ); +} 3; $stuff->set_option( oink => "blah", xxy => "flop" ); - my @key_value = $stuff->key_value; + my @key_value = sort{ $a->[0] cmp $b->[0] } $stuff->key_value; is_deeply( \@key_value, - [ [ 'xxy', 'flop' ], [ 'quantity', 4 ], [ 'oink', 'blah' ] ], + [ sort{ $a->[0] cmp $b->[0] } [ 'xxy', 'flop' ], [ 'quantity', 4 ], [ 'oink', 'blah' ] ], '... got the right key value pairs' - ); + ) or do{ require Data::Dumper; diag(Data::Dumper::Dumper(\@key_value)) }; my %options_elements = $stuff->options_elements; is_deeply(