[EMAIL PROTECTED] wrote:

I usually do this with can_ok()

        can_ok( __PACKAGE__, qw(is_code isnt_code) );


Initially i thought "Would that work ? Isnt __PACKAGE__ equal to main:: in a t file ?" then I realised we're testing that the use_ok is exporting these to our namespace, which is __PACKAGE__ so yeah that'd work.

Then, somehow, I thought, what if our module we're testing looked like this -

<code>
package Mo::Bling;
use strict;
use warnings;
...
sub bling {}
...
<other functions defined here>
...
1;

__TEST__
use Test::More test => xxx;

use_ok(__PACKAGE__, qw(pragmas));

is(__PACKAGE__->bling(), 'mo bling than yo', 'adds bling');

...
<mo tests >
...

__DATA__

...
<data we may wish to use in __TEST__ scenarios>
...

__END__
...
<pod>
...

</code>

I'm thinking that the code, tests, data and pod are all there in the pm file - that seems on the surface a good thing. Does this seem like a reasonable idea ?

Against it is the significant inertia the current .t regime enjoys, but it seems an interesting idea.

--
Leif Eriksen
Snr Developer
http://www.hpa.com.au/
phone: +61 3 9217 5545
email: [EMAIL PROTECTED]

Reply via email to