Add another MOOSE_TEST_MD option, MooseX
[gitmo/Moose.git] / t / basics / buildargs_warning.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::Fatal;
7 use Test::More;
8 use Test::Moose qw( with_immutable );
9
10 use Test::Requires {
11     'Test::Output' => '0.01',
12 };
13
14 {
15     package Baz;
16     use Moose;
17 }
18
19 with_immutable {
20     is( exception {
21         stderr_like { Baz->new( x => 42, 'y' ) }
22         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+},
23             'warning when passing an odd number of args to new()';
24
25         stderr_unlike { Baz->new( x => 42, 'y' ) }
26         qr{\QOdd number of elements in anonymous hash},
27             'we suppress the standard warning from Perl for an odd number of elements in a hash';
28
29         stderr_is { Baz->new( { x => 42 } ) }
30         q{},
31             'we handle a single hashref to new without errors';
32     }, undef );
33 }
34 'Baz';
35
36 done_testing;