summaryrefslogtreecommitdiff
path: root/t/release-pp-36-large-arrays.t
blob: 6301d916be149d8d8aa992e80c301e6c222c9f66 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55


use Test::More;

BEGIN {
    unless ( $ENV{RELEASE_TESTING} ) {
        plan skip_all => 'these tests are for release testing';
    }

    $ENV{PV_TEST_PERL} = 1;
}

use strict;
use warnings;

use Test::Fatal;
use Test::More;

{
    package Foo;

    use Params::Validate qw( validate ARRAYREF );

    sub v1 {
        my %p = validate(
            @_, {
                array => {
                    callbacks => {
                        'checking array contents' => sub {
                            for my $x ( @{ $_[0] } ) {
                                return 0 unless defined $x && !ref $x;
                            }
                            return 1;
                        },
                    }
                }
            }
        );
        return $p{array};
    }
}

{
    for my $size ( 100, 1_000, 100_000 ) {
        my @array = ('x') x $size;
        is_deeply(
            Foo::v1( array => \@array ),
            \@array,
            "validate() handles $size element array correctly"
        );
    }
}

done_testing();