Data-Undump
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
t/01_undump.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use Test::LongString;
use Data::Undump qw(undump);
use Data::Dumper;
our @dump;
{
local $/="";
while (<DATA>) {
chomp;
push @dump, $_;
}
}
plan tests => 1 + 3 * @dump;
pass();
sub dd { return Data::Dumper->new([$_[0]])->Purity(1)->Useqq(1)->Sortkeys(1)->Dump() }
sub check {
my $dump= shift;
my $undumped= dd(my $struct= undump($dump));
my $show_diag= !is( $@||undef, undef, "after undump \$\@ was false");
my $evaled= dd(eval($dump));
$show_diag += !($dump eq "undef"
? pass("undumping undef")
: isnt($struct, undef, "undump returned something"));
$show_diag += !is_string($undumped,$evaled,"undump and eval agree");
$show_diag and diag($dump);
}
check($_) for @dump;
BEGIN {
@dump= (
" 'foo' ",
' "foo" ',
);
}
__DATA__
1
0
123013.139
-1234.59
0.41
-0.13
123
''
"foo"
'foo'
undef
[]
{}
{ foo => 'bar' }
{ foo => bar => baz => undef }
[ 1 ]
view all matches for this distributionview release on metacpan - search on metacpan
( run in 2.068 seconds using v1.00-cache-2.02-grep-82fe00e-cpan-d29e8ade9f55 )