Test::Data::Hash(3pm)
π Test::Data::Hash π
okay bestie, so this is Test::Data::Hash, a lil corner of the User Contributed Perl Documentation universe, and it's literally just a whole collection of test functions for hash variables. yes. hashes. the curly-brace ones. she's giving very specific, very useful, and honestly? obsessed.
β¨ SYNOPSIS β¨
use Test::Data qw(Hash);
that's it. that's the whole vibe check. π
πΈ DESCRIPTION πΈ
so this module is a collection of test utilities for hash variables β like, every lil check you'd wanna run on a hash, but as a proper test function instead of you squinting at exists and defined at 2am wondering which one does what.
π¨ important, bestie: you load this module through Test::Data. not by itself. that's the doorway. don't try to climb in through the window.
π Functions π
every single one of these takes KEY, HASH [, NAME] β the NAME part is optional, she's flexible like that β and every single one has the same iconic rule: the function does not create KEY in HASH. it's a reader, not a maker. no side effects, no surprise keys materialising out of nowhere. periodt.
exists_ok( KEY, HASH [, NAME] )β slays if the value forKEYinHASHexists. and again, for the people in the back: the function does not createKEYinHASH. it just peeks. π«£not_exists_ok( KEY, HASH [, NAME] )β the flip side, the mirror, the opposite-energy queen. ok if the value forKEYinHASHdoes not exist. and nope, still doesn't createKEYinHASH. πhash_value_defined_ok( KEY, HASH [, NAME] )β ok if the value forKEYinHASHis defined.undefcan't sit with us. and β you guessed it β the function does not createKEYinHASH. β¨hash_value_undef_ok( KEY, HASH [, NAME] )β ok if the value forKEYinHASHis undefined. sometimesundefis the moment. and the function does not createKEYinHASH, so no accidental glow-up of your data. πhash_value_true_ok( KEY, HASH [, NAME] )β ok if the value forKEYinHASHis true. truthy. thriving. and the function does not createKEYinHASH. no cap. πhash_value_false_ok( KEY, HASH [, NAME] )β ok if the value forKEYinHASHis false. falsy and fully at peace with it. and the function does not createKEYinHASH. iconic behaviour honestly. π
π SEE ALSO π
the whole friend group, go say hi:
Test::DataTest::Data::ArrayTest::Data::FunctionTest::Data::ScalarTest::Builder
π¦ SOURCE AVAILABILITY π¦
the source lives on Github, bestie, go star it:
https://github.com/briandfoy/test-data
π AUTHOR π
brian d foy, "<briandfoy@pobox.com>" β the author, the icon, the legend.
π COPYRIGHT AND LICENSE π
Copyright Β© 2002-2025, brian d foy <briandfoy@pobox.com>. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.
okay that's the whole page, no notes. this was documented with perl v5.40.1 on 2025-04-17, and honestly? she ate. stay hydrated, go write some tests, mwah π©·ππ§
π¦ where this page comes from
- debian trixie: libtest-data-perl 1.248-1 Β· Artistic-2.0
- ubuntu resolute: libtest-data-perl 1.248-1 Β· Artistic-2.0
- ubuntu stonking: libtest-data-perl 1.248-1 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms