Test::Most implements die_on_fail by checking the result from the last run test before it runs the next. Therefore the die doesn't happen immediately. Rather it waits until your second call to ok. Then it dies before it runs the test. Any code between the two calls to ok gets executed.

You can see this for yourself by looking at the source code for Test::Most (see the link on the upper left side of the page). When you open the source code page scroll down to the definition of die_on_fail. That function is simply a wrapper around set_failure_handler. set_failure_handler simply redefines Test::Builder::ok to save the result from each test and then check it the next time a test is run.

Best, beth

Update: fixed typo as noted below in reply, and one additional typo (s/Test::More::ok/Test::Builder::ok/).


In reply to Re: die_on_fail of Test::Most only dies after the next test by ELISHEVA
in thread die_on_fail of Test::Most only dies after the next test by elTriberium

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.