Codebase list libparams-validate-perl / d64ec6eb-8114-4b87-a1df-aedc1a663c66/main t / 32-regex-as-value.t
d64ec6eb-8114-4b87-a1df-aedc1a663c66/main

Tree @d64ec6eb-8114-4b87-a1df-aedc1a663c66/main (Download .tar.gz)

32-regex-as-value.t @d64ec6eb-8114-4b87-a1df-aedc1a663c66/mainraw · history · blame

use strict;
use warnings;

use Params::Validate qw( validate SCALAR SCALARREF );

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

is(
    exception { v( foo => qr/foo/ ) },
    undef,
    'no exception with regex object'
);

is(
    exception { v( foo => 'foo' ) },
    undef,
    'no exception with plain scalar'
);

my $foo = 'foo';
is(
    exception { v( foo => \$foo ) },
    undef,
    'no exception with scalar ref'
);

done_testing();

sub v {
    validate(
        @_, {
            foo => { type => SCALAR | SCALARREF },
        },
    );
    return;
}