| 1 |
#!perl -w |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use Test::More; |
| 6 |
|
| 7 |
use XS::APItest; |
| 8 |
|
| 9 |
my %ix; |
| 10 |
sub showix { |
| 11 |
diag join ", ", map { $ix{$_} > 1 ? "$_ x $ix{$_}" : $_ } sort { $a <=> $b } keys %ix; |
| 12 |
} |
| 13 |
my $len = 100; |
| 14 |
my $str= "a" x $len; |
| 15 |
my $pat= join "|", map { "a" x $_ } 1 .. $len; |
| 16 |
|
| 17 |
$str=~/^($pat)(??{ $ix{get_savestack_ix()}++; "(?!)" })/; |
| 18 |
my $keys= 0+keys %ix; |
| 19 |
cmp_ok($keys,">",0, "We expect at least one key in %ix for (??{ ... }) test"); |
| 20 |
cmp_ok($keys,"<=", 2, "We expect no more than two keys in %ix if (??{ ... }) does not leak") |
| 21 |
or showix(); |
| 22 |
|
| 23 |
%ix= (); |
| 24 |
$str=~/^($pat)(?{ $ix{my $x=get_savestack_ix()}++; })(?!)/; |
| 25 |
$keys= 0+keys %ix; |
| 26 |
cmp_ok($keys,">",0, "We expect at least one key in %ix for (?{ ... }) test"); |
| 27 |
cmp_ok($keys, "<=", 2, "We expect no more than two keys in %ix if (?{ ... }) does not leak") |
| 28 |
or showix(); |
| 29 |
|
| 30 |
%ix= (); |
| 31 |
$str=~/^($pat)(?(?{ $ix{my $x=get_savestack_ix()}++; })x|y)(?!)/; |
| 32 |
$keys= 0+keys %ix; |
| 33 |
cmp_ok($keys,">",0, "We expect at least one key in %ix for (?(?{ ... })yes|no) test"); |
| 34 |
cmp_ok($keys, "<=", 2, "We expect no more than two keys in %ix if (?(?{ ... })yes|no) does not leak") |
| 35 |
or showix(); |
| 36 |
|
| 37 |
done_testing(); |