#!/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 => 3;
+use Test::More;
use Test::Exception;
-
{
package My::Custom::Meta::Attr;
use Mouse;
isa_ok($c->meta->get_attribute('bling_bling'), 'My::Custom::Meta::Attr');
-
+done_testing;
#!/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;
use Test::Exception;
-;
-
lives_ok {
package MouseX::Attribute::Test;
use Mouse::Role;
extends 'Mouse::Meta::Attribute';
with 'MouseX::Attribute::Test';
} 'custom attribute metaclass extending role is okay';
+
+done_testing;
--- /dev/null
+#!/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;
+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, 'Mouse::Meta::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, 'Mouse::Meta::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, 'Mouse::Meta::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)');
+}
+
+done_testing;
#!/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 tests => 32;
+use Test::More;
use Test::Exception;
{
'... and error provides a useful explanation' );
}
-
{
package Foo::Subclass;
is( $instance->an_attr, 'value', 'Can get value' );
}
'Can create instance and access attributes';
+
+done_testing;
#!/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 => 4;
+use Test::More;
use Test::Exception;
{
package NoOpTrait;
use Mouse::Role;
-
-
}
{
package Parent;
- use Mouse "-traits" => 'NoOpTrait';
+ use Mouse -traits => 'NoOpTrait';
has attr => (
is => 'rw',
package Child;
use base 'Parent';
}
+
is(Child->meta->name, 'Child', "correct metaclass name");
+
my $child = Child->new(attr => "ibute");
ok($child, "constructor works");
-
is($child->attr, "ibute", "getter inherited properly");
$child->attr("ition");
is($child->attr, "ition", "setter inherited properly");
+
+done_testing;
#!/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 => 5;
+use Test::More;
{
package My::Trait;
ok(!$other_meta->can('enam'), "the method was not installed under the other class' alias");
ok(!$other_meta->can('reversed_name'), "the method was not installed under the original name when that was excluded");
+done_testing;
--- /dev/null
+use lib "t/lib";
+# This is automatically generated by author/import-moose-test.pl.
+# DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
+use t::lib::MooseCompat;
+package MyExporter::User;
+use MyExporter;
+
+use Test::More;
+use Test::Exception;
+{ local $TODO = q{Mouse does not support with_meta option in the exporter};
+lives_and {
+ with_prototype {
+ my $caller = caller(0);
+ is($caller, 'MyExporter', "With_caller prototype code gets called from MyMouseX");
+ };
+} "check function with prototype";
+} # end of TODO
+lives_and {
+ as_is_prototype {
+ my $caller = caller(0);
+ is($caller, 'MyExporter', "As-is prototype code gets called from MyMouseX");
+ };
+} "check function with prototype";
+
+done_testing;
--- /dev/null
+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;
+{
+ package ParentClass;
+ use Mouse;
+}
+{
+ package SomeClass;
+ use base 'ParentClass';
+}
+{
+ package SubClassUseBase;
+ use base qw/SomeClass/;
+ use Mouse;
+}
+
+use Test::More;
+use Test::Exception;
+
+lives_ok {
+ Mouse->init_meta(for_class => 'SomeClass');
+} 'Mouse class => use base => Mouse Class, then Mouse->init_meta on middle class ok';
+
+done_testing;
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;
--- /dev/null
+#!/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;
+
+my $called;
+{
+ package Foo;
+ use Mouse;
+
+ sub BUILD { $called++ }
+}
+
+Foo->new;
+is($called, 1, "BUILD called from ->new");
+$called = 0;
+Foo->meta->new_object;
+is($called, 1, "BUILD called from ->meta->new_object");
+
+done_testing;
--- /dev/null
+#!/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;
+
+{
+ package Foo::Base::Meta::Trait;
+ use Mouse::Role;
+}
+
+{
+ package Foo::Base;
+ use Mouse;
+ Mouse::Util::MetaRole::apply_metaroles(
+ for => __PACKAGE__,
+ class_metaroles => { constructor => ['Foo::Base::Meta::Trait'] },
+ );
+ __PACKAGE__->meta->make_immutable;
+}
+
+{
+ package Foo::Meta::Trait;
+ use Mouse::Role;
+}
+
+{
+ package Foo;
+ use Mouse;
+ Mouse::Util::MetaRole::apply_metaroles(
+ for => __PACKAGE__,
+ class_metaroles => { constructor => ['Foo::Meta::Trait'] }
+ );
+ ::ok(!Foo->meta->is_immutable);
+ extends 'Foo::Base';
+ ::ok(!Foo->meta->is_immutable);
+}
+
+done_testing;
--- /dev/null
+#!/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;
+use Test::Exception;
+
+{
+ package Foo::Meta::Constructor1;
+ use Mouse::Role;
+}
+
+{
+ package Foo::Meta::Constructor2;
+ use Mouse::Role;
+}
+
+{
+ package Foo;
+ use Mouse;
+ Mouse::Util::MetaRole::apply_metaroles(
+ for => __PACKAGE__,
+ class_metaroles => { constructor => ['Foo::Meta::Constructor1'] },
+ );
+}
+
+{
+ package Foo::Sub;
+ use Mouse;
+ Mouse::Util::MetaRole::apply_metaroles(
+ for => __PACKAGE__,
+ class_metaroles => { constructor => ['Foo::Meta::Constructor2'] },
+ );
+ extends 'Foo';
+}
+
+{
+ package Foo::Sub::Sub;
+ use Mouse;
+ Mouse::Util::MetaRole::apply_metaroles(
+ for => __PACKAGE__,
+ class_metaroles => { constructor => ['Foo::Meta::Constructor2'] },
+ );
+ ::lives_ok { extends 'Foo::Sub' } "doesn't try to fix if nothing is needed";
+}
+
+done_testing;