Test::Resub

Test::Resub is a lexically scoped subroutine replacement for testing.
Download

Test::Resub Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • AirWave Wireless
  • Publisher web site:
  • http://search.cpan.org/~airwave/Test-Resub-1.02/lib/Test/Resub.pm

Test::Resub Tags


Test::Resub Description

Test::Resub is a lexically scoped subroutine replacement for testing. Test::Resub is a lexically scoped subroutine replacement for testing.SYNOPSIS #!/usr/bin/perl use Test::More tests => 4; use Test::Resub qw(resub); { package Somewhere; sub show { my ($class, $message) = @_; return "$class, $message"; } } # sanity is( Somewhere->show('beyond the sea'), 'Somewhere, beyond the sea' ); # scoped replacement of subroutine with argument capturing { my $rs = resub 'Somewhere::show', sub { 'hi' }, capture => 1; is( Somewhere->show('over the rainbow'), 'hi' ); is_deeply( $rs->method_args, ] ); } # scope ends, resub goes away, original code returns is( Somewhere->show('waiting for me'), 'Somewhere, waiting for me' );This module allows you to temporarily replace a subroutine/method with arbitrary code. Later, you can tell how many times was it called and with what arguments each time. You can also specify that the subroutine/method must get called, must not get called, or may be optionally called. Requirements: · Perl


Test::Resub Related Software