a number of changes;
[gitmo/Class-MOP.git] / t / 103_Perl6Attribute_test.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More tests => 10;
7 use File::Spec;
8
9 BEGIN { 
10     use_ok('Class::MOP');    
11     require_ok(File::Spec->catdir('examples', 'Perl6Attribute.pod'));
12 }
13
14 {
15     package Foo;
16     
17     use metaclass;
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;
25         bless $class->meta->construct_instance(@_) => $class;
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 == {}');