Depend on a recent Moose to be compatible with the new meta method api.
[gitmo/MooseX-Emulate-Class-Accessor-Fast.git] / t / adopt.t
CommitLineData
c5a105b3 1#!perl
2use strict;
3use lib 't/lib';
7ed9430a 4use Test::More tests => 13;
c5a105b3 5
6#1,2
7require_ok("MooseX::Adopt::Class::Accessor::Fast");
8use_ok('TestAdoptCAF');
9
10#3-6
11ok(TestAdoptCAF->can('meta'), 'Adopt seems to work');
12ok(TestAdoptCAF->meta->find_attribute_by_name($_), "attribute $_ created")
13 for qw(foo bar baz);
6b8ba79f 14
7ed9430a 15{
16 my $ok = eval {
17 local $SIG{__WARN__} = sub {
18 die "Warning generated when new was called with no arguments: " .
19 join("; ", @_);
20 };
21 TestAdoptCAF->new(());
22 };
23 ok( ref($ok), ref($ok) ? "no warnings when instantiating object" : $@);
24}
6b8ba79f 25#7-9
26my $t = TestAdoptCAF->new(foo => 100, bar => 200, groditi => 300);
27is($t->{foo}, 100, '$self->{foo} set');
28is($t->{bar}, 200, '$self->{bar} set');
29is($t->{groditi}, 300, '$self->{groditi} set');
30
31#10-12
32my $u = TestAdoptCAF->new({foo => 100, bar => 200, groditi => 300});
7ed9430a 33is($u->{foo}, 100, '$self->{foo} set');
34is($u->{bar}, 200, '$self->{bar} set');
35is($u->{groditi}, 300, '$self->{groditi} set');
36