File: buildargs_warning.t

package info (click to toggle)
libmoose-perl 2.2207-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 7,416 kB
  • sloc: perl: 21,345; ansic: 291; makefile: 10
file content (32 lines) | stat: -rw-r--r-- 850 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use strict;
use warnings;

use Test::Needs 'Test::Output';
use Test::Fatal;
use Test::More;
use Test::Moose qw( with_immutable );
use 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;