The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.


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();