Add release date
[gitmo/Class-MOP.git] / t / 500_deprecated.t
CommitLineData
30229767 1use strict;
2use warnings;
3
b409c969 4use Test::More tests => 6;
30229767 5use Test::Exception;
6
7use Carp;
8
9$SIG{__WARN__} = \&croak;
10
11{
12 package Foo;
13 use Test::More;
14 use Test::Exception;
15
16 throws_ok {
17 Class::MOP::in_global_destruction();
18 } qr/\b deprecated \b/xmsi, 'complained';
19}
20
21{
22 package Bar;
23 use Test::More;
24 use Test::Exception;
25
26 use Class::MOP::Deprecated -compatible => 0.93;
27
28 throws_ok {
29 Class::MOP::in_global_destruction();
30 } qr/\b deprecated \b/xmsi, 'complained';
31}
32
33{
34 package Baz;
35 use Test::More;
36 use Test::Exception;
37
38 use Class::MOP::Deprecated -compatible => 0.92;
39
40 lives_ok {
41 Class::MOP::in_global_destruction();
42 } 'safe';
43}
44
45
46{
47 package Baz::Inner;
48 use Test::More;
49 use Test::Exception;
50
51 lives_ok {
52 Class::MOP::in_global_destruction();
53 } 'safe in an inner class';
54}
55
b409c969 56{
57 package Quux;
58
59 use Class::MOP::Deprecated -compatible => 0.92;
60 use Scalar::Util qw( blessed );
61
62 use metaclass;
63
64 sub foo {42}
65
66 Quux->meta->add_method( bar => sub {84} );
67
68 my $map = Quux->meta->get_method_map;
69 my @method_objects = grep { blessed($_) } values %{$map};
70
71 ::is( scalar @method_objects, 3,
72 'get_method_map still returns all values as method object' );
73 ::is_deeply( [ sort keys %{$map} ],
74 [ qw( bar foo meta ) ],
75 'get_method_map returns expected methods' );
76}