use Test::More tests => 1; { my $called = 0; no warnings; local *CGI::new = sub { $called = 1 }; use warnings; my $o = Foo->new; ok($called, 'Foo->new called CGI->new'); };