File: adopt.t

package info (click to toggle)
libmoosex-emulate-class-accessor-fast-perl 0.009032-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 172 kB
  • sloc: perl: 224; makefile: 2
file content (36 lines) | stat: -rw-r--r-- 1,000 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use strict;
use warnings;
use lib 't/lib';
use Test::More tests => 13;

#1,2
require_ok("MooseX::Adopt::Class::Accessor::Fast");
use_ok('TestAdoptCAF');

#3-6
ok(TestAdoptCAF->can('meta'), 'Adopt seems to work');
ok(TestAdoptCAF->meta->find_attribute_by_name($_), "attribute $_ created")
  for qw(foo bar baz);

{
  my $ok = eval {
    local $SIG{__WARN__} = sub { 
      die "Warning generated when new was called with no arguments: " . 
        join("; ", @_);
    };
    TestAdoptCAF->new(());
  };
  ok( ref($ok), ref($ok) ? "no warnings when instantiating object" : $@);
}
#7-9
my $t = TestAdoptCAF->new(foo => 100, bar => 200, groditi => 300);
is($t->{foo},     100, '$self->{foo} set');
is($t->{bar},     200, '$self->{bar} set');
is($t->{groditi}, 300, '$self->{groditi} set');

#10-12
my $u = TestAdoptCAF->new({foo => 100, bar => 200, groditi => 300});
is($u->{foo},     100, '$self->{foo} set');
is($u->{bar},     200, '$self->{bar} set');
is($u->{groditi}, 300, '$self->{groditi} set');