Test::Smart::Interface::Mock - Mock interface for testing Test::Smart


Test-Smart documentation Contained in the Test-Smart distribution.

Index


Code Index:

NAME

Top

Test::Smart::Interface::Mock - Mock interface for testing Test::Smart

SYNOPSIS

Top

  use Test::Smart;

  initialize('Test::Smart::Interface::Mock',
              answer  => 'always do this',
              comment => 'saying this about it',
              skip    => 'or skip because of this',
              error   => 'or give this error');

  # do some testing here to make sure Test::Smart
  # reacts properly.

DESCRIPTION

Top

This is for internal testing. If you're re-implementing Test::Smart you might find it useful yourself.

AUTHOR

Top

Edgar A. Bering, <trizor@gmail.com>

COPYRIGHT AND LICENSE

Top


Test-Smart documentation Contained in the Test-Smart distribution.
package Test::Smart::Interface::Mock;

use strict;
use warnings;
use base 'Test::Smart::Interface';

sub load {
  my $class = shift;
  my %args = @_;
  my $self = {};

  $self->{_answer} = $args{answer};
  $self->{_comment} = $args{comment};
  $self->{_skip} = $args{skip};
  $self->{_error} = $args{error};

  bless $self,$class;
}

sub submit {
  my ($self,$question,$name) = @_;

  $self->err($self->{_error}), return undef if $self->{_error};
  return Test::Smart::Question->new(question=>$question,
                                    name=>$name,
                                    id=>"id",
                                    skip=>$self->{_skip}) if $self->{_skip};
  return Test::Smart::Question->new(question=>$question,name=>$name,id=>"id");
}

sub has_answer {
  return 1;
}

sub answer {
  my ($self,$Qobj) = @_;

  $self->err($self->{_error}), return undef if $self->{_error};
  $Qobj->answer($self->{_answer},$self->{_comment});
}


1;