Thanks a lot AnomalousMonk, that's some great insight. I'll apply that to these types of tests for sure. I've also run into a situation where in a test I needed to run past an exit(), and am becoming familiar with Test::Trap.

The following example hasn't yet incorporated your Test::Exception (I also noticed that I wasn't using strict or warnings which has turned out to be very significant for the stability and predictability of a test suite).

#!perl -T use warnings; use strict; use Test::More tests => 8; use Test::Trap; BEGIN {#1 use_ok( 'Devel::Examine::Subs' ) || print "Bail out!\n"; } my $des = Devel::Examine::Subs->new({ file => 't/sample.data', engine => 'all', }); {#2 - core dump my $file = 't/core_dump.debug'; do { eval { open STDOUT, '>', $file or die $!; }; ok (! $@, "STDOUT redirected for core dump"); my @exit = trap { $des->run({core_dump => 1}); }; eval { print STDOUT $trap->stdout; }; is (! $trap->stdout, '', "output to stdout" ); ok (! $@, "core dump gave no errors" ); }; eval { open my $fh, '<', $file or die $!; }; ok (! $@, "core dump output file exists and can be read" ); open my $fh, '<', $file or die $!; my @lines = <$fh>; is (@lines, 183, "Based on test data, core dump dumps the correct +info" ); eval { close $fh; }; ok (! $@, "core dump output file closed successfully" ); eval { unlink $file; }; ok (! $@, "core dump temp file deleted successfully" ); }

-stevieb


In reply to Re^3: "Unescaped left brace in regex is deprecated" by stevieb
in thread "Unescaped left brace in regex is deprecated" by stevieb

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.