1

これはwarnings::warnif( 'deprecated' … ) with carp?に対するフォローアップの質問です。.

これは、 Github の Business::Cyber​​Sourceからの私のコードのスニペットです。

注:前の回答(前の質問)、およびの追加は、を使用@CARP_NOTすることを示しています。鯉を直接代用しようとしましたが、動作はまったく同じでした。warnings::warnifcarp

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'
    );

しかし、このコードを呼び出すと

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,
}]);

エラーはまだ間違った場所から報告されています (少なくとも からではありません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.

テスト ファイルの正しい行番号からこのレポートを作成するにはどうすればよいですか? ->new(注:使用する代わりに直接呼び出した場合、動作は変わりませんでしたnew_ok

4

0 に答える 0