http://qs321.pair.com?node_id=689602

mandog has asked for the wisdom of the Perl Monks concerning the following question:

I'm playing with  Test::NoWarnings.

When I test a sub from a module, that spits out warnings, Test::NoWarnings does not complain.

When I test a sub defined in the test file, test: 'no warnings' fails as i would expect.

What am I missing ?

See example code below

#!/usr/bin/perl -T # v5.8.8 (debian etch / ubuntu hardy) use Test::More tests=>2; # $VERSION .082 (ubuntu hardy) # $VERSION eq .084 (cpan) use Test::NoWarnings; use warnings; use strict; use lib qw| . |; use foo; # defined in foo.pm identical to get_match2 # does # is(get_match(undef),undef,'undef gives undef'); # defined below, test 'no warnings' fails as I expect is(get_match2(undef),undef,' match 2 undef gives undef'); sub get_match2 { my $match_me=shift; if ($match_me=~/(\d.+)/){ return $1; } else{ return undef; } }

Contents of foo.pm

Package foo; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw( get_match ); sub get_match { my $match_me=shift; # if ($match_me=~/(.+)/){ return $1; } else{ return undef; } } 1;