Posted on 2005-09-19 06:51:52-07 by whitney
use_ok() produces warnings with Class::Std
When testing a package that makes use of Class::Std with the Test::More's use_ok() function I get warnings like this:

Too late to run CHECK block at /usr/lib/perl5/site_perl/5.8.6/Class/Std.pm line 359.

example package:

package Foo; use Class::Std; { my %name_of : ATTR; } 1;


example test (foo.t):

use Test::More tests => 1; use_ok('Foo');


$ perl t/foo.t

1..1 Too late to run CHECK block at /usr/lib/perl5/site_perl/5.8.6/Class/Std.pm line 359. ok 1 - use Foo;

Anyone know what's causing this?
Direct Responses: 1333 | Write a response
Posted on 2005-11-17 13:35:09-08 by jdhedden in response to 1012
Re: use_ok() produces warnings with Class::Std
The problem you're encountering is related to this bug report. It is caused by the fact that Class::Std has a CHECK block in which it does most of its setup. The CHECK block would normally get executed at the last stage of compilation, and before the code starts running. The use_ok() function does an eval to import your module. The test code is already running by that point, so it's too late to deal with the CHECK block. As a result, Class::Std fails to work properly.

You should take a look at Object::InsideOut. It has all of the features of Class::Std and many more, plus none of its bugs, including this one.
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.