Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I suppose "I don't like modules that use string eval" is a fine objection if you want it to be, but I was under the impression that your meditation here was an attempt to argue that blindly applying conventional wisdom as prohibitions without understanding why it's conventional wisdom and why the real world can be more nuanced than it is is a bad thing.

So color me somewhat confused.

The bit between big black lines looks an aweful lot like a string eval to me?

Yep, and that's one way to do it. My Perl 6 reimplementation doesn't use string eval at all, for example. It's unnecessary in Perl 6. I believe my original Perl 5 T::B code dispatched to very small subroutine references. As it turns out, string eval happens to be faster and clearer in Perl 5 than maintaining a comprehensive dispatch table of all of the possible comparison operations. If there's a simpler, faster, and clearer way to do this, I'm sure Schwern would take a patch.

Similarly, I believe that like() uses string eval so that the code will work on truly ancient versions of Perl 5 that don't have qr//. I don't support versions of Perl older than 5.6.2, but Schwern's willing to do so here. If you have another solution that meets his goals, I'm sure he'd take that patch too.

However you said "String eval is the underlying basis of what the Test::* modules do." The code you quoted is not proof of that. How can it be? cmp_ok is not the underlying basis of what the Test::* modules do. It's not the underlying basis of Test::More. It's not the underlying basis of Test::Builder. Thus it's not the underlying basis of any Test::* module.

(What's the underlying basis of T::B? ok() and, to a lesser extent, diag().)

Reimplementing a small subset of perl's native functionality--string/numeric comparisons and regex--, using a large, slow, verbose and complex hierarchy of OO code modules, in order to compare scalar variables against constants, when at the final step you are just going to use string eval and let Perl do those comparisons anyway, just so that you can convert the boolean results into a stream of 'ok's and 'not ok's.

My goodness, you're right. It's almost as if we wanted to test Perl code with Perl code. It's almost as if the code in T::B exists to report the locations of failures correctly, handle overloading properly, manage threading appropriately, and provide a uniform interface available from Perl 5.004 or earlier to the latest bleadperl, while allowing hundreds of testing modules to interoperate smoothly in the same process without having to know the internals of even those modules not yet written and without requiring everyone who wants to write tests in Perl to reinvent all of that badly and discover and, hopefully, fix the same weird bugs that everyone who writes testing modules in Perl would have had to fix eventually.

The horror.

fascile

I assume you meant facile, which means "easy", "unconstrained", and "pleasant". Thank you. That's why we wrote those modules.

(If you meant "superficial", I'd love to see the code you have which solves the same problems. Denying that many people have these problems and have solved them very satisfyingly is not the same thing.)

As always, you may have the last word in this discussion.


In reply to Re^7: Testing methodology, best practices and a pig in a hut. by chromatic
in thread Testing methodology, best practices and a pig in a hut. by BrowserUk

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, 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, 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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (8)
    As of 2017-10-23 16:26 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      My fridge is mostly full of:

















      Results (281 votes). Check out past polls.

      Notices?