xref: /openbsd-src/gnu/usr.bin/perl/t/bigmem/str.t (revision 5486feefcc8cb79b19e014ab332cc5dfd05b3b33)
1#!perl
2BEGIN {
3    chdir 't' if -d 't';
4    @INC = "../lib";
5    require './test.pl';
6}
7
8use Config qw(%Config);
9
10# 2G each for the $p2g, $n2g and $t
11
12$ENV{PERL_TEST_MEMORY} >= 11
13    or skip_all("Need ~11Gb for this test");
14$Config{ptrsize} >= 8
15    or skip_all("Need 64-bit pointers for this test");
16
17my $p = "A";
18my $n = ~$p;
19
20my $sz = 0x8000_0001;
21
22my $p2g = ($p x $sz);
23
24is(length $p2g, $sz, "check p2g size");
25
26my $t = ($p x $sz);
27ok($t eq $p2g, "check scalar repeat with large count");
28undef $t;
29my $two = 2; # no constant folding
30
31$t = ($p2g x $two);
32ok($t eq "$p2g$p2g", "check scalar repeat with large source");
33undef $t;
34
35$t = ~$p2g;
36my $n2g = ($n x $sz);
37
38is(length $n2g, $sz, "check p2g size");
39
40# don't risk a 4GB diagnostic if they don't match
41ok($t eq $n2g, "string complement very large string");
42
43done_testing();
44
45