Kalle Hallivuori > Test-CallFlow > Test::CallFlow::ArgCheck

Download:
Test-CallFlow-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

New  7
Open  0
View/Report Bugs
Source  

NAME ^

Test::CallFlow::ArgCheck

SYNOPSIS ^

Abstract base class for mock call argument checkers. Implementors should only need to implement check() below.

  my $checker = Test::CallFlow::ArgCheck::Regexp->new( test => qr/../, max => 9 );
  my @args = qw(abc ab a abcd);
  my $at = 0;
  $at = $checker->skip_matching( $at, \@args );
  "@args[$at,]" eq "a abcd" or die "checker failed";

PROPERTIES ^

  test  whatever child class check() method uses to validate an argument
  min   minimum number of matches, 0 means optional, default 1
  max   maximum number of matches, default same as min.

FUNCTIONS ^

new

  my $checker = Test::CallFlow::ArgCheck::SUBCLASS->new( $test, $min, $max );

or

  my $checker = Test::CallFlow::ArgCheck::SUBCLASS->new( 
        test => 'whatever SUBCLASS::check() tests an argument against',
        min => 0,
        max => 999, 
  );

check

  $checker->check( $at, \@args ) ? 1 : undef;

Should be implemented in an inherited class to return a boolean result of comparing a single argument against value of test property.

skip_matching

  die "Mismatch at $at" unless defined
    $at = $checker->skip_matching( $at, \@args );

If arguments on beginning of given list match requirements (test, range) of this checker, new index is returned.

Otherwise returns -1 - position of failed argument.

syntax highlighting: