Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I see the value of having a test script which reality-checks that everything compiles, especially if there are big gaps in a test suite.

    But I don't see what's wrong with "use_ok()" for a module that you neede to "use" anyway. It's hardly any more syntax. What's the harm?

    • First, here's the general 'correct' incantation:

      BEGIN {
          use_ok 'Some::Module' or die "Cannot use Some::Module";
      }

      If the module is not used in a "BEGIN" block, compile-time behavior is ignored (e.g., exported functions may alter how your code parses).

      If you don't have the 'or die' (or BAIL_OUT), things can get even worse. If the module fails to load, but most of it compiled, you can get partially compiled code loaded. Your 'use_ok' failure may scroll off the screen but failures show up much l

      • So I would say it summarizes like this:

        If "use" a module it fails, the test grinds to a halt, which is nearly always a reasonable result.

        With "use_ok", the test may /continue/ causing unexpected results later on, because the module is not loaded, or worse, partially loaded.

        Thanks for your clarification, Ovid.