xref: /openbsd/gnu/usr.bin/perl/dist/Data-Dumper/t/huge.t (revision e5dd7070)
1#!./perl -w
2#
3# automated tests for Data::Dumper that need large amounts of memory; they
4# are skipped unless PERL_TEST_MEMORY is set, and at least 10
5#
6
7use strict;
8use warnings;
9
10use Test::More;
11
12use Config;
13use Data::Dumper;
14
15BEGIN {
16    plan skip_all => 'Data::Dumper was not built'
17        if $Config{extensions} !~ m{\b Data/Dumper \b}x;
18    plan skip_all => 'Need 64-bit pointers for this test'
19        if $Config{ptrsize} < 8;
20    plan skip_all => 'Need ~10 GiB of core for this test'
21        if !$ENV{PERL_TEST_MEMORY} || $ENV{PERL_TEST_MEMORY} < 10;
22}
23
24plan tests => 1;
25
26{
27    my $input = q/'/ x 2**31;
28    my $len = length Dumper($input);
29    # Each single-quote will get backslashed, so the output must have
30    # stricly more than twice as many characters as the input.
31    cmp_ok($len, '>', 2**32, 'correct output for huge all-quotable value');
32    undef $input;
33}
34