Subject: | Document requires Storable support |
Storable freeze + thaw doesn't render identical behavuour.
I've attached the test as we talked about. Gotta run.
#!/usr/bin/perl -w
#
use strict;
use lib ();
use UNIVERSAL 'isa';
use File::Spec::Functions ':ALL';
BEGIN {
$| = 1;
unless ( $ENV{HARNESS_ACTIVE} ) {
require FindBin;
$FindBin::Bin = $FindBin::Bin; # Avoid a warning
chdir catdir( $FindBin::Bin, updir() );
lib->import('blib', 'lib');
}
}
# Load the code to test
use Class::Autouse ':devel';
BEGIN { $PPI::XS_DISABLE = 1 }
use PPI::Document ();
use Storable qw/dclone/;
# Execute the tests
use Test::More tests => 100;
use Scalar::Util 'refaddr';
#####################################################################
# Test freeze/thaw of PPI::Document objects
{
# Create a document with various example package statements
my $Document = PPI::Lexer->lex_source( <<'END_PERL' );
package Foo;
@ISA = (qw/File::Spec/);
1;
END_PERL
isa_ok( $Document, 'PPI::Document' );
print "\nDo it with normally\n";
ok(my $variableIsa = $Document->find_first(sub { $_[1] eq '@ISA'; }), "Found ISA var");
is($variableIsa->parent, q|@ISA = (qw/File::Spec/);|, "Got parent ok");
print "\nDo it with a cloned (freeze+thaw) document\n";
ok(my $CloneDocument = dclone($Document), "dclone ok");
is(ref($CloneDocument), ref($Document), " same class");
ok(my $cloneVariableIsa = $CloneDocument->find_first(sub { $_[1] eq '@ISA'; }), "Found ISA var");
is($cloneVariableIsa->parent, q|@ISA = (qw/File::Spec/);|, "Got parent ok"); # <-- this one fails
}
1;