Type::Tiny::Manual::UsingWithTestMore - Online Linux Manual PageSection : 3pm
Updated : 2021-02-24
Source : perl v5.32.1
Note : User Contributed Perl Documentation
NAMEType::Tiny::Manual::UsingWithTestMore − Type::Tiny for test suites
MANUAL
Test::TypeTinyThis is a module for testing that types you've defined accept and reject the values you think they should. should_pass($value, $type);
should_fail($othervalue, $type);
Easy. (But yeah, I always forget whether the type goes first or second!) There's also a function to test that subtype/supertype relationships are working okay. ok_subtype($type, @subtypes);
Of course you can just check a type like this: ok( $type−>check($value) );
But the advantage of should_pass is that if the EXTENDED_TESTING environment variable is set to true, should_pass will also perform a strict check on the value, which involves climbing up the type's inheritance tree (its parent, its parent's parent, etc) to make sure the value passes all their constraints. If a normal check and strict check differ, this is usually a problem in the inlining code somewhere. See Test::TypeTiny for more information.
Type::Tiny as a Replacement for Test::DeepHere's one of the examples from the Test::Deep documentation: my $name_re = re('^(Mr|Mrs|Miss) \w+ \w+$');
cmp_deeply(
$person,
{
Name => $name_re,
Phone => re('^0d{6}$'),
ChildNames => array_each($name_re)
},
"person ok"
);
It's pretty easy to rewrite this to use Types::Standard: my $name = StrMatch[ qr/^(Mr|Mrs|Miss) \w+ \w+$/ ];
should_pass(
$person,
Dict[
Name => $name,
Phone => StrMatch[ qr/^0d{6}$/ ],
ChildNames => ArrayRef[$name]
]
);
There's nothing especially wrong with Test::Deep, but if you're already familiar with Type::Tiny's built-in types and you've maybe written your own type libraries too, it will save you having to switch between using two separate systems of checks.
NEXT STEPSHere's your next step: • Type::Tiny::Manual::Params Advanced information on Type::Params, and using Type::Tiny with other signature modules like Function::Parameters and Kavorka.
AUTHORToby Inkster <tobyink@cpan.org>.
COPYRIGHT AND LICENCEThis software is copyright (c) 2013−2014, 2017−2021 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.
DISCLAIMER OF WARRANTIESTHIS 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. 0
Johanes Gumabo
Data Size : 9,776 byte
man-Type::Tiny::Manual::UsingWithTestMore.3pmBuild : 2024-12-05, 20:55 :
Visitor Screen : x
Visitor Counter ( page / site ) : 3 / 179,958
Visitor ID : :
Visitor IP : 3.139.69.138 :
Visitor Provider : AMAZON-02 :
Provider Position ( lat x lon ) : 39.962500 x -83.006100 : x
Provider Accuracy Radius ( km ) : 1000 :
Provider City : Columbus :
Provider Province : Ohio , : ,
Provider Country : United States :
Provider Continent : North America :
Visitor Recorder : Version :
Visitor Recorder : Library :
Online Linux Manual Page : Version : Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page : Library : lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page : Library : lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base : Version : Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base : Library : lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36
Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.
ERROR : Need New Coding : (parse_manual_page_|249|Type::Tiny::Manual::UsingWithTestMore.3pm|36/37|el══─{─══.|.el══─{─══. ds -- \|\(em\|
) (htmlprn|149|Type::Tiny::Manual::UsingWithTestMore.3pm|36/37|.el══─{─══. ds -- — |.el══─{─══. ds -- \|\(em\|
) (parse_manual_page_|249|Type::Tiny::Manual::UsingWithTestMore.3pm|43|br══─}─══|'br══─}─══
) (htmlprn|149|Type::Tiny::Manual::UsingWithTestMore.3pm|43|'br══─}─══ |'br══─}─══
)