1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
|
# -*- cperl -*-
#use strict;
use Test::More;
BEGIN {
eval 'use Storable 1.03';
unless ($@) {
plan tests => 7;
} else {
plan skip_all => "Storable >= 1.03 not installed\n";
}
use Storable qw/freeze thaw/;
}
BEGIN {
use PDL::LiteF;
use PDL::Dbg;
use_ok('PDL::IO::Storable');
}
$a = sequence(2,2);
# $a->dump;
$serialized = freeze $a;
$olda = thaw $serialized;
# $olda->dump;
ok(sum(abs($a-$olda))==0, 'PDL freeze/thaw');
# $oldb = thaw $serialized;
# $oldc = thaw $serialized;
#
# $PDL::Dbg::Infostr = "%T %D %S %A";
# PDL->px;
#
# undef $oldb;
# print $oldc;
undef $a;
$data = {
key1 => 1,
key2 => sequence(3),
key3 => 'hallo',
};
$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';
can_ok($phash, 'freeze');
$pfreeze = $phash->freeze;
$phthaw = thaw $pfreeze;
ok(all($phthaw == $phash), 'PDL has-a works with freeze/thaw');
ok(UNIVERSAL::isa($phthaw,'HASH'), 'PDL is a hash');
|