Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Test::NoWarnings test 'no warnings' apparently inconsistant

by mandog (Curate)
on Jun 01, 2008 at 22:21 UTC ( #689602=perlquestion: print w/replies, xml ) Need Help??

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 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

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;

Replies are listed 'Best First'.
Re: Test::NoWarnings test 'no warnings' apparently inconsistant
by pc88mxer (Vicar) on Jun 01, 2008 at 23:16 UTC
    It's not Test::NoWarnings fault. You'll get the warning if you use warnings in the file

      As noted you don't set warnings in your .pm, adding $^W++ in your .t test file will switch warnings on globally and thus make it behave as you desire.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://689602]
Approved by pc88mxer
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (6)
As of 2021-09-25 10:32 GMT
Find Nodes?
    Voting Booth?

    No recent polls found