Converted to Build.PL
[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;
7
8BEGIN {
9 use_ok('Class::MOP');
10 use_ok('examples::Perl6Attribute');
11}
12
13{
14 package Foo;
15
16 use Class::MOP 'meta';
17
18 Foo->meta->add_attribute(Perl6Attribute->new('$.foo'));
19 Foo->meta->add_attribute(Perl6Attribute->new('@.bar'));
20 Foo->meta->add_attribute(Perl6Attribute->new('%.baz'));
21
22 sub new {
23 my $class = shift;
24 bless $class->meta->construct_instance() => $class;
25 }
26}
27
28my $foo = Foo->new();
29isa_ok($foo, 'Foo');
30
31can_ok($foo, 'foo');
32can_ok($foo, 'bar');
33can_ok($foo, 'baz');
34
35is($foo->foo, undef, '... Foo.foo == undef');
36
37$foo->foo(42);
38is($foo->foo, 42, '... Foo.foo == 42');
39
40is_deeply($foo->bar, [], '... Foo.bar == []');
41is_deeply($foo->baz, {}, '... Foo.baz == {}');