This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Merge branch 'release-5.29.2' into blead
[perl5.git] / t / bigmem / regexp.t
CommitLineData
389ecb56
FC
1#!perl
2BEGIN {
a817e89d 3 chdir 't' if -d 't';
9224f6d1 4 @INC = "../lib";
389ecb56
FC
5 require './test.pl';
6}
7
8use Config qw(%Config);
9
10$ENV{PERL_TEST_MEMORY} >= 2
11 or skip_all("Need ~2Gb for this test");
12$Config{ptrsize} >= 8
13 or skip_all("Need 64-bit pointers for this test");
14
49f55535 15plan(6);
389ecb56
FC
16
17# [perl #116907]
18# ${\2} to defeat constant folding, which in this case actually slows
19# things down
99a90e59 20my $x=" "x(${\2}**31) . "abcdefg";
389ecb56
FC
21ok $x =~ /./, 'match against long string succeeded';
22is "$-[0]-$+[0]", '0-1', '@-/@+ after match against long string';
99a90e59
FC
23
24pos $x = 2**31-1;
25my $result;
26for(1..5) {
27 $x =~ /./g;
28 $result .= "$&-";
29}
30is $result," -a-b-c-d-", 'scalar //g hopping past the 2**31 threshold';
19394178
FC
31pos $x = 2**31+3;
32$x =~ /./g;
33is "$'", 'efg', q "$' after match against long string";
a10eae29
FC
34is "$-[0],$+[0]", '2147483651,2147483652',
35 '@- and @+ after matches past 2**31';
49f55535
FC
36
37# Substring optimisations
38is $x =~ /(?:(?:.{32766}){32766}){2}(?:.{32766}){8}.{8}ef/, 1,
39 'anchored substr past 2**31';