This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/op/inc.t: Test incrementing UV with and without upgrading to NV.
[perl5.git] / t / bigmem / regexp.t
1 #!perl
2 BEGIN {
3     chdir 't' if -d 't';
4     @INC = "../lib";
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
15 plan(6);
16
17 # [perl #116907]
18 # ${\2} to defeat constant folding, which in this case actually slows
19 # things down
20 my $x=" "x(${\2}**31) . "abcdefg";
21 ok $x =~ /./, 'match against long string succeeded';
22 is "$-[0]-$+[0]", '0-1', '@-/@+ after match against long string';
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';
31 pos $x = 2**31+3;
32 $x =~ /./g;
33 is "$'", 'efg', q "$' after match against long string";
34 is "$-[0],$+[0]", '2147483651,2147483652',
35    '@- and @+ after matches past 2**31';
36
37 # Substring optimisations
38 is $x =~ /(?:(?:.{32766}){32766}){2}(?:.{32766}){8}.{8}ef/, 1,
39   'anchored substr past 2**31';