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
|
#========================================================================
#
# t/codec/storable.t
#
# Test the Badger::Codec::Storable module.
#
# Written by Andy Wardley <abw@wardley.org>
#
# This is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
#========================================================================
use strict;
use warnings;
use lib qw( ./lib ../lib ../../lib );
use Badger::Codec::Storable;
use constant Codec => 'Badger::Codec::Storable';
use Badger::Test
debug => 'Badger::Codec::Storable',
args => \@ARGV;
eval "require Storable";
if ($@) {
skip_all('Storable module not installed');
}
else {
plan(5);
}
my $data = {
pi => 3.14,
e => 2.718,
hash => {
things => [ qw( foo bar baz ) ],
}
};
my $encoded = Codec->encode($data);
ok( $encoded, 'encoded data' );
my $decoded = Codec->decode($encoded);
ok( $decoded, 'decoded data' );
is( $decoded->{ pi }, $data->{ pi }, 'pi remains constant' );
is( $decoded->{ e }, $data->{ e }, 'e remains constant' );
is( $decoded->{ hash }->{ things }->[0], 'foo', 'foo' );
__END__
# Local Variables:
# mode: Perl
# perl-indent-level: 4
# indent-tabs-mode: nil
# End:
#
# vim: expandtab shiftwidth=4:
|