Assert::Refute::T::Hash - Assertions about hashes for Assert::Refute suite
use Test::More; use Assert::Refute::T::Hash; keys_are { foo => 42, bar => 137 }, ["foo"], ["bar"], "Hash keys as expected";
All of the below functions are exported by default:
Check that keys in hash are exactly as expected:
if \@required is present, make sure that all keys listed there exist;
if \@allowed is present, make sure no keys are present except those listed in either required or allowed.
For each key in %spec, check corresponding value in %hash:
if spec is undef, only accept undefined or missing value;
undef
if spec is a string or number, check exact match (is);
is
if spec is a regular expression, apply it (like);
like
if spec is a contract or sub, apply it to the value (subcontract);
subcontract
[NOTE] This test should die if any other value appears in the spec. However, it does not yet, instead producing a warning and an unconditionally failed test.
This module is part of Assert::Refute suite.
Copyright 2017-2018 Konstantin S. Uvarin. <khedin at cpan.org>
<khedin at cpan.org>
This program is free software; you can redistribute it and/or modify it under the terms of the the Artistic License (2.0). You may obtain a copy of the full license at:
http://www.perlfoundation.org/artistic_license_2_0
To install Assert::Refute::T::Hash, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Assert::Refute::T::Hash
CPAN shell
perl -MCPAN -e shell install Assert::Refute::T::Hash
For more information on module installation, please visit the detailed CPAN module installation guide.