Commit | Line | Data |
a886a4d6 |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
a28e50e4 |
4 | use Test::More; |
a886a4d6 |
5 | |
6 | { |
7 | package FooTrait; |
8 | use Moose::Role; |
9 | } |
10 | { |
11 | package Foo; |
12 | use Moose -traits => ['FooTrait']; |
13 | } |
14 | |
15 | is(Class::MOP::class_of('Foo'), Foo->meta, |
16 | "class_of and ->meta are the same on Foo"); |
17 | my $meta = Foo->meta; |
18 | is(Class::MOP::class_of($meta), $meta->meta, |
19 | "class_of and ->meta are the same on Foo's metaclass"); |
20 | isa_ok(Class::MOP::class_of($meta), 'Moose::Meta::Class'); |
21 | isa_ok($meta->meta, 'Moose::Meta::Class'); |
b4633c88 |
22 | ok($meta->is_mutable, "class is mutable"); |
23 | ok(Class::MOP::class_of($meta)->is_mutable, "metaclass is mutable"); |
28469dc6 |
24 | ok($meta->meta->does_role('FooTrait'), "does the trait"); |
a886a4d6 |
25 | Foo->meta->make_immutable; |
26 | is(Class::MOP::class_of('Foo'), Foo->meta, |
27 | "class_of and ->meta are the same on Foo (immutable)"); |
28 | $meta = Foo->meta; |
29 | isa_ok($meta->meta, 'Moose::Meta::Class'); |
b4633c88 |
30 | ok($meta->is_immutable, "class is immutable"); |
5d0d2c0b |
31 | ok($meta->meta->is_immutable, "metaclass is immutable (immutable class)"); |
6691b1f8 |
32 | is(Class::MOP::class_of($meta), $meta->meta, |
33 | "class_of and ->meta are the same on Foo's metaclass (immutable)"); |
34 | isa_ok(Class::MOP::class_of($meta), 'Moose::Meta::Class'); |
28469dc6 |
35 | ok($meta->meta->does_role('FooTrait'), "still does the trait after immutable"); |
a28e50e4 |
36 | |
37 | done_testing; |