Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /usr/share/doc/perl-Moose/t/basics/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //usr/share/doc/perl-Moose/t/basics/buildargs_warning.t
use strict;
use warnings;

use Test::Fatal;
use Test::More;
use Test::Moose qw( with_immutable );

use Test::Requires 'Test::Output';

{
    package Baz;
    use Moose;
}

with_immutable {
    is( exception {
        stderr_like { Baz->new( x => 42, 'y' ) }
        qr{\QThe new() method for Baz expects a hash reference or a key/value list. You passed an odd number of arguments at $0 line \E\d+},
            'warning when passing an odd number of args to new()';

        stderr_unlike { Baz->new( x => 42, 'y' ) }
        qr{\QOdd number of elements in anonymous hash},
            'we suppress the standard warning from Perl for an odd number of elements in a hash';

        stderr_is { Baz->new( { x => 42 } ) }
        q{},
            'we handle a single hashref to new without errors';
    }, undef );
}
'Baz';

done_testing;

Hry