Frequently I notice in test suites that authors aren't always checking that their functions have been exported correctly to their namespace. Having a function exported accidentally can wreak havoc if you redefine a function. Below shows one way of testing this, though you will need to customize it to your situation.
use Test::More 'no_plan'; + use_ok('CGI'); ok(! defined *::param{CODE}, '¶m is not exported to our namespace' +); # in another test file, verifying that you can import: # (though in this example you can run these in one test file) use_ok('CGI', ':standard') or die; can_ok(__PACKAGE__, 'param'); + # or, if you prefer symmetry with the "not exported" test: + ok(defined *::param{CODE}, '¶m is exported to namespace');
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Testing that functions are imported
by kappa (Chaplain) on Oct 05, 2004 at 18:05 UTC | |
by Ovid (Cardinal) on Oct 05, 2004 at 18:21 UTC | |
|
Re: Testing that functions are imported
by PodMaster (Abbot) on Oct 06, 2004 at 13:42 UTC |