Commit | Line | Data |
e2f8b029 |
1 | use strict; |
2 | use warnings; |
3 | |
efd3d14c |
4 | use Test::More tests => 9; |
9ec169fe |
5 | use File::Spec; |
e2f8b029 |
6 | |
efd3d14c |
7 | BEGIN {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 | |
26 | my $foo = Foo->new(); |
27 | isa_ok($foo, 'Foo'); |
28 | |
29 | can_ok($foo, 'foo'); |
30 | can_ok($foo, 'bar'); |
31 | can_ok($foo, 'baz'); |
32 | |
33 | is($foo->foo, undef, '... Foo.foo == undef'); |
34 | |
35 | $foo->foo(42); |
36 | is($foo->foo, 42, '... Foo.foo == 42'); |
37 | |
38 | is_deeply($foo->bar, [], '... Foo.bar == []'); |
39 | is_deeply($foo->baz, {}, '... Foo.baz == {}'); |