Commit | Line | Data |
---|---|---|
b464e2b7 TC |
1 | #!perl |
2 | BEGIN { | |
a817e89d | 3 | chdir 't' if -d 't'; |
9224f6d1 | 4 | @INC = "../lib"; |
b464e2b7 TC |
5 | } |
6 | ||
7 | use strict; | |
8 | require './test.pl'; | |
9 | use Config qw(%Config); | |
10 | ||
11 | # memory usage checked with top | |
12 | $ENV{PERL_TEST_MEMORY} >= 2 | |
13 | or skip_all("Need ~2GB for this test"); | |
14 | $Config{ptrsize} >= 8 | |
15 | or skip_all("Need 64-bit pointers for this test"); | |
16 | ||
17 | plan(tests => 4); | |
18 | ||
19 | my $space = " "; # avoid constant folding from doubling memory usage | |
20 | # concatenation here increases memory usage significantly | |
21 | my $work = $space x 0x80000002; | |
22 | substr($work, 0x80000000) = "\n\n"; | |
23 | ||
24 | # this would SEGV | |
25 | is(index($work, "\n"), 0x80000000, "test index() over 2G mark"); | |
26 | ||
27 | # this would simply fail | |
28 | is(rindex($work, "\n"), 0x80000001, "test rindex() over 2G mark"); | |
29 | ||
30 | utf8::upgrade($work); | |
31 | ||
32 | # this would SEGV | |
33 | is(index($work, "\n"), 0x80000000, "test index() over 2G mark (utf8-ish)"); | |
34 | ||
35 | # this would simply fail | |
36 | is(rindex($work, "\n"), 0x80000001, "test rindex() over 2G mark (utf8-ish)"); | |
37 |