in reply to How Do I Bundle Perl Modules and Their Tests Into the Same File?
The ifdef module would be useful for this. Write your module like this:
Remember: There's always one more bug.
Then run it like this:package MyClass; { # Put class code here inside the braces to # constrain the lexical scope of its variables ... } 1; =begin TEST package main; # Test code my $obj = MyClass->new(); ... =cut
I'm sure others will offer more ideas, too.perl -Mifdef=TEST MyClass.pm
Update: Added missing 1; as pointed out below.
Remember: There's always one more bug.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How Do I Bundle Perl Modules and Their Tests Into the Same File?
by perlknight (Pilgrim) on Feb 13, 2006 at 00:30 UTC | |
by ikegami (Patriarch) on Feb 13, 2006 at 03:13 UTC |
In Section
Seekers of Perl Wisdom