NAME
Assert::Refute::T::Hash - Assertions about hashes for Assert::Refute suite
SYNOPSIS
use Test::More;
use Assert::Refute::T::Hash;
keys_are { foo => 42, bar => 137 }, ["foo"], ["bar"], "Hash keys as expected";
EXPORTS
All of the below functions are exported by default:
keys_are \%hash, \@required, \@allowed, "Message"
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.
values_are \%hash, \%spec
For each key in %spec, check corresponding value in %hash:
if spec is
undef
, only accept undefined or missing value;if spec is a string or number, check exact match (
is
);if spec is a regular expression, apply it (
like
);if spec is a contract or sub, apply it to the value (
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.
LICENSE AND COPYRIGHT
This module is part of Assert::Refute suite.
Copyright 2017-2018 Konstantin S. Uvarin. <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: