Test::TypeConstraints - testing whether some value is valid as (Moose|Mouse)::Meta::TypeConstraint
use Test::TypeConstraints qw(type_isa); type_isa($got, "ArrayRef[Int]", "type should be ArrayRef[Int]");
Test::TypeConstraints is for testing whether some value is valid as (Moose|Mouse)::Meta::TypeConstraint.
type_isa($value, $type); type_isa($value, $type, $test_name); type_isa($value, $type, $test_name, %options);
Performs a type check against the $value using the $type.
$type can be a class name, a Moose/Mouse type name, Moose/Mouse::Meta::TypeConstraint object or Moose/Mouse::Meta::TypeConstraint::Class object.
$test_name is the description of the test. If not given, one will be provided.
%options control optional behaviors. Its keys can be the following...
If true, coercion will be used when performing the type check.
If a code ref is given, it will be run and passed in the coerced value for additional testing.
type_isa $value, "Some::Class", "coerce to Some::Class", coerce => sub { isa_ok $_[0], "Some::Class"; is $_[0]->value, $value; };
type_does($value, $role); type_does($value, $role, $test_name); type_does($value, $role, $test_name, %options);
Tests that the $value does the $role.
Works like type_isa, but for roles instead of classes and types. The $value must have consumed the given $role.
type_isa
The opposites of type_isa and type_does. They take the same arguments and options.
type_does
Checks that the value is not of the given type or role.
Keiji Yoshimi <walf443 at gmail dot com>
Mouse::Util::TypeConstraints, Moose::Util::TypeConstraints
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Test::TypeConstraints, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::TypeConstraints
CPAN shell
perl -MCPAN -e shell install Test::TypeConstraints
For more information on module installation, please visit the detailed CPAN module installation guide.