Thread testcase schlägt fehl
(36 answers)
Opened by GwenDragon at 2017-07-19 21:24
Kann mir jemand erklären warum das Testcase fehlschlägt?
Sereal 3.015 Strawberry Perl 5.20.3 x86 Win 10 x64 Code (perl): (dl
)
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 #!/usr/bin/perl use 5.020; use strict; use warnings; use Sereal; use Fcntl ':flock'; my $cachename = 'validator.cache'; my %validator; sub fetch_validator { if ( open my $CACHE, '<', $cachename ) { binmode $CACHE; my $data = <$CACHE>; close $CACHE or die; my $sereal = Sereal::Decoder->new(); if ( $sereal->looks_like_sereal($data) ) { my $VAR1 = $sereal->decode($data); %validator = %{$VAR1}; } else { warn "No SERAL data"; } return %validator; } } sub put_validator { if ( open my $CACHE, '>', $cachename ) { truncate $CACHE, 0; seek $CACHE, 0, 0; flock $CACHE, LOCK_EX; binmode $CACHE; my $sereal = Sereal::Encoder->new(); my $VAR1 = \%validator; my $data = $sereal->encode($VAR1); print $CACHE $data; close $CACHE or die; return %validator; } } use Digest::MD5 qw(md5_hex); for ( 1 .. 1_000 ) { my $d = $_; $validator{ 1000 + $d }{ time + rand $d } = md5_hex(time); put_validator(); fetch_validator(); } ergibt Sereal: Error: Unexpected termination of packet while reading hash contents, insufficient remaining tags for number of keys specified, want 20 bytes, only have 0 available at offset 10 of input at srl_decoder.c line 1003 at ser.pl line 22. Last edited: 2017-07-19 21:42:59 +0200 (CEST) |