Giter VIP home page Giter VIP logo

test-typeconstraints's Introduction

NAME

Test::TypeConstraints - testing whether some value is valid as (Moose|Mouse)::Meta::TypeConstraint

SYNOPSIS

use Test::TypeConstraints qw(type_isa);

type_isa($got, "ArrayRef[Int]", "type should be ArrayRef[Int]");

DESCRIPTION

Test::TypeConstraints is for testing whether some value is valid as (Moose|Mouse)::Meta::TypeConstraint.

METHODS

type_isa

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...

coerce

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

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_isnt

type_doesnt

The opposites of type_isa and type_does. They take the same arguments and options.

Checks that the value is not of the given type or role.

AUTHOR

Keiji Yoshimi

THANKS TO

  • schwern
  • gfx
  • tokuhirom

SEE ALSO

Mouse::Util::TypeConstraints, Moose::Util::TypeConstraints

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

test-typeconstraints's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.