Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Thanks, all, for the help. I've gone down the command line switch route and have got my code working. But the code has two areas that smell to me, so I come again pleading for help. :-)

I have tests in three files that are called from a fourth, which is as follows:

use strict; use warnings; use Test::Harness; runtests(["podext.t"], ["excelpod.bat"], ["ExcelPOD.t"]);

This works fine, but I don't like the business of having to run the .bat file. However, I can't find any way of putting a command such as -t with command line parameters into the list of test files to be run without getting an error. The second smell is in, some of which is:

use if (1 == scalar @ARGV && "-t" eq $ARGV[0]), "Test::More"; ... if (0 < scalar @ARGV && '-t' eq $ARGV[0]) { #Tests no warnings; eval {"plan tests => 63;"}; use warnings;

If I write this without all the conditionals, everything works, but running in "live mode" (as opposed to test mode) I get a message saying that no test were run. This might be mistaken for an error message and cause confusion, so I want to suppress it. But writing the "use if" line means that running in live mode generates a compile time error when I give the test plan (and I can find no way of providing that in the "use if" command). Wrapping it in an "eval" command results in a warning of a useless use of a constant in void context, and the only way I can find to avoid that is to suppress warnings.

As I say, the code is working and the tests are running, but I'd be a happier bunny either if I knew how to avoid the kludges or if I knew that they were unavoidable.


John Davies

In reply to Re^2: TDD of non-module code by davies
in thread TDD of non-module code by davies

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (3)
    As of 2020-11-28 02:47 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found