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/,
+ '... this failed cause of type check';
} 7;
-qr/^Attribute \(type_constrained\) does not pass the type constraint because\: Validation failed for 'Int' failed with value 10\.5/,
-'... this failed cause of type check';
use strict;
use warnings;
+use lib 't/lib';
+
use Scalar::Util 'isweak';
use Test::More tests => 42;
use Test::Exception;
+use MetaTest;
+
{
our @calls;
has foo => (is => 'rw', trigger => sub { push @calls, [@_] });
}
-
+skip_meta {
{
my $attr = Foo->meta->get_attribute('foo');
Foo->meta->make_immutable, redo if Foo->meta->is_mutable;
}
+} 6;
use strict;
use warnings;
-use Test::More tests => 16;
+use lib 't/lib';
+
+use Test::More;
use Test::Exception;
+use MetaTest;
+
+skip_all_meta 16;
{
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 84;
use Test::Exception;
+use MetaTest;
{
}
# check some meta-stuff
-
-ok(Bar->meta->has_attribute('foo'), '... Bar has a foo attr');
-ok(Bar->meta->has_attribute('bar'), '... Bar has a bar attr');
-ok(Bar->meta->has_attribute('baz'), '... Bar has a baz attr');
-ok(Bar->meta->has_attribute('gorch'), '... Bar has a gorch attr');
-ok(Bar->meta->has_attribute('gloum'), '... Bar has a gloum attr');
-ok(Bar->meta->has_attribute('bling'), '... Bar has a bling attr');
-ok(Bar->meta->has_attribute('bunch_of_stuff'), '... Bar does have a bunch_of_stuff attr');
-ok(!Bar->meta->has_attribute('blang'), '... Bar has a blang attr');
-ok(Bar->meta->has_attribute('fail'), '... Bar has a fail attr');
-ok(!Bar->meta->has_attribute('other_fail'), '... Bar does not have an other_fail attr');
-
-isnt(Foo->meta->get_attribute('foo'),
- Bar->meta->get_attribute('foo'),
- '... Foo and Bar have different copies of foo');
-isnt(Foo->meta->get_attribute('bar'),
- Bar->meta->get_attribute('bar'),
- '... Foo and Bar have different copies of bar');
-isnt(Foo->meta->get_attribute('baz'),
- Bar->meta->get_attribute('baz'),
- '... Foo and Bar have different copies of baz');
-isnt(Foo->meta->get_attribute('gorch'),
- Bar->meta->get_attribute('gorch'),
- '... Foo and Bar have different copies of gorch');
-isnt(Foo->meta->get_attribute('gloum'),
- Bar->meta->get_attribute('gloum'),
- '... Foo and Bar have different copies of gloum');
-isnt(Foo->meta->get_attribute('bling'),
- Bar->meta->get_attribute('bling'),
- '... Foo and Bar have different copies of bling');
-isnt(Foo->meta->get_attribute('bunch_of_stuff'),
- Bar->meta->get_attribute('bunch_of_stuff'),
- '... Foo and Bar have different copies of bunch_of_stuff');
-
-ok(Bar->meta->get_attribute('bar')->has_type_constraint,
- '... Bar::bar inherited the type constraint too');
-ok(Bar->meta->get_attribute('baz')->has_type_constraint,
- '... Bar::baz inherited the type constraint too');
-
-is(Bar->meta->get_attribute('bar')->type_constraint->name,
- 'Str', '... Bar::bar inherited the right type constraint too');
-
-is(Foo->meta->get_attribute('baz')->type_constraint->name,
- 'Ref', '... Foo::baz inherited the right type constraint too');
-is(Bar->meta->get_attribute('baz')->type_constraint->name,
- 'ArrayRef', '... Bar::baz inherited the right type constraint too');
-
-ok(!Foo->meta->get_attribute('gorch')->is_required,
- '... Foo::gorch is not a required attr');
-ok(Bar->meta->get_attribute('gorch')->is_required,
- '... Bar::gorch is a required attr');
-
-is(Foo->meta->get_attribute('bunch_of_stuff')->type_constraint->name,
- 'ArrayRef',
- '... Foo::bunch_of_stuff is an ArrayRef');
-is(Bar->meta->get_attribute('bunch_of_stuff')->type_constraint->name,
- 'ArrayRef[Int]',
- '... Bar::bunch_of_stuff is an ArrayRef[Int]');
-
-ok(!Foo->meta->get_attribute('gloum')->is_lazy,
- '... Foo::gloum is not a required attr');
-ok(Bar->meta->get_attribute('gloum')->is_lazy,
- '... Bar::gloum is a required attr');
-
-ok(!Foo->meta->get_attribute('foo')->should_coerce,
- '... Foo::foo should not coerce');
-ok(Bar->meta->get_attribute('foo')->should_coerce,
- '... Bar::foo should coerce');
-
-ok(!Foo->meta->get_attribute('bling')->has_handles,
- '... Foo::foo should not handles');
-ok(Bar->meta->get_attribute('bling')->has_handles,
- '... Bar::foo should handles');
-
+skip_meta {
+ ok(Bar->meta->has_attribute('foo'), '... Bar has a foo attr');
+ ok(Bar->meta->has_attribute('bar'), '... Bar has a bar attr');
+ ok(Bar->meta->has_attribute('baz'), '... Bar has a baz attr');
+ ok(Bar->meta->has_attribute('gorch'), '... Bar has a gorch attr');
+ ok(Bar->meta->has_attribute('gloum'), '... Bar has a gloum attr');
+ ok(Bar->meta->has_attribute('bling'), '... Bar has a bling attr');
+ ok(Bar->meta->has_attribute('bunch_of_stuff'), '... Bar does have a bunch_of_stuff attr');
+ ok(!Bar->meta->has_attribute('blang'), '... Bar has a blang attr');
+ ok(Bar->meta->has_attribute('fail'), '... Bar has a fail attr');
+ ok(!Bar->meta->has_attribute('other_fail'), '... Bar does not have an other_fail attr');
+
+ isnt(Foo->meta->get_attribute('foo'),
+ Bar->meta->get_attribute('foo'),
+ '... Foo and Bar have different copies of foo');
+ isnt(Foo->meta->get_attribute('bar'),
+ Bar->meta->get_attribute('bar'),
+ '... Foo and Bar have different copies of bar');
+ isnt(Foo->meta->get_attribute('baz'),
+ Bar->meta->get_attribute('baz'),
+ '... Foo and Bar have different copies of baz');
+ isnt(Foo->meta->get_attribute('gorch'),
+ Bar->meta->get_attribute('gorch'),
+ '... Foo and Bar have different copies of gorch');
+ isnt(Foo->meta->get_attribute('gloum'),
+ Bar->meta->get_attribute('gloum'),
+ '... Foo and Bar have different copies of gloum');
+ isnt(Foo->meta->get_attribute('bling'),
+ Bar->meta->get_attribute('bling'),
+ '... Foo and Bar have different copies of bling');
+ isnt(Foo->meta->get_attribute('bunch_of_stuff'),
+ Bar->meta->get_attribute('bunch_of_stuff'),
+ '... Foo and Bar have different copies of bunch_of_stuff');
+
+ ok(Bar->meta->get_attribute('bar')->has_type_constraint,
+ '... Bar::bar inherited the type constraint too');
+ ok(Bar->meta->get_attribute('baz')->has_type_constraint,
+ '... Bar::baz inherited the type constraint too');
+
+ is(Bar->meta->get_attribute('bar')->type_constraint->name,
+ 'Str', '... Bar::bar inherited the right type constraint too');
+
+ is(Foo->meta->get_attribute('baz')->type_constraint->name,
+ 'Ref', '... Foo::baz inherited the right type constraint too');
+ is(Bar->meta->get_attribute('baz')->type_constraint->name,
+ 'ArrayRef', '... Bar::baz inherited the right type constraint too');
+
+ ok(!Foo->meta->get_attribute('gorch')->is_required,
+ '... Foo::gorch is not a required attr');
+ ok(Bar->meta->get_attribute('gorch')->is_required,
+ '... Bar::gorch is a required attr');
+
+ is(Foo->meta->get_attribute('bunch_of_stuff')->type_constraint->name,
+ 'ArrayRef',
+ '... Foo::bunch_of_stuff is an ArrayRef');
+ is(Bar->meta->get_attribute('bunch_of_stuff')->type_constraint->name,
+ 'ArrayRef[Int]',
+ '... Bar::bunch_of_stuff is an ArrayRef[Int]');
+
+ ok(!Foo->meta->get_attribute('gloum')->is_lazy,
+ '... Foo::gloum is not a required attr');
+ ok(Bar->meta->get_attribute('gloum')->is_lazy,
+ '... Bar::gloum is a required attr');
+
+ ok(!Foo->meta->get_attribute('foo')->should_coerce,
+ '... Foo::foo should not coerce');
+ ok(Bar->meta->get_attribute('foo')->should_coerce,
+ '... Bar::foo should coerce');
+
+ ok(!Foo->meta->get_attribute('bling')->has_handles,
+ '... Foo::foo should not handles');
+ ok(Bar->meta->get_attribute('bling')->has_handles,
+ '... Bar::foo should handles');
+} 32;
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 92;
use Test::Exception;
+use MetaTest;
# -------------------------------------------------------------------
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, 'Moose::Meta::Method::Delegation');
-is($meth->associated_attribute->name, 'foo',
- 'associated_attribute->name for this method is foo');
-
+skip_meta {
+ my $meth = Bar->meta->get_method('foo_bar');
+ isa_ok($meth, 'Moose::Meta::Method::Delegation');
+ is($meth->associated_attribute->name, 'foo',
+ 'associated_attribute->name for this method is foo');
+} 2;
is($bar->foo->bar, 10, '... bar->foo->bar returned the right default');
can_ok($bar, 'foo_bar');
);
}
my $i = Quux->new;
- ok($i->meta->has_method('foo_bar'), 'handles method foo_bar is present');
- $i->meta->remove_attribute('foo');
- ok(!$i->meta->has_method('foo_bar'), 'handles method foo_bar is removed');
+ skip_meta {
+ ok($i->meta->has_method('foo_bar'), 'handles method foo_bar is present');
+ $i->meta->remove_attribute('foo');
+ ok(!$i->meta->has_method('foo_bar'), 'handles method foo_bar is removed');
+ } 2;
}
# Make sure that a useful error message is thrown when the delegation target is
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 39;
use Test::Exception;
+use MetaTest;
+
=pod
This tests the more complex
can_ok( $p, "child_b_method_1" );
ok( !$p->can("child_b_method_2"), "but not ChildB's unspecified siblings" );
-
+skip_meta {
ok( !$p->can($_), "none of ChildD's methods ($_)" )
for grep { /^child/ } map { $_->name } ChildD->meta->get_all_methods();
+ } 2;
can_ok( $p, "child_c_method_3_la" );
can_ok( $p, "child_c_method_4_la" );
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 47;
use Test::Exception;
+use MetaTest;
{
is => 'bare',
);
}
-
- my $foo_attr = Test::Attribute::Inline::Documentation->meta->get_attribute('foo');
-
- ok($foo_attr->has_documentation, '... the foo has docs');
- is($foo_attr->documentation,
- q{
- The 'foo' attribute is my favorite
- attribute in the whole wide world.
- },
- '... got the foo docs');
+ skip_meta {
+ my $foo_attr = Test::Attribute::Inline::Documentation->meta->get_attribute('foo');
+
+ ok($foo_attr->has_documentation, '... the foo has docs');
+ is($foo_attr->documentation,
+ q{
+ The 'foo' attribute is my favorite
+ attribute in the whole wide world.
+ },
+ '... got the foo docs');
+ } 2;
}
{
has 'foo' => ( required => 1, builder => 'build_foo', is => 'ro');
sub build_foo { return "works" };
}
+ skip_meta {
+ my $meta = Test::Builder::Attribute->meta;
+ my $foo_attr = $meta->get_attribute("foo");
- my $meta = Test::Builder::Attribute->meta;
- my $foo_attr = $meta->get_attribute("foo");
-
- ok($foo_attr->is_required, "foo is required");
- ok($foo_attr->has_builder, "foo has builder");
- is($foo_attr->builder, "build_foo", ".. and it's named build_foo");
+ ok($foo_attr->is_required, "foo is required");
+ ok($foo_attr->has_builder, "foo has builder");
+ is($foo_attr->builder, "build_foo", ".. and it's named build_foo");
- my $instance = Test::Builder::Attribute->new;
- is($instance->foo, 'works', "foo builder works");
+ my $instance = Test::Builder::Attribute->new;
+ is($instance->foo, 'works', "foo builder works");
+ } 4;
}
{
sub _build__foo { return "works too" };
}
- my $meta = Test::LazyBuild::Attribute->meta;
- my $foo_attr = $meta->get_attribute("foo");
- my $_foo_attr = $meta->get_attribute("_foo");
+ skip_meta {
+ my $meta = Test::LazyBuild::Attribute->meta;
+ my $foo_attr = $meta->get_attribute("foo");
+ my $_foo_attr = $meta->get_attribute("_foo");
- ok($foo_attr->is_lazy, "foo is lazy");
- ok($foo_attr->is_lazy_build, "foo is lazy_build");
+ ok($foo_attr->is_lazy, "foo is lazy");
+ ok($foo_attr->is_lazy_build, "foo is lazy_build");
- ok($foo_attr->has_clearer, "foo has clearer");
- is($foo_attr->clearer, "clear_foo", ".. and it's named clear_foo");
+ ok($foo_attr->has_clearer, "foo has clearer");
+ is($foo_attr->clearer, "clear_foo", ".. and it's named clear_foo");
- ok($foo_attr->has_builder, "foo has builder");
- is($foo_attr->builder, "_build_foo", ".. and it's named build_foo");
+ ok($foo_attr->has_builder, "foo has builder");
+ is($foo_attr->builder, "_build_foo", ".. and it's named build_foo");
- ok($foo_attr->has_predicate, "foo has predicate");
- is($foo_attr->predicate, "has_foo", ".. and it's named has_foo");
+ ok($foo_attr->has_predicate, "foo has predicate");
+ is($foo_attr->predicate, "has_foo", ".. and it's named has_foo");
- ok($_foo_attr->is_lazy, "_foo is lazy");
- ok(!$_foo_attr->is_required, "lazy_build attributes are no longer automatically required");
- ok($_foo_attr->is_lazy_build, "_foo is lazy_build");
+ ok($_foo_attr->is_lazy, "_foo is lazy");
+ ok(!$_foo_attr->is_required, "lazy_build attributes are no longer automatically required");
+ ok($_foo_attr->is_lazy_build, "_foo is lazy_build");
- ok($_foo_attr->has_clearer, "_foo has clearer");
- is($_foo_attr->clearer, "_clear_foo", ".. and it's named _clear_foo");
+ ok($_foo_attr->has_clearer, "_foo has clearer");
+ is($_foo_attr->clearer, "_clear_foo", ".. and it's named _clear_foo");
- ok($_foo_attr->has_builder, "_foo has builder");
- is($_foo_attr->builder, "_build__foo", ".. and it's named _build_foo");
+ ok($_foo_attr->has_builder, "_foo has builder");
+ is($_foo_attr->builder, "_build__foo", ".. and it's named _build_foo");
- ok($_foo_attr->has_predicate, "_foo has predicate");
- is($_foo_attr->predicate, "_has_foo", ".. and it's named _has_foo");
+ ok($_foo_attr->has_predicate, "_foo has predicate");
+ is($_foo_attr->predicate, "_has_foo", ".. and it's named _has_foo");
+ } 17;
my $instance = Test::LazyBuild::Attribute->new;
ok(!$instance->has_foo, "noo foo value yet");
lives_ok { OutOfClassTest::has('foo', is => 'bare'); } 'create attr via direct sub call';
lives_ok { OutOfClassTest->can('has')->('bar', is => 'bare'); } 'create attr via can';
-
-ok(OutOfClassTest->meta->get_attribute('foo'), 'attr created from sub call');
-ok(OutOfClassTest->meta->get_attribute('bar'), 'attr created from can');
-
+skip_meta {
+ ok(OutOfClassTest->meta->get_attribute('foo'), 'attr created from sub call');
+ ok(OutOfClassTest->meta->get_attribute('bar'), 'attr created from can');
+} 2;
{
{
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 12;
use Test::Exception;
use Test::Moose;
+use MetaTest;
{
can_ok($c, 'baz');
is($c->baz, 100, '... got the right value for baz');
-my $bar_attr = $c->meta->get_attribute('bar');
-does_ok($bar_attr, 'My::Attribute::Trait');
-ok($bar_attr->has_applied_traits, '... got the applied traits');
-is_deeply($bar_attr->applied_traits, [qw/My::Attribute::Trait/], '... got the applied traits');
-is($bar_attr->foo, "blah", "attr initialized");
-
-my $gorch_attr = $c->meta->get_attribute('gorch');
-ok(!$gorch_attr->does('My::Attribute::Trait'), '... gorch doesnt do the trait');
-ok(!$gorch_attr->has_applied_traits, '... no traits applied');
-is($gorch_attr->applied_traits, undef, '... no traits applied');
-
+skip_meta {
+ my $bar_attr = $c->meta->get_attribute('bar');
+ does_ok($bar_attr, 'My::Attribute::Trait');
+ ok($bar_attr->has_applied_traits, '... got the applied traits');
+ is_deeply($bar_attr->applied_traits, [qw/My::Attribute::Trait/], '... got the applied traits');
+ is($bar_attr->foo, "blah", "attr initialized");
+
+ my $gorch_attr = $c->meta->get_attribute('gorch');
+ ok(!$gorch_attr->does('My::Attribute::Trait'), '... gorch doesnt do the trait');
+ ok(!$gorch_attr->has_applied_traits, '... no traits applied');
+ is($gorch_attr->applied_traits, undef, '... no traits applied');
+} 7;
use strict;
use warnings;
+use lib 't/lib';
+
use Test::More tests => 23;
use Test::Exception;
use Test::Moose;
+use MetaTest;
{
can_ok($c, 'baz') and
is($c->baz, 100, '... got the right value for baz');
-my $bar_attr = $c->meta->get_attribute('bar');
-does_ok($bar_attr, 'My::Attribute::Trait');
-is($bar_attr->foo, "blah", "attr initialized");
-
-ok(!$bar_attr->meta->does_role('Aliased'), "does_role ignores aliases for sanity");
-ok($bar_attr->does('Aliased'), "attr->does uses aliases");
-ok(!$bar_attr->meta->does_role('Fictional'), "does_role returns false for nonexistent roles");
-ok(!$bar_attr->does('Fictional'), "attr->does returns false for nonexistent roles");
+skip_meta {
+ my $bar_attr = $c->meta->get_attribute('bar');
+ does_ok($bar_attr, 'My::Attribute::Trait');
+ is($bar_attr->foo, "blah", "attr initialized");
+ ok(!$bar_attr->meta->does_role('Aliased'), "does_role ignores aliases for sanity");
+ ok($bar_attr->does('Aliased'), "attr->does uses aliases");
+ ok(!$bar_attr->meta->does_role('Fictional'), "does_role returns false for nonexistent roles");
+ ok(!$bar_attr->does('Fictional'), "attr->does returns false for nonexistent roles");
+} 6;
my $quux = My::Derived::Class->new(bar => 1000);
is($quux->bar, 1000, '... got the right value for bar');
can_ok($quux, 'baz');
is($quux->baz, 1000, '... got the right value for baz');
-my $derived_bar_attr = $quux->meta->get_attribute("bar");
-does_ok($derived_bar_attr, 'My::Attribute::Trait' );
-
-is( $derived_bar_attr->foo, "blah", "attr initialized" );
+skip_meta {
+ my $derived_bar_attr = $quux->meta->get_attribute("bar");
+ does_ok($derived_bar_attr, 'My::Attribute::Trait' );
-does_ok($derived_bar_attr, 'My::Other::Attribute::Trait' );
+ is( $derived_bar_attr->foo, "blah", "attr initialized" );
-is($derived_bar_attr->the_other_attr, "oink", "attr initialized" );
+ does_ok($derived_bar_attr, 'My::Other::Attribute::Trait' );
-ok(!$derived_bar_attr->meta->does_role('Aliased'), "does_role ignores aliases for sanity");
-ok($derived_bar_attr->does('Aliased'), "attr->does uses aliases");
-ok(!$derived_bar_attr->meta->does_role('Fictional'), "does_role returns false for nonexistent roles");
-ok(!$derived_bar_attr->does('Fictional'), "attr->does returns false for nonexistent roles");
+ is($derived_bar_attr->the_other_attr, "oink", "attr initialized" );
+ ok(!$derived_bar_attr->meta->does_role('Aliased'), "does_role ignores aliases for sanity");
+ ok($derived_bar_attr->does('Aliased'), "attr->does uses aliases");
+ ok(!$derived_bar_attr->meta->does_role('Fictional'), "does_role returns false for nonexistent roles");
+ ok(!$derived_bar_attr->does('Fictional'), "attr->does returns false for nonexistent roles");
+} 8;
can_ok($quux, 'additional_method');
is(eval { $quux->additional_method }, 42, '... got the right value for additional_method');
use strict;
use warnings;
-use Test::More tests => 7;
+use lib 't/lib';
+
+use Test::More;
use Test::Exception;
use Test::Moose;
+use MetaTest;
+
+skip_all_meta 7;
{
use strict;
use warnings;
-use Test::More tests => 2;
+use lib 't/lib';
+use Test::More;
+
+use MetaTest;
+
+skip_all_meta 2;
{
package Bar::Meta::Attribute;
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 5;
+
+use lib 't/lib';
+
+use Test::More;
+
+use MetaTest;
+
+skip_all_meta 5;
{
package My::Attribute::Trait;
use strict;
use warnings;
-use Test::More tests => 2;
+use lib 't/lib';
+
+use Test::More;
use Moose ();
use Moose::Meta::Class;
+use MetaTest;
+
+skip_all_meta 2;
+
my $meta = Moose::Meta::Class->create('Banana');
my $warn;
#!/usr/bin/env perl
use strict;
use warnings;
+
+use lib 't/lib';
+
use Test::More;
+use MetaTest;
+
BEGIN {
eval "use Test::Output;";
plan skip_all => "Test::Output is required for this test" if $@;
- plan tests => 5;
+ skip_all_meta 5;
}
{