Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

include example of a regular subref as a type validator

  • Loading branch information...
commit 34c02e91b477907b895ad6b609d004a4b67548d5 1 parent a1865eb
@karenetheridge authored
Showing with 30 additions and 3 deletions.
  1. +21 −0 examples/synopsis.t
  2. +9 −3 lib/Test/Deep/Type.pm
View
21 examples/synopsis.t
@@ -0,0 +1,21 @@
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Deep;
+use Test::Deep::Type;
+use MooseX::Types::Moose 'Str';
+
+cmp_deeply(
+ {
+ message => 'ack I am slain',
+ counter => 123,
+ },
+ {
+ message => is_type(Str),
+ counter => is_type(sub { die "not an integer" unless int($_[0]) eq $_[0] }),
+ },
+ 'message is a plain string, counter is a number',
+);
+
+done_testing;
View
12 lib/Test/Deep/Type.pm
@@ -121,9 +121,15 @@ __END__
use MooseX::Types::Moose 'Str';
cmp_deeply(
- { message => 'ack I am slain' },
- { message => is_type(Str) },
- 'message is a plain string',
+ {
+ message => 'ack I am slain',
+ counter => 123,
+ },
+ {
+ message => is_type(Str),
+ counter => is_type(sub { die "not an integer" unless int($_[0]) eq $_[0] }),
+ },
+ 'message is a plain string, counter is a number',
);
=head1 DESCRIPTION

0 comments on commit 34c02e9

Please sign in to comment.
Something went wrong with that request. Please try again.