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