Subject: | Data::Visitor::Callback transform: blessed hashref is doubly blessed |
Converting an unblessed hashref into:
bless { val => $hashref }, 'Example'
via Data::Visitor::Callback (hash callback) results in:
bless { val => bless { val => $hashref }, 'Example' }, 'Example'
I've attached two tests. should_fail.t should fail but passes.
should_pass.t should pass but fails.
Tested on perl 5.10.1 (Ubuntu 11.04) with Data::Visitor 0.28.
Thanks,
chocolateboy.
Subject: | data_visitor_callback_should_fail.t |
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dump qw(pp);
use Data::Visitor::Callback;
use Test::More tests => 1;
my $visitor = Data::Visitor::Callback->new(
hash => sub { bless { val => $_ }, 'Example' }
);
my $test = { foo => 'bar' };
my $got = $visitor->visit($test);
my $want = bless { val => { foo => 'bar' } }, 'Example';
$want = bless { val => $want }, 'Example';
is_deeply ($got, $want);
Subject: | data_visitor_callback_should_pass.t |
#!/usr/bin/env perl
use strict;
use warnings;
use Data::Dump qw(pp);
use Data::Visitor::Callback;
use Test::More tests => 1;
my $visitor = Data::Visitor::Callback->new(
hash => sub { bless { val => $_ }, 'Example' }
);
my $test = { foo => 'bar' };
my $got = $visitor->visit($test);
my $want = bless { val => { foo => 'bar' } }, 'Example';
# $want = bless { val => $want }, 'Example';
is_deeply ($got, $want);