Revert most of the conversion to Test::Fatal so we can redo it
[gitmo/Moose.git] / t / 010_basics / 022_buildargs_warning.t
CommitLineData
0d922627 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
53a4d826 6use Test::Exception;
0d922627 7use Test::More;
8use Test::Moose qw( with_immutable );
9
10use Test::Requires {
11 'Test::Output' => '0.01',
12};
13
14{
15 package Baz;
16 use Moose;
17}
18
19with_immutable {
53a4d826 20 lives_and {
b8f320d7 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 t/010_basics/022_buildargs_warning.t line \E\d+},
23 'warning when passing an odd number of args to new()';
0d922627 24
b8f320d7 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 };
0d922627 33}
34'Baz';
35
36done_testing;