Test::TypeTiny(3)

🌸 NAME 🌸

Test::TypeTiny β€” literally the actually-useful functions for testing the efficacy of type constraints πŸ’… (and yup, this is from the User Contributed Perl Documentation manual, section 3 β€” you found it, bestie πŸŽ€)


✨ SYNOPSIS ✨

use strict;
use warnings;
use Test::More;
use Test::TypeTiny;

use Types::Mine qw(Integer Number);

should_pass(1, Integer);
should_pass(-1, Integer);
should_pass(0, Integer);
should_fail(2.5, Integer);

ok_subtype(Number, Integer);

done_testing;

That's the whole vibe, no cap. Copy it, run it, slay πŸ¦‹


πŸ¦‹ STATUS πŸ¦‹

This module is covered by the Type-Tiny stability policy. That's it, that's the status β€” iconic and stable πŸ’–


πŸ’… DESCRIPTION πŸ’…

Test::TypeTiny provides a few handy functions for testing type constraints. It's giving "small module, big main-character energy" πŸ”₯

🌟 FUNCTIONS 🌟

  • should_pass($value, $type, $test_name)
  • should_pass($value, $type) β€” Test that passes iff $value passes $type->check. So like, if the value behaves, the test goes green πŸ’š
  • should_fail($value, $type, $test_name)
  • should_fail($value, $type) β€” Test that passes iff $value fails $type->check. Yes bestie, sometimes you want it to fail, and this test passes when it does πŸ™ˆ
  • ok_subtype($type, @subtypes) β€” Test that passes iff all @subtypes are subtypes of $type. Family tree check, but make it a test 🌈
  • EXTENDED_TESTING β€” Exportable boolean constant. It's a constant. It's boolean. It's exportable. Periodt οΏ½οΏ½
  • matchfor(@things) β€” Assistant for matching exceptions. Not exported by default! πŸ‘€ See also Test::Fatal::matchfor.

🌈 ENVIRONMENT 🌈

If the EXTENDED_TESTING environment variable is set to true, this module will promote each should_pass or should_fail test into a subtest block and test the type constraint in both an inlined and non-inlined manner. Overachiever behaviour, honestly πŸŽ€

🚨 This variable must be set at compile time (i.e. before this module is loaded). Compile time, not runtime β€” timing is everything, bestie 😭

πŸ’€ BUGS πŸ’€

Please report any bugs to https://github.com/tobyink/p5-type-tiny/issues. Found a bug? Don't suffer in silence, tell the maintainer 🫢


⭐ SEE ALSO ⭐

Type::Tiny.

For an alternative to should_pass, see Test::Deep::Type which will happily accept a Type::Tiny type constraint instead of a MooseX::Types one. Options! We love options πŸ’œ


🫢 AUTHOR 🫢

Toby Inkster <tobyink@cpan.org>. The legend behind all this ✨


This software is copyright (c) 2013-2014, 2017-2025 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Free as in "go off, bestie" πŸ’–


πŸ’œ DISCLAIMER OF WARRANTIES πŸ’œ

⚠️ Okay so: THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. Translation: no promises, no guarantees, use at your own risk πŸ˜­πŸ’€

and that's the entire page, bestie!! πŸŽ€ you just read Test::TypeTiny(3), brought to you by perl v5.42.2, dated 2026-04-07. now go forth and make those type constraints pass their vibe check πŸŒΈπŸ¦‹βœ¨

πŸ“¦ where this page comes from