Cannot accept an arrayref to pos_validated_list, since this can be confused with...
[gitmo/MooseX-Params-Validate.git] / t / 012_ref_as_first_param.t
CommitLineData
954fa4ca 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
7use Test::Fatal;
8
9{
10 use MooseX::Params::Validate;
11
12 sub foo {
13 my ( $x, $y ) = validated_list(
14 \@_,
15 x => { isa => 'Any' },
16 y => { isa => 'Any' },
17 );
18
19 return { x => $x, y => $y };
20 }
21
22 sub bar {
23 my %p = validated_hash(
24 \@_,
25 x => { isa => 'Any' },
26 y => { isa => 'Any' },
27 );
28
29 return \%p;
30 }
954fa4ca 31}
32
33is_deeply(
34 foo( x => 42, y => 84 ),
35 { x => 42, y => 84 },
36 'validated_list accepts a plain hash'
37);
38
39is_deeply(
40 foo( { x => 42, y => 84 } ),
41 { x => 42, y => 84 },
42 'validated_list accepts a hash reference'
43);
44
45is_deeply(
46 bar( x => 42, y => 84 ),
47 { x => 42, y => 84 },
48 'validated_hash accepts a plain hash'
49);
50
51is_deeply(
52 bar( { x => 42, y => 84 } ),
53 { x => 42, y => 84 },
54 'validated_hash accepts a hash reference'
55);
56
954fa4ca 57done_testing();