This is a followup question to warnings::warnif( 'deprecated' … ) with carp?.
here's a snippet of my code from Business::CyberSource on Github
note: the previous answer (in the previous question), and adding of @CARP_NOT
have demonstrated that warnings::warnif
uses carp
. I attempted to substitute carp directly, the behavior was exactly the same.
our @CARP_NOT = ( __PACKAGE__, qw( Class::MOP::Method::Wrapped ) );
around BUILDARGS => sub {
my $orig = shift;
my $class = shift;
my $args = $class->$orig( @_ );
if ( exists $args->{username} ) {
warnings::warnif('deprecated',
'`username` is deprecated, use `user` instead'
);
But when I call this code
use strict;
use warnings;
use Test::More;
use Business::CyberSource::Client;
my $class = 'Business::CyberSource::Client';
my $client
= new_ok( $class => [{
username => $ENV{PERL_BUSINESS_CYBERSOURCE_USERNAME} || 'test',
password => $ENV{PERL_BUSINESS_CYBERSOURCE_PASSWORD} || 'test',
production => 0,
}]);
The error is still reported from the wrong place (though at least not from Class::MOP::Method::Wrapped
)
t/new-client.t .. `username` is deprecated, use `user` instead at constructor Business::CyberSource::Client::new (defined at /home/xenoterracide/Documents/Business-CyberSource/lib/Business/CyberSource/Client.pm line 314) line 6.
How can I make this report from the correct line number in the test file? (note: behavior did not change if I called ->new
directly instead of using new_ok