File: regexp.t

package info (click to toggle)
perl 5.20.2-3%2Bdeb8u11
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 102,964 kB
  • sloc: perl: 555,553; ansic: 214,041; sh: 38,121; pascal: 8,783; cpp: 3,895; makefile: 2,393; xml: 2,325; yacc: 1,741
file content (39 lines) | stat: -rw-r--r-- 973 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!perl
BEGIN {
    chdir 't';
    unshift @INC, "../lib";
    require './test.pl';
}

use Config qw(%Config);

$ENV{PERL_TEST_MEMORY} >= 2
    or skip_all("Need ~2Gb for this test");
$Config{ptrsize} >= 8
    or skip_all("Need 64-bit pointers for this test");

plan(6);

# [perl #116907]
# ${\2} to defeat constant folding, which in this case actually slows
# things down
my $x=" "x(${\2}**31) . "abcdefg";
ok $x =~ /./, 'match against long string succeeded';
is "$-[0]-$+[0]", '0-1', '@-/@+ after match against long string';

pos $x = 2**31-1;
my $result;
for(1..5) {
    $x =~ /./g;
    $result .= "$&-";
}
is $result," -a-b-c-d-", 'scalar //g hopping past the 2**31 threshold';
pos $x = 2**31+3;
$x =~ /./g;
is "$'", 'efg', q "$' after match against long string";
is "$-[0],$+[0]", '2147483651,2147483652',
   '@- and @+ after matches past 2**31';

# Substring optimisations
is $x =~ /(?:(?:.{32766}){32766}){2}(?:.{32766}){8}.{8}ef/, 1,
  'anchored substr past 2**31';