I appreciate your effort but this is my confusion: The script works correctly at the command line and does not issue any warnings, despite use of the strict and warnings pragmas enabled. It is only when I try to run it using automated test tools do those warnings arise.

Example: If I simply call reduce with 1 argument at the command line, it will be pushed onto the @answer array and returned.

This tells me that the instantiation errors are in the way the test code interfaces with the code under test. I don't understand why the arguments aren't being passed to the appropriate subroutine.

If I attempt to pass a list of scalar arguments in the test code, I get syntax errors when I run:

perl -c test_file.t

Also:

  • 1. What should I be doing in the return statements of this particular subroutine so they are easier to test?
  • 2. Should I be testing the subroutine individually, or indirectly accessing the sub through a call to main, as it appears to be done in the Perl Testing: A Developer's Notebook example?

  • In reply to Re^4: How to write testable command line script? by thechartist
    in thread How to write testable command line script? by thechartist

    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.