testing

Dominic Thoreau dominic.thoreau at googlemail.com
Mon Nov 3 14:08:23 GMT 2008


2008/11/3 Christopher Jones <c.jones at ucl.ac.uk>:
> Should you be able to create and call methods from a package in a test
> script? i.e Should something like this work? (i.e.i.e. it doesn't seem to
> for me right now).
>
>
> #!/usr/bin/perl -w
> use strict;
>
> use Test::More tests => 2;
>
> BEGIN {
>        use_ok('My::Module');    # contains a package called 'my_mod'
> };
> test 'object init' => sub {
>        ok(my $object = my_test_mod->new(),'init');
> };
>
> { package my_test_mod;
>        our @ISA = qw( my_mod );
> }

I think (off the top of my head, and I haven't used any of the Test::*
modules), but it's at least possible that because you put an enclosure
around the use_ok call, that the code in that file isn't available to
anything outside that block.

Scope is always useful once you understand it - but can be nasty when you don't.

'Course I could be wrong.....
-- 
No train here, but still:
The sign says: "Ready to Leave"
Normal service, yes?


More information about the london.pm mailing list