The problem with it, as I see it is that, with optimisitic typing (ie, just passing in $self), you get an immediate failure if the object under test calls an unexpected method simply because you haven't implemented it.
Fair point. Although in some circumstances that could be what you want :-)
Instead of replacing stuff I sometimes just add instrumentation with something like Hook::LexWrap - handy when retrofitting tests onto tightly coupled code.
This really comes down to how much value you see in the strict typing of variables.
Well, all the ways of doing it in perl suck in one way or another so I don't often use it, but it's nice if done right (Eiffel springs to mind).
Method selecters are cool, and interfaces would be yet another solution.
Maybe in perl6 :-)
In reply to Re^2: Test::Class & self-shunt pattern
by adrianh
in thread Documenting Methods/Subs
by vek
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |