We need to say new -> _new? what's the better way of doing this?
[gitmo/Moose.git] / t / 300_immutable / 014_immutable_metaclass_with_traits.t
1 #!/usr/bin/env perl
2 use strict;
3 use warnings;
4 use Test::More tests => 10;
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');
22 Foo->meta->make_immutable;
23 is(Class::MOP::class_of('Foo'), Foo->meta,
24     "class_of and ->meta are the same on Foo (immutable)");
25 $meta = Foo->meta;
26 isa_ok($meta->meta, 'Moose::Meta::Class');
27 ok(Class::MOP::class_of($meta)->is_immutable, "metaclass is immutable");
28 TODO: {
29     local $TODO = "immutable metaclasses with traits do weird things";
30     is(Class::MOP::class_of($meta), $meta->meta,
31         "class_of and ->meta are the same on Foo's metaclass (immutable)");
32     isa_ok(Class::MOP::class_of($meta), 'Moose::Meta::Class');
33     ok($meta->meta->is_immutable, "metaclass is immutable");
34 }