This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
amigaos4: no env in main()
[perl5.git] / t / bigmem / index.t
CommitLineData
b464e2b7
TC
1#!perl
2BEGIN {
a817e89d 3 chdir 't' if -d 't';
9224f6d1 4 @INC = "../lib";
b464e2b7
TC
5}
6
7use strict;
8require './test.pl';
9use 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
17plan(tests => 4);
18
19my $space = " "; # avoid constant folding from doubling memory usage
20# concatenation here increases memory usage significantly
21my $work = $space x 0x80000002;
22substr($work, 0x80000000) = "\n\n";
23
24# this would SEGV
25is(index($work, "\n"), 0x80000000, "test index() over 2G mark");
26
27# this would simply fail
28is(rindex($work, "\n"), 0x80000001, "test rindex() over 2G mark");
29
30utf8::upgrade($work);
31
32# this would SEGV
33is(index($work, "\n"), 0x80000000, "test index() over 2G mark (utf8-ish)");
34
35# this would simply fail
36is(rindex($work, "\n"), 0x80000001, "test rindex() over 2G mark (utf8-ish)");
37