Commit | Line | Data |
0d922627 |
1 | #!/usr/bin/perl |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
b10dde3a |
6 | use Test::Fatal; |
0d922627 |
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 { |
b10dde3a |
20 | is( exception { |
b8f320d7 |
21 | stderr_like { Baz->new( x => 42, 'y' ) } |
e46b3371 |
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+}, |
b8f320d7 |
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'; |
b10dde3a |
32 | }, undef ); |
0d922627 |
33 | } |
34 | 'Baz'; |
35 | |
36 | done_testing; |