| 1 |
#!perl |
| 2 |
use strict; |
| 3 |
use warnings; |
| 4 |
use Data::Dumper; |
| 5 |
use File::Spec; |
| 6 |
|
| 7 |
use lib File::Spec->catdir(qw(t lib)); |
| 8 |
|
| 9 |
BEGIN { |
| 10 |
lib->import('lib') |
| 11 |
if !-d 't'; |
| 12 |
} |
| 13 |
|
| 14 |
use Sereal::TestSet qw(:all); |
| 15 |
use Test::More; |
| 16 |
|
| 17 |
my $ok = have_encoder_and_decoder(); |
| 18 |
if ( not $ok ) { |
| 19 |
plan skip_all => 'Did not find right version of encoder'; |
| 20 |
} |
| 21 |
else { |
| 22 |
my $e = Sereal::Encoder->new(); |
| 23 |
my $d = Sereal::Decoder->new(); |
| 24 |
|
| 25 |
my $out; |
| 26 |
my $payload = [ 'abcd' x 1024 ]; |
| 27 |
my $ok = eval { $out = $e->encode($payload); 1 }; |
| 28 |
my $err = $@ || 'Zombie error'; |
| 29 |
ok( $ok, "snappy_incr and warn_unknown makes CODE encoding not fail" ); |
| 30 |
|
| 31 |
my $decoded; |
| 32 |
$ok = eval { $decoded = $d->decode($out); 1 }; |
| 33 |
$err = $@ || 'Zombie error'; |
| 34 |
ok( $ok, "snappy_incr and warn_unknown produced decodable output" ) |
| 35 |
or do { |
| 36 |
diag($err); |
| 37 |
hobodecode($out) if $ENV{DEBUG_SEREAL}; |
| 38 |
}; |
| 39 |
|
| 40 |
is_deeply( $decoded, $payload, 'results matches' ); |
| 41 |
} |
| 42 |
|
| 43 |
pass(); |
| 44 |
done_testing(); |
| 45 |
|