Edgar A. Bering > Test-AskAnExpert > Test::AskAnExpert::Interface

Download:
dists/Test-AskAnExpert-0.03.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1   Source  

NAME ^

Test::AskAnExpert::Interface - the superclass of all Test::AskAnExpert Interfaces

DESCRIPTION ^

Test::AskAnExpert::Interface provides a base class for classes providing an Interface to the testing system, simulating a computer actually answering the Human Intelligent question. Any implementing class should override all of the provided placeholders or else tests will be skipped.

SYNOPSIS ^

  package Test::AskAnExpert::Interface::Implementation;
  use base qw(Test::AskAnExpert::Interface);

  sub load {
    # Do any loading
  }

Methods:

  sub submit {
    # Submit a question
  }

  sub has_answer {
    # See if theres an answer
  }

  sub answer {
    # Go get it
  }

If you have problems, return undef on error and set the error using your inherited err method: SUPER->err("The moon is in the wrong phase");

DETAILS ^

Test::AskAnExpert::Interface is just that, an interface specification. Please fully implement any subclass, otherwise tests will just skip. Except for maybe the constructor, if you don't need to do anything there.

load()

This is your constructor, you may specify any other parameters you like or need to set your interface up, just document them well.

submit($question,$name)

Questions are submitted to the Interface through this method, which recieves a plain text question and a test name. Do whatever magic is necessary to send your question here and return an instance of Test::AskAnExpert::Question with the appropriate and any extra fields you may need populated. Or return undef and set err if you run into problems.

Consult the documentation of Test::AskAnExpert::Question for details on populating it. The provided submit creates one with the skip flag set, you probably don't want this.

answer($question_obj)

This method is used to retrieve an answer and populate it into the $QuestionObj provided. Consult Test::AskAnExpert::Question's documentation on how to do that. It should return true on success and undef on failure. You are allowed to set the skip flag here, its what the default does.

has_answer($Qobj)

This method should return true when there is an answer available for the passed question, but should not modify the object. This is because it is often easier or cheaper to see if the answer is there than to actually go get it. The default just returns true, you probably shouldn't use it.

err([$message])

If there was an error in calling any of the above methods set an error string with this method. Calling err with no arguments returns the current error (if any).

SEE ALSO ^

Test::AskAnExpert, Test::AskAnExpert::Question

AUTHOR ^

Edgar A. Bering, <trizor@cpan.org>

COPYRIGHT AND LICENSE ^

Copyright (C) 2007 by Edgar A. Bering

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic 2.0 liscence as provided in the LICENSE file of this distribution.

syntax highlighting: