use strict;
use warnings;
-use Test::More tests => 4;
-use Test::Exception;
+use Test::More;
+use Test::Fatal;
use Carp;
{
package Foo;
- use Test::More;
- use Test::Exception;
- throws_ok {
+ ::like( ::exception {
Class::MOP::in_global_destruction();
- } qr/\b deprecated \b/xmsi, 'complained';
+ }, qr/\b deprecated \b/xmsi, 'Class::MOP::in_global_destruction is deprecated' );
}
{
package Bar;
- use Test::More;
- use Test::Exception;
- use Class::MOP::Deprecated -compatible => 0.93;
+ use Class::MOP::Deprecated -api_version => 0.93;
- throws_ok {
+ ::like( ::exception {
Class::MOP::in_global_destruction();
- } qr/\b deprecated \b/xmsi, 'complained';
+ }, qr/\b deprecated \b/xmsi, 'Class::MOP::in_global_destruction is deprecated with 0.93 compatibility' );
}
{
package Baz;
- use Test::More;
- use Test::Exception;
- use Class::MOP::Deprecated -compatible => 0.92;
+ use Class::MOP::Deprecated -api_version => 0.92;
- lives_ok {
+ ::is( ::exception {
Class::MOP::in_global_destruction();
- } 'safe';
+ }, undef, 'Class::MOP::in_global_destruction is not deprecated with 0.92 compatibility' );
}
+{
+ package Foo2;
+
+ use metaclass;
+
+ ::like( ::exception { Foo2->meta->get_attribute_map }, qr/\Qget_attribute_map method has been deprecated/, 'get_attribute_map is deprecated' );
+}
{
- package Baz::Inner;
- use Test::More;
- use Test::Exception;
+ package Quux;
- lives_ok {
- Class::MOP::in_global_destruction();
- } 'safe in an inner class';
+ 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;