a number of changes;
[gitmo/Class-MOP.git] / t / 103_Perl6Attribute_test.t
CommitLineData
e2f8b029 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More tests => 10;
9ec169fe 7use File::Spec;
e2f8b029 8
9BEGIN {
10 use_ok('Class::MOP');
9ec169fe 11 require_ok(File::Spec->catdir('examples', 'Perl6Attribute.pod'));
e2f8b029 12}
13
14{
15 package Foo;
16
c9e77dbb 17 use metaclass;
e2f8b029 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
29my $foo = Foo->new();
30isa_ok($foo, 'Foo');
31
32can_ok($foo, 'foo');
33can_ok($foo, 'bar');
34can_ok($foo, 'baz');
35
36is($foo->foo, undef, '... Foo.foo == undef');
37
38$foo->foo(42);
39is($foo->foo, 42, '... Foo.foo == 42');
40
41is_deeply($foo->bar, [], '... Foo.bar == []');
42is_deeply($foo->baz, {}, '... Foo.baz == {}');