1use Test::More tests => 7; 2 3BEGIN { 4 if ($ENV{PERL_CORE}) { 5 chdir('t') if -d 't'; 6 @INC = qw(../lib); 7 } 8} 9 10BEGIN { use_ok('NEXT') }; 11 12package A; 13use base qw(B); 14use NEXT; 15sub test_next { shift->NEXT::test_next(@_); } 16sub test_next_distinct { shift->NEXT::DISTINCT::test_next_distinct(@_); } 17sub test_next_actual { shift->NEXT::ACTUAL::test_next_actual(@_); } 18sub test_next_actual_distinct { shift->NEXT::ACTUAL::DISTINCT::test_next_actual_distinct(@_); } 19sub test_every { shift->EVERY::test_every(@_); } 20sub test_every_last { shift->EVERY::LAST::test_every_last(@_); } 21 22package B; 23sub test_next { $_[1]; } 24sub test_next_distinct { $_[1]; } 25sub test_next_actual { $_[1]; } 26sub test_next_actual_distinct { $_[1]; } 27sub test_every { $_[1]; } 28sub test_every_last { $_[1]; } 29 30package main; 31 32my $foo = bless {}, 'A'; 33 34"42" =~ /(.*)/; 35is($foo->test_next($&), $&, "The value of '\$&' was not overwritten in NEXT."); 36 37"42" =~ /(.*)/; 38is($foo->test_next_distinct($&), $&, "The value of '\$&' was not overwritten in NEXT::DISTINCT."); 39 40"42" =~ /(.*)/; 41is($foo->test_next_actual($&), $&, "The value of '\$&' was not overwritten in NEXT::ACTUAL."); 42 43"42" =~ /(.*)/; 44is($foo->test_next_actual_distinct($&), $&, "The value of '\$&' was not overwritten in NEXT::ACTUAL::DISTINCT."); 45 46"42" =~ /(.*)/; 47is($foo->test_every($&)->{'B::test_every'}, $&, "The value of '\$&' was not overwritten in EVERY."); 48 49"42" =~ /(.*)/; 50is($foo->test_every_last($&)->{'B::test_every_last'}, $&, "The value of '\$&' was not overwritten in EVERY::LAST."); 51