37e340cd0c3b3428a6fbeb95f742be88a4903034
[gitmo/Moose.git] / t / 050_metaclasses / 019_create_anon_with_required_attr.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 3;
7 use Test::Exception;
8
9 {
10     package HasFoo;
11     use Moose::Role;
12     has 'foo' => (
13         is       => 'ro',
14         isa      => 'Str',
15         required => 1,
16     );
17
18 }
19
20 {
21     package My::Metaclass;
22     use Moose;
23     extends 'Moose::Meta::Class';
24     with 'HasFoo';
25 }
26
27 package main;
28
29 my $anon;
30 lives_ok {
31     $anon = My::Metaclass->create_anon_class( foo => 'this' );
32 } 'create anon class';
33 isa_ok( $anon, 'My::Metaclass' );
34 cmp_ok( $anon->foo, 'eq', 'this', 'foo is this' );
35