summaryrefslogtreecommitdiff
path: root/t/32-regex-as-value.t
diff options
context:
space:
mode:
Diffstat (limited to 't/32-regex-as-value.t')
-rw-r--r--t/32-regex-as-value.t37
1 files changed, 37 insertions, 0 deletions
diff --git a/t/32-regex-as-value.t b/t/32-regex-as-value.t
new file mode 100644
index 0000000..bbd0640
--- /dev/null
+++ b/t/32-regex-as-value.t
@@ -0,0 +1,37 @@
+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;
+}