Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Comment on

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

Hi,
I'm writing a module to verify data values. The objects are esentially factories which write subroutines to validate data items.

As part of their construction these objects can be fed arrays or subroutine references. The relevant set routines check to see if you've fed them the right type of thing - this is done using ref :-

sub _ref_check { my ($test,$should_be) = @_; my $ref = ref($test); unless ($ref eq $should_be) { if (length($ref) > 0) { carp ("\n>> $test isn't a reference to a $should_be, but rathe +r a reference to a ".$ref."\n") } else { carp ("\n>> $test isn't an array reference at all, but a SCALA +R\n") }# if (defined($refref)) return 0; } # unless ($ref eq $should_be) return 1; } #End of subrotuine _ref_check

This works fine, and I'm happy with it, but in my test scripts I have chosen to test that I can't feed improper things to the set routines. As you can see the error reports from carp in _ref_check() turn up in the test output.

t\01-sanity.....................ok t\02-simple.....................ok 16/0 >> 4 isn't an array reference at all, but a SCALAR # # Won't accept scalar values >> HASH(0x1dec550) isn't a reference to an array, but rather a referen +ce to a HASH # # Won't accept hash values t\02-simple.....................ok t\03-transform..................ok 3/0 >> ARRAY(0x1c0ba88) isn't a reference to a subroutine , but rather a r +eference to an ARRAY t\03-transform..................ok 5/0 >> 4 isn't an array reference at all, but a SCALAR t\03-transform..................ok 7/0 >> HASH(0x1ab5430) isn't a reference to an array, but rather a referen +ce to a HAS t\03-transform..................ok [snip] All tests successful. Files=9, Tests=101, 1 wallclock secs ( 0.00 cusr + 0.00 csys = 0.00 + CPU)

So what I would like is style advice - is it appropriate/accepatable for tests to output something besides

t\01-sanity.....................ok

In any event can I turn off carp, or otherwise lose diagnostic output while running tests?

--
Anthony Staines

P.S. If you're really curious the module will be on my scratchpad for a while, but it's not really ready for the real world...


In reply to Silencing warnings when testing by astaines

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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

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

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (7)
    As of 2014-09-19 08:30 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      How do you remember the number of days in each month?











      Results (133 votes), past polls