Commit | Line | Data |
---|---|---|
389ecb56 FC |
1 | #!perl |
2 | BEGIN { | |
a817e89d | 3 | chdir 't' if -d 't'; |
9224f6d1 | 4 | @INC = "../lib"; |
389ecb56 FC |
5 | require './test.pl'; |
6 | } | |
7 | ||
8 | use 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 | 15 | plan(6); |
389ecb56 FC |
16 | |
17 | # [perl #116907] | |
18 | # ${\2} to defeat constant folding, which in this case actually slows | |
19 | # things down | |
99a90e59 | 20 | my $x=" "x(${\2}**31) . "abcdefg"; |
389ecb56 FC |
21 | ok $x =~ /./, 'match against long string succeeded'; |
22 | is "$-[0]-$+[0]", '0-1', '@-/@+ after match against long string'; | |
99a90e59 FC |
23 | |
24 | pos $x = 2**31-1; | |
25 | my $result; | |
26 | for(1..5) { | |
27 | $x =~ /./g; | |
28 | $result .= "$&-"; | |
29 | } | |
30 | is $result," -a-b-c-d-", 'scalar //g hopping past the 2**31 threshold'; | |
19394178 FC |
31 | pos $x = 2**31+3; |
32 | $x =~ /./g; | |
33 | is "$'", 'efg', q "$' after match against long string"; | |
a10eae29 FC |
34 | is "$-[0],$+[0]", '2147483651,2147483652', |
35 | '@- and @+ after matches past 2**31'; | |
49f55535 FC |
36 | |
37 | # Substring optimisations | |
38 | is $x =~ /(?:(?:.{32766}){32766}){2}(?:.{32766}){8}.{8}ef/, 1, | |
39 | 'anchored substr past 2**31'; |