Merge branch 'master' into method_map_move
[gitmo/Class-MOP.git] / t / 103_Perl6Attribute_test.t
CommitLineData
e2f8b029 1use strict;
2use warnings;
3
efd3d14c 4use Test::More tests => 9;
9ec169fe 5use File::Spec;
e2f8b029 6
efd3d14c 7BEGIN {use Class::MOP;
10dd437b 8 require_ok(File::Spec->catfile('examples', 'Perl6Attribute.pod'));
e2f8b029 9}
10
11{
12 package Foo;
13
c9e77dbb 14 use metaclass;
e2f8b029 15
16 Foo->meta->add_attribute(Perl6Attribute->new('$.foo'));
17 Foo->meta->add_attribute(Perl6Attribute->new('@.bar'));
18 Foo->meta->add_attribute(Perl6Attribute->new('%.baz'));
19
20 sub new {
21 my $class = shift;
5659d76e 22 $class->meta->new_object(@_);
23 }
e2f8b029 24}
25
26my $foo = Foo->new();
27isa_ok($foo, 'Foo');
28
29can_ok($foo, 'foo');
30can_ok($foo, 'bar');
31can_ok($foo, 'baz');
32
33is($foo->foo, undef, '... Foo.foo == undef');
34
35$foo->foo(42);
36is($foo->foo, 42, '... Foo.foo == 42');
37
38is_deeply($foo->bar, [], '... Foo.bar == []');
39is_deeply($foo->baz, {}, '... Foo.baz == {}');