File: 500_deprecated.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 (78 lines) | stat: -rwxr-xr-x 1,545 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use strict;
use warnings;

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

use Carp;

$SIG{__WARN__} = \&croak;

{
    package Foo;

    ::throws_ok{
        Class::MOP::in_global_destruction();
        } qr/\b deprecated \b/xmsi,
        'Class::MOP::in_global_destruction is deprecated';
}

{
    package Bar;

    use Class::MOP::Deprecated -api_version => 0.93;

    ::throws_ok{
        Class::MOP::in_global_destruction();
        } qr/\b deprecated \b/xmsi,
        'Class::MOP::in_global_destruction is deprecated with 0.93 compatibility';
}

{
    package Baz;

    use Class::MOP::Deprecated -api_version => 0.92;

    ::lives_ok{
        Class::MOP::in_global_destruction();
        }
        'Class::MOP::in_global_destruction is not deprecated with 0.92 compatibility';
}

{
    package Foo2;

    use metaclass;

    ::throws_ok{ Foo2->meta->get_attribute_map }
        qr/\Qget_attribute_map method has been deprecated/,
        'get_attribute_map is deprecated';
}

{
    package Quux;

    use Class::MOP::Deprecated -api_version => 0.92;
    use Scalar::Util qw( blessed );

    use metaclass;

    sub foo {42}

    Quux->meta->add_method( bar => sub {84} );

    my $map = Quux->meta->get_method_map;
    my @method_objects = grep { blessed($_) } values %{$map};

    ::is(
        scalar @method_objects, 3,
        'get_method_map still returns all values as method object'
    );
    ::is_deeply(
        [ sort keys %{$map} ],
        [qw( bar foo meta )],
        'get_method_map returns expected methods'
    );
}

done_testing;