1#!perl 2 3use strict; 4use warnings; 5use Test::More tests => 6; 6 7use XS::APItest; 8 9my $record = XS::APItest::peep_record; 10my $rrecord = XS::APItest::rpeep_record; 11 12# our peep got called and remembered the string constant 13XS::APItest::peep_enable; 14eval q[my $foo = q/affe/]; 15XS::APItest::peep_disable; 16 17is(scalar @{ $record }, 1); 18is(scalar @{ $rrecord }, 1); 19is($record->[0], 'affe'); 20is($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 29my $code = q[my ($a,$b); $a =]; 30$code .= qq{ \$b ? "foo$_" :} for (1..10); 31$code .= qq{ "foo11" }; 32XS::APItest::peep_enable; 33eval $code; 34XS::APItest::peep_disable; 35 36is_deeply($record, [ "foo11" ]); 37is_deeply($rrecord, [ 38 qw(foo1 foo2 foo3 foo4 foo5 foo6 foo10 foo9 foo8 foo7 foo11) ]); 39