File: 306_rebless_overload.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 (27 lines) | stat: -rw-r--r-- 638 bytes parent folder | download | duplicates (2)
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 base '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;