in reply to test case for private function in module
package Foo::Bar; my $privateFunc1 = sub { ... } my $privateFunc2 = sub { ... } my $privateFunc3 = sub { ... } if (our $TESTING) { # Expose private functions for testing. *_privateFunc1 = $privateFunc1; *_privateFunc2 = $privateFunc2; *_privateFunc3 = $privateFunc3; }
By setting var $TESTING in your module's package to something true, you can now perform testing on your private functions.
BEGIN { $Foo::Bar::TESTING = 1; } use Foo::Bar; is( Foo::Bar::_privateFunc1($val), $expect, 'privateFunc1' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: test case for private function in module
by ack (Deacon) on Apr 08, 2009 at 21:54 UTC |