2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
15 This test demonstrates the ability to extend
16 Mouse meta-level classes using Mouse itself.
21 package My::Meta::Class;
24 extends 'Mouse::Meta::Class';
26 around 'create_anon_class' => sub {
28 my ($self, %options) = @_;
29 $options{superclasses} = [ 'Mouse::Object' ]
30 unless exists $options{superclasses};
31 $next->($self, %options);
35 my $anon = My::Meta::Class->create_anon_class();
36 isa_ok($anon, 'My::Meta::Class');
37 isa_ok($anon, 'Mouse::Meta::Class');
38 isa_ok($anon, 'Mouse::Meta::Class');
41 [ $anon->superclasses ],
43 '... got the default superclasses');
46 package My::Meta::Attribute::DefaultReadOnly;
49 extends 'Mouse::Meta::Attribute';
53 my ($self, $name, %options) = @_;
55 unless exists $options{is};
56 $next->($self, $name, %options);
61 my $attr = My::Meta::Attribute::DefaultReadOnly->new('foo');
62 isa_ok($attr, 'My::Meta::Attribute::DefaultReadOnly');
63 isa_ok($attr, 'Mouse::Meta::Attribute');
64 isa_ok($attr, 'Mouse::Meta::Attribute');
66 ok($attr->has_reader, '... the attribute has a reader (as expected)');
67 ok(!$attr->has_writer, '... the attribute does not have a writer (as expected)');
68 ok(!$attr->has_accessor, '... the attribute does not have an accessor (as expected)');
72 my $attr = My::Meta::Attribute::DefaultReadOnly->new('foo', (is => 'rw'));
73 isa_ok($attr, 'My::Meta::Attribute::DefaultReadOnly');
74 isa_ok($attr, 'Mouse::Meta::Attribute');
75 isa_ok($attr, 'Mouse::Meta::Attribute');
77 ok(!$attr->has_reader, '... the attribute does not have a reader (as expected)');
78 ok(!$attr->has_writer, '... the attribute does not have a writer (as expected)');
79 ok($attr->has_accessor, '... the attribute does have an accessor (as expected)');