Add test plan, tidy, and add test descriptions
[gitmo/Class-MOP.git] / t / 103_Perl6Attribute_test.t
1 use strict;
2 use warnings;
3
4 use Test::More tests => 9;
5 use File::Spec;
6
7 BEGIN {use Class::MOP;    
8     require_ok(File::Spec->catfile('examples', 'Perl6Attribute.pod'));
9 }
10
11 {
12     package Foo;
13     
14     use metaclass;
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;
22         $class->meta->new_object(@_);
23     }      
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 == {}');