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