Perltidy this code a bit.
[gitmo/Moose.git] / t / 010_basics / 013_create.t
CommitLineData
6d5cbd2b 1#!/usr/bin/perl
2
61bdd94f 3use strict;
4use warnings;
6d5cbd2b 5
61bdd94f 6use Test::More tests => 10;
7use Test::Exception;
8
9BEGIN {
10 use_ok('Moose::Meta::Class');
11 use_ok('Moose');
12 use_ok('Moose::Role');
13}
14
15{
16 package Class;
17 use Moose;
18
19 package Foo;
20 use Moose::Role;
21 sub foo_role_applied { 1 }
22
23 package Conflicts::With::Foo;
24 use Moose::Role;
25 sub foo_role_applied { 0 }
26
27 package Not::A::Role;
28 sub lol_wut { 42 }
29}
30
31my $new_class;
32
33lives_ok {
34 $new_class = Moose::Meta::Class->create(
35 'Class::WithFoo',
36 superclasses => ['Class'],
37 roles => ['Foo'],
38 );
39} 'creating lives';
40ok $new_class;
41
42my $with_foo = Class::WithFoo->new;
43
44ok $with_foo->foo_role_applied;
45isa_ok $with_foo, 'Class', '$with_foo';
46
47throws_ok {
48 Moose::Meta::Class->create(
49 'Made::Of::Fail',
50 superclasses => ['Class'],
51 roles => 'Foo', # "oops"
52 );
53} qr/You must pass an ARRAY ref of roles/;
54
55ok !Made::Of::Fail->isa('UNIVERSAL'), "did not create Made::Of::Fail";
56
57dies_ok {
58 Moose::Meta::Class->create(
59 'Continuing::To::Fail',
60 superclasses => ['Class'],
61 roles => ['Foo', 'Conflicts::With::Foo'],
62 );
63} 'conflicting roles == death';
64
65# XXX: Continuing::To::Fail gets created anyway
66