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,

print "2 * 2 =", doubler(2);
should be
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;

In reply to Re: "nmake test" Error... by ikegami
in thread "nmake test" Error... by biohisham

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.