Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I like to use Devel::Cover to make sure that my test suite adequately covers my code. I've run into a bit of a conundrum on how to test something.

BEGIN { eval { require YAML::Syck; YAML::Syck->import }; #1 if ($@) { require YAML; YAML->import; #2 } }

Yes, I know I could use Best (use Best qw/YAML::Syck YAML/;), but for this project, it's not an option due to bureaucratic considerations.

My problem is that my tests only exercise the statements in #1, and not in #2 -- or vice-versa. I'm looking for a way that my test script can, e.g. temporarily make require YAML::Syck or YAML::Syck->import die so that I can automatically prove the fallback works.

I have tried to search for answers, but can't seem to find a set of search terms that provides any enlightenment. So, I turn to the Monestary: any ideas?

Updates:

<radiant.matrix>
Ramblings and references
“A positive attitude may not solve all your problems, but it will annoy enough people to make it worth the effort.” — Herm Albright
I haven't found a problem yet that can't be solved by a well-placed trebuchet

In reply to [solved] Test question: how to exercise conditional module load? by radiantmatrix

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2024-04-19 04:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found