This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Upgrade to Tie-RefHash-1.38
[perl5.git] / lib / Tie / RefHash / rebless.t
1 #!/usr/bin/perl -T -w
2
3 BEGIN {
4     if( $ENV{PERL_CORE} ) {
5         chdir 't';
6         @INC = '../lib';
7     }
8 }
9
10 use strict;
11
12 use Tie::RefHash;
13
14 {
15   package Moose;
16   sub new { bless { }, shift };
17
18   package Elk;
19   use vars qw/@ISA/;
20   @ISA = "Moose";
21 }
22
23 $\ = "\n";
24 print "1..2";
25
26 my $obj = Moose->new;
27
28 tie my %hash, "Tie::RefHash";
29
30 $hash{$obj} = "magic";
31
32 print ( ( $hash{$obj} eq "magic" ) ? "" : "not ", "ok - keyed before rebless" );
33
34 bless $obj, "Elk";
35
36 print ( ( $hash{$obj} eq "magic" ) ? "" : "not ", "ok - still the same");