Created
September 15, 2011 11:31
-
-
Save ilmari/1219046 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use Test::More; | |
use Test::Fatal; | |
use MooseX::Types::Moose qw(ArrayRef HashRef Value); | |
use MooseX::Types -declare => [ | |
qw(StructHash StructArray Struct) | |
]; | |
subtype StructHash, as HashRef[Struct]; | |
subtype StructArray, as ArrayRef[Struct]; | |
subtype Struct, as Value|StructArray|StructHash; | |
ok is_Struct(42), "Scalar struct"; | |
ok is_Struct([ 42 ]), "Array struct"; | |
ok is_Struct({ foo => 42 }), "Hash struct"; | |
done_testing; | |
__END__ | |
ok 1 - Scalar struct | |
not ok 2 - Array struct | |
# Failed test 'Array struct' | |
# at /home/ilmari/tmp/recursive-types.t line 16. | |
not ok 3 - Hash struct | |
# Failed test 'Hash struct' | |
# at /home/ilmari/tmp/recursive-types.t line 17. | |
1..3 | |
# Looks like you failed 2 tests of 3. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment