Commit | Line | Data |
38bf2a25 |
1 | use strict; |
2 | use warnings; |
3 | use Test::More; |
4 | use Class::MOP; |
5 | |
6 | do { |
7 | package Without::Overloading; |
8 | sub new { bless {}, shift } |
9 | |
10 | package With::Overloading; |
11 | use base 'Without::Overloading'; |
12 | use overload q{""} => sub { "overloaded" }; |
13 | }; |
14 | |
15 | my $without = bless {}, "Without::Overloading"; |
16 | like("$without", qr/^Without::Overloading/, "no overloading"); |
17 | |
18 | my $with = With::Overloading->new; |
19 | is("$with", "overloaded", "initial overloading works"); |
20 | |
21 | |
22 | my $meta = Class::MOP::Class->initialize('With::Overloading'); |
23 | |
24 | $meta->rebless_instance($without); |
25 | is("$without", "overloaded", "overloading after reblessing works"); |
26 | |
27 | done_testing; |