File: 160_recursion.t

package info (click to toggle)
libsereal-decoder-perl 5.004%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 2,556 kB
  • sloc: ansic: 11,615; perl: 6,938; sh: 25; makefile: 9
file content (34 lines) | stat: -rw-r--r-- 654 bytes parent folder | download | duplicates (3)
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
#!perl
use strict;
use warnings;
use Sereal::Decoder qw(decode_sereal);
use Sereal::Decoder::Constants qw(:all);
use File::Spec;

use lib File::Spec->catdir(qw(t lib));

BEGIN {
    lib->import('lib')
        if !-d 't';
}

use Sereal::TestSet qw(:all);

use Test::More;

my $recur_depth= 1000;
my $s= Header();
$s .= chr( SRL_HDR_ARRAYREF + 1 ) for 1 .. $recur_depth;
$s .= integer(1);

my $out= decode_sereal( $s, { max_recursion_depth => $recur_depth + 1 } );
pass("alive");
my $no_exception= eval {
    $out= decode_sereal( $s, { max_recursion_depth => $recur_depth - 1 } );
    1;
};
ok( !$no_exception );

done_testing();
note("All done folks!");