summaryrefslogtreecommitdiff
path: root/t/cmop/rebless_overload.t
blob: c3a7a6824912899042dda370bf5fa15077a2acff (plain)
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
use strict;
use warnings;
use Test::More;
use Class::MOP;

do {
    package Without::Overloading;
    sub new { bless {}, shift }

    package With::Overloading;
    use parent -norequire => 'Without::Overloading';
    use overload q{""} => sub { "overloaded" };
};

my $without = bless {}, "Without::Overloading";
like("$without", qr/^Without::Overloading/, "no overloading");

my $with = With::Overloading->new;
is("$with", "overloaded", "initial overloading works");


my $meta = Class::MOP::Class->initialize('With::Overloading');

$meta->rebless_instance($without);
is("$without", "overloaded", "overloading after reblessing works");

done_testing;