in reply to "nmake test" Error...
The mentioned error is because you didn't export doubler. See Exporter for details. First, make it exportable:
our %EXPORT_TAGS = ( 'all' => [ qw( doubler ) ] );
Second, import it. A normal script would import it as follows:
use Integer::Doubler qw( doubler ); -or- use Integer::Doubler qw( :all );
But a test script uses use_ok as follows instead in order to report compile issues in the module more nicely:
BEGIN { use_ok 'Integer::Doubler', qw( doubler ); -or- use_ok 'Integer::Doubler', qw( :all ); }
Finally, I wanted to mention an issue you haven't encountered yet. Don't print from your tests. Use the functions in Test::More instead. You'll use is almost exclusively, using ok only when is isn't sufficient (since is gives more info on failures).
For example,
should beprint "2 * 2 =", doubler(2);
is( doubler(2), 2*2, 'doubler(2)' );
(The last argument is a short description of the test.)
Now that you have two tests (use_ok and is), you need to tell that to the test harness.
use Test::More tests => 2;
|
|---|