NAME
Games::Golf::Entry - Single solution for a golf hole.
SYNOPSIS
use Games::Golf;
my $entry = new Games::Golf::Entry ( "hole.pl" );
$entry->test;
$entry->print_report;
$entry->test_ok or die;
DESCRIPTION
Internal object to be used by Games::Golf
. Each solution represents a single hole.
CONSTRUCTOR
-
Creates a new
Games::Golf::Entry
object. You should pass the path to the file that holds the solution.!!FIXME!! We should pass the hole name in order to know which test suite to apply.
!!FIXME!! Should we pass arguments as an array or as a hash?
!!FIXME!! Maybe we could create another constructor that will accept directly the code to test? Don't sure this is a good idea.
ACCESSORS
- id()
-
Return a unique id of the current entry.
- date_string()
-
Return the date in a human-readable format: yyyy.mm.dd hh::mm::ss
All the following accessors are autoloaded.
-
Full name of the author.
- email()
-
Author's email address.
- hole()
-
The name of the hole this solution solves.
- date()
-
Date of the entry.
- code()
-
The entry's code.
- result()
-
The entry's test result. This is updated by the
ok()
method, which should only be used by thecheck()
method ofGames::Golf::TestSuite
(do I make myself clear?).This structure is an array reference. The first parameter is the total number of tests taken. The second parameters is the number of tests passed. The rest of the array is the list of errors messages.
""
means the test passed. For example:$result = [ 5, # total number of tests taken 3, # number of tests passed "", # ok 1 "", # ok 2 "expected:\n--\n3--\ngot:\n--\n4--\n" # not ok 3 "", # ok 4 ];
- file()
-
Filename of the entry.
METHODS
- score()
-
Compute and return this Entry's score.
- ok( $status, $msg )
-
WARNING: This method should only be used in the
Games::Golf::TestSuite
object.Updates the
result
attribute of theGames::Golf::Entry
object.If the test passed,
$status
should be true (and the message stored will be empty).If the test failed,
$status
should be false, and a message should be given. If no message is given,ok()
will store a default message inresult
. This means that you can be sure that if a message inresult
is true, then the test failed.
BUGS
Please report all bugs to:
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Games-Golf
TODO
Lots of stuff.
AUTHORS
See AUTHORS file for the list of authors.
COPYRIGHT
This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.