| 1 |
#!perl |
| 2 |
|
| 3 |
use strict; |
| 4 |
use warnings; |
| 5 |
use Test::More tests => 6; |
| 6 |
|
| 7 |
use XS::APItest; |
| 8 |
|
| 9 |
my $record = XS::APItest::peep_record; |
| 10 |
my $rrecord = XS::APItest::rpeep_record; |
| 11 |
|
| 12 |
# our peep got called and remembered the string constant |
| 13 |
XS::APItest::peep_enable; |
| 14 |
eval q[my $foo = q/affe/]; |
| 15 |
XS::APItest::peep_disable; |
| 16 |
|
| 17 |
is(scalar @{ $record }, 1); |
| 18 |
is(scalar @{ $rrecord }, 1); |
| 19 |
is($record->[0], 'affe'); |
| 20 |
is($rrecord->[0], 'affe'); |
| 21 |
|
| 22 |
|
| 23 |
# A deep-enough nesting of conditionals defeats the deferring mechanism |
| 24 |
# and triggers recursion. Note that this test is sensitive to the details |
| 25 |
# rpeep: the main thing it is testing is that rpeep is called more than |
| 26 |
# peep, and that all branches are covered; the order of branch calling is |
| 27 |
# less important. |
| 28 |
|
| 29 |
my $code = q[my ($a,$b); $a =]; |
| 30 |
$code .= qq{ \$b ? "foo$_" :} for (1..10); |
| 31 |
$code .= qq{ "foo11" }; |
| 32 |
XS::APItest::peep_enable; |
| 33 |
eval $code; |
| 34 |
XS::APItest::peep_disable; |
| 35 |
|
| 36 |
is_deeply($record, [ "foo11" ]); |
| 37 |
is_deeply($rrecord, [ |
| 38 |
qw(foo1 foo2 foo3 foo4 foo5 foo6 foo10 foo9 foo8 foo7 foo11) ]); |