Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

include example of a regular subref as a type validator

  • Loading branch information...
commit 34c02e91b477907b895ad6b609d004a4b67548d5 1 parent a1865eb
Karen Etheridge authored

Showing 2 changed files with 30 additions and 3 deletions. Show diff stats Hide diff stats

  1. +21 0 examples/synopsis.t
  2. +9 3 lib/Test/Deep/Type.pm
21 examples/synopsis.t
... ... @@ -0,0 +1,21 @@
  1 +use strict;
  2 +use warnings;
  3 +
  4 +use Test::More;
  5 +use Test::Deep;
  6 +use Test::Deep::Type;
  7 +use MooseX::Types::Moose 'Str';
  8 +
  9 +cmp_deeply(
  10 + {
  11 + message => 'ack I am slain',
  12 + counter => 123,
  13 + },
  14 + {
  15 + message => is_type(Str),
  16 + counter => is_type(sub { die "not an integer" unless int($_[0]) eq $_[0] }),
  17 + },
  18 + 'message is a plain string, counter is a number',
  19 +);
  20 +
  21 +done_testing;
12 lib/Test/Deep/Type.pm
@@ -121,9 +121,15 @@ __END__
121 121 use MooseX::Types::Moose 'Str';
122 122
123 123 cmp_deeply(
124   - { message => 'ack I am slain' },
125   - { message => is_type(Str) },
126   - 'message is a plain string',
  124 + {
  125 + message => 'ack I am slain',
  126 + counter => 123,
  127 + },
  128 + {
  129 + message => is_type(Str),
  130 + counter => is_type(sub { die "not an integer" unless int($_[0]) eq $_[0] }),
  131 + },
  132 + 'message is a plain string, counter is a number',
127 133 );
128 134
129 135 =head1 DESCRIPTION

0 comments on commit 34c02e9

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