litle changes, almost ready to ship
[gitmo/MooseX-Emulate-Class-Accessor-Fast.git] / t / adopt.t
1 #!perl
2 use strict;
3 use lib 't/lib';
4 use Test::More tests => 13;
5
6 #1,2
7 require_ok("MooseX::Adopt::Class::Accessor::Fast");
8 use_ok('TestAdoptCAF');
9
10 #3-6
11 ok(TestAdoptCAF->can('meta'), 'Adopt seems to work');
12 ok(TestAdoptCAF->meta->find_attribute_by_name($_), "attribute $_ created")
13   for qw(foo bar baz);
14
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 }
25 #7-9
26 my $t = TestAdoptCAF->new(foo => 100, bar => 200, groditi => 300);
27 is($t->{foo},     100, '$self->{foo} set');
28 is($t->{bar},     200, '$self->{bar} set');
29 is($t->{groditi}, 300, '$self->{groditi} set');
30
31 #10-12
32 my $u = TestAdoptCAF->new({foo => 100, bar => 200, groditi => 300});
33 is($u->{foo},     100, '$self->{foo} set');
34 is($u->{bar},     200, '$self->{bar} set');
35 is($u->{groditi}, 300, '$self->{groditi} set');
36