Skip to content

Commit

Permalink
move "my" to where needed
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Feb 6, 2024
1 parent 3718ad5 commit 3a90dce
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions IO/Storable/t/storable.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,19 @@ use PDL::LiteF;
use PDL::Dbg;
use PDL::IO::Storable;

my ($data,$dfreeze,$dthaw,$oldx,$pfreeze,$phash,$phthaw,$seq1,$seq1_tf,$seq2,$seq2_dc,$serialized);

my $x = sequence(2,2);
# $x->dump;

$serialized = freeze $x;
my $serialized = freeze $x;

$oldx = thaw $serialized;
my $oldx = thaw $serialized;
# $oldx->dump;

is sum(abs($x-$oldx)), 0, 'PDL freeze/thaw';

$x = double '1';
$serialized = freeze $x;
$dthaw = thaw $serialized;
my $dthaw = thaw $serialized;
is $dthaw, $x, 'PDL freeze/thaw of PDL scalar';

# $oldb = thaw $serialized;
Expand All @@ -34,39 +32,39 @@ is $dthaw, $x, 'PDL freeze/thaw of PDL scalar';

undef $x;

$data = {
my $data = {
key1 => 1,
key2 => sequence(3),
key3 => 'hallo',
};

$dfreeze = freeze $data;
my $dfreeze = freeze $data;
$dthaw = thaw $dfreeze;

isa_ok($dthaw, 'HASH'); # we got a HASH back

ok(all($data->{key2} == $dthaw->{key2}), 'PDL in structure');

$phash = bless {PDL => sequence 3}, 'PDL';
my $phash = bless {PDL => sequence 3}, 'PDL';
can_ok($phash, 'freeze');

$pfreeze = $phash->freeze;
$phthaw = thaw $pfreeze;
my $pfreeze = $phash->freeze;
my $phthaw = thaw $pfreeze;

ok(all($phthaw == $phash), 'PDL has-a works with freeze/thaw');
isa_ok($phthaw,'HASH', 'PDL is a hash');

# Test that freeze + thaw results in new object
$seq1 = sequence(3);
$seq1_tf = thaw(freeze($seq1));
my $seq1 = sequence(3);
my $seq1_tf = thaw(freeze($seq1));
$seq1->slice('1') .= 9;
ok(! all($seq1 == $seq1_tf), 'Initialization from seraialized object') or
diag($seq1, $seq1_tf);

# Test that dclone results in a new object
# i.e. that dclone(.) == thaw(freeze(.))
$seq2 = sequence(4);
$seq2_dc = Storable::dclone($seq2);
my $seq2 = sequence(4);
my $seq2_dc = Storable::dclone($seq2);
$seq2->slice('2') .= 8;
ok(! all($seq2 == $seq2_dc), 'Initialization from dclone object') or
diag($seq2, $seq2_dc);
Expand Down

0 comments on commit 3a90dce

Please sign in to comment.