I can't, because if I fix the problem you mention, then the problem I describe in this post both disappears in the chopped version of my code posted here, and in the real, full version.

Below is a patched exception.t that completely fixes my problem, because by fixing the bug you mentioned, it also fixed the bug I though I was having. Unfortunately, it was foolish enough, and I was too frustrated to spot it before posting here for help. JavaFan thanks for pointing out my stupid mistake, because I really did think I was having the problem I previously described.

#!perl # exception.t tests all of Exception. use strict; use warnings; use diagnostics; use 5.010; use Test::More;# tests => '19'; BEGIN { use_ok('Exception', 'create_exception'); } # Test uneven params. # create exception w/params create_exception('ParameterException', 'description', 'param', 'param2 +'); evalok(sub {eval {die Exception->throw('ParameterException', param =>) +};}, <<EOD, 'check throw()ing uneven params'); You tried to throw an exception that had an uneven number of parameter +s and their values. The list of parameters you provide must be an even numb +er of parameters followed by their values as in a hash. (ex: 'exception' a = +> '1', b => '2', c => '3') EOD done_testing(); # runs code, and validates the $@ error message. # Why make people install Test::Exception if this little bit of code i +s all # that's needed? sub evalok { my ($code, $expected_message, $test_name) = @_; $code->(); my $croak = $@; $croak =~ s/\sat.*\n$//; #remove cruft. is($croak, $expected_message, $test_name); }

The fix was simply creating the exception with create_exception() before trying to throw it. In the previously posted code, I though I was, but it was creating an exception named ParameterException, but using an exception named TestException.

JavaFan, I feel kinda foolish for posting code that doesn't even have the problem I think it does. Anyway, thanks for the extra set of eyes that made this nightmare I wasted hours debugging seem trivial and foolish. I guess this is what I get for creating new tests by copy and pasting code from previous tests, and forgetting to change all of the variables for the new code.


In reply to Re^2: grep in if statement not working as expected by dly
in thread grep in if statement not working as expected by dly

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.