Personally I prefer decoupling the implementation from the code to test it for several reasons.
- Testing is often about interaction between several modules, in this approach test code gets scattered across modules, and one has to have a script to test the integration of the modules anyway.
- It's easier to track changes to implementation and test code if they're in separate files. This is especially important during refactoring when the test code must be changed as little as possible, if at all.
- It's useful to have someone else write the tests for your code since she might think of edge conditions you overlooked. Even if you write your own tests: 'testing' ne 'implementing' and should be as far apart as possible IMHO.
- If you like to use a testing framework such as Test::More et al., a dependency is created between the module and the testing framework, which is not desirable. (I've been bitten by this at some point.)
Just my 2 cents, -gjb-