1#!/usr/bin/perl -w
2
3use strict;
4
5use Params::Validate qw(validate validate_pos SCALAR);
6use Test::More tests => 6;
7
8{
9    package Tie::SimpleArray;
10    use Tie::Array;
11    use base 'Tie::StdArray';
12}
13
14{
15    package Tie::SimpleHash;
16    use Tie::Hash;
17    use base 'Tie::StdHash';
18}
19
20{
21    tie my @p, 'Tie::SimpleArray';
22
23    my %spec = ( foo => 1 );
24    push @p, ( foo => 'hello' );
25
26    eval { validate( @p, \%spec ) };
27    warn $@ if $@;
28    is( $@, q{}, 'validate() call succeeded with tied params array and regular hashref spec' );
29}
30
31
32SKIP:
33{
34    skip 'Params::Validate segfaults with tied hash for spec', 1;
35
36    my @p;
37    tie my %spec, 'Tie::SimpleHash';
38
39    $spec{foo} = 1;
40    push @p, ( foo => 'hello' );
41
42    eval { validate( @p, \%spec ) };
43    warn $@ if $@;
44    is( $@, q{}, 'validate() call succeeded with regular params array and tied hashref spec' );
45}
46
47SKIP:
48{
49    skip 'Params::Validate segfaults with tied hash for spec', 1;
50
51    tie my @p, 'Tie::SimpleArray';
52    tie my %spec, 'Tie::SimpleHash';
53
54    $spec{foo} = 1;
55    push @p, ( foo => 'hello' );
56
57    eval { validate( @p, \%spec ) };
58    warn $@ if $@;
59    is( $@, q{}, 'validate() call succeeded with tied params array and tied hashref spec' );
60}
61
62{
63    tie my @p, 'Tie::SimpleArray';
64    my %spec;
65
66    $spec{type} = SCALAR;
67    push @p, 'hello';
68
69    eval { validate_pos( @p, \%spec ) };
70    warn $@ if $@;
71    is( $@, q{}, 'validate_pos() call succeeded with tied params array and regular hashref spec' );
72}
73
74
75SKIP:
76{
77    skip 'Params::Validate segfaults with tied hash for spec', 1;
78
79    my @p;
80    tie my %spec, 'Tie::SimpleHash';
81
82    $spec{type} = SCALAR;
83    push @p, 'hello';
84
85    eval { validate_pos( @p, \%spec ) };
86    warn $@ if $@;
87    is( $@, q{}, 'validate_pos() call succeeded with regular params array and tied hashref spec' );
88}
89
90SKIP:
91{
92    skip 'Params::Validate segfaults with tied hash for spec', 1;
93
94    tie my @p, 'Tie::SimpleArray';
95    tie my %spec, 'Tie::SimpleHash';
96
97    $spec{type} = SCALAR;
98    push @p, 'hello';
99
100    eval { validate_pos( @p, \%spec ) };
101    warn $@ if $@;
102    is( $@, q{}, 'validate_pos() call succeeded with tied params array and tied hashref spec' );
103}
104
105