Subject: | Generating spurious warnings only in the debugger |
The following test script passes if run via prove, but fails if run in
the debugger.
#!/usr/bin/perl
# Tests that Test::MockObject obeys the correct behaviour
BEGIN {
$| = 1;
$^W = 1;
}
use strict;
use Test::More tests => 8;
use Params::Util '_INSTANCE';
use Test::MockObject::Extends;
SCOPE: {
package Foo;
sub new { bless {}, $_[0]; }
sub dummy { 0 }
}
# Set a warning counter
my $warning_count = 0;
$SIG{__WARN__} = sub { $warning_count++ };
my $object = Foo->new;
isa_ok( $object, 'Foo' );
is( $warning_count, 0, 'No warnings' );
my $mock = Test::MockObject::Extends->new( $object );
isa_ok( $mock, 'Foo' );
is( $warning_count, 0, 'No warnings' );
# Positive case
if ( _INSTANCE($mock, 'Foo') ) {
pass( "_INSTANCE(true) returned true" );
} else {
fail( "_INSTANCE(true) returned false" );
}
is( $warning_count, 0, 'No warnings' );