9 plan skip_all => "5.10.0 required" unless eval { require 5.010 };
13 use MooseX::Types::Moose qw(Str HashRef ArrayRef);
17 ok( "foo" ~~ Str, "string" );
18 ok( Str() ~~ "foo", "string" );
19 ok( !("foo" ~~ HashRef), "hashref" );
20 ok( !(HashRef() ~~ "foo"), "hashref" );
24 # unfortunately we can't actually have when(HashRef) etc, because that
25 # resolves as a boolean (checks whether the return value of HashRef etc
27 when ($_ ~~ HashRef) { return "hash" }
28 when ($_ ~~ ArrayRef) { return "array" }
29 when ($_ ~~ Str) { return "string" }
30 default { return "something else" }
34 is( foo({}), "hash" );
35 is( foo("foo"), "string" );
36 is( foo([]), "array" );
37 is( foo(sub { }), "something else" );