File: 049_metaclass_reinitialize.t

package info (click to toggle)
libclass-mop-perl 1.04-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 1,244 kB
  • ctags: 1,272
  • sloc: perl: 5,192; ansic: 241; makefile: 2
file content (43 lines) | stat: -rw-r--r-- 785 bytes parent folder | download
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
37
38
39
40
41
42
43
use strict;
use warnings;

use Test::More;
use Test::Exception;

{
    package Foo;
    use metaclass;
    sub foo {}
}

sub check_meta_sanity {
    my ($meta) = @_;
    isa_ok($meta, 'Class::MOP::Class');
    is($meta->name, 'Foo');
    ok($meta->has_method('foo'));
}

can_ok('Foo', 'meta');

my $meta = Foo->meta;
check_meta_sanity($meta);

lives_ok {
    $meta = $meta->reinitialize($meta->name);
};
check_meta_sanity($meta);

lives_ok {
    $meta = $meta->reinitialize($meta);
};
check_meta_sanity($meta);

throws_ok {
    $meta->reinitialize('');
} qr/You must pass a package name or an existing Class::MOP::Package instance/;

throws_ok {
    $meta->reinitialize($meta->new_object);
} qr/You must pass a package name or an existing Class::MOP::Package instance/;

done_testing;