File: rebless_overload.t

package info (click to toggle)
libmoose-perl 2.2207-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 7,416 kB
  • sloc: perl: 21,345; ansic: 291; makefile: 10
file content (27 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (7)
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;