Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re^7: Testing methodology, best practices and a pig in a hut.

by chromatic (Archbishop)
on Feb 28, 2008 at 00:03 UTC ( #670794=note: print w/replies, xml ) Need Help??

in reply to Re^6: Testing methodology, best practices and a pig in a hut.
in thread Testing methodology, best practices and a pig in a hut.

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.


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.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://670794]
[james28909]: how come it is so easy for me to not care what others think while others will mute themselves because they are scare they will be called ignorant or stupid
[james28909]: do you relize how shrodinger felt when he was describing the quantum world? what about neils bohr?
[holli]: it's probably the autist in you. I am like that too, no fucks given about what others think about me
james28909 checks, yep... htere are no fucks to give
[james28909]: another thing i am sick of is hurting others feelings
[1nickt]: james28909 You lost me a bit when you said "show me evolution from intelligence to ignorance". I guess we would have to define the terms, but as I look around at my species and how we are destroying our habitat ...
[james28909]: seems like a person cant even have a belief without hurting someones feelings. i never said my way is the only way. i just said i have pretty good scientific evidence, and then asked for opposing side to present evidence
[james28909]: was downvoted and left without a reply. go figure
[holli]: but then you DO give a fuck

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2017-12-15 14:26 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (433 votes). Check out past polls.