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