Commit | Line | Data |
e2f8b029 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | use Test::More tests => 10; |
9ec169fe |
7 | use File::Spec; |
e2f8b029 |
8 | |
9 | BEGIN { |
10 | use_ok('Class::MOP'); |
9ec169fe |
11 | require_ok(File::Spec->catdir('examples', 'Perl6Attribute.pod')); |
e2f8b029 |
12 | } |
13 | |
14 | { |
15 | package Foo; |
16 | |
17 | use Class::MOP 'meta'; |
18 | |
19 | Foo->meta->add_attribute(Perl6Attribute->new('$.foo')); |
20 | Foo->meta->add_attribute(Perl6Attribute->new('@.bar')); |
21 | Foo->meta->add_attribute(Perl6Attribute->new('%.baz')); |
22 | |
23 | sub new { |
24 | my $class = shift; |
d6fbcd05 |
25 | bless $class->meta->construct_instance(@_) => $class; |
e2f8b029 |
26 | } |
27 | } |
28 | |
29 | my $foo = Foo->new(); |
30 | isa_ok($foo, 'Foo'); |
31 | |
32 | can_ok($foo, 'foo'); |
33 | can_ok($foo, 'bar'); |
34 | can_ok($foo, 'baz'); |
35 | |
36 | is($foo->foo, undef, '... Foo.foo == undef'); |
37 | |
38 | $foo->foo(42); |
39 | is($foo->foo, 42, '... Foo.foo == 42'); |
40 | |
41 | is_deeply($foo->bar, [], '... Foo.bar == []'); |
42 | is_deeply($foo->baz, {}, '... Foo.baz == {}'); |