Test::...::Fuzzy(3pm)

πŸ“¦
version 0.01 Β· 6 versions
, in debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Test::...::Fuzzy β€” the manual page, but make it cute ✨

okay bestie, you're looking at the docs for Test::Deep::Fuzzy, a lil module in the User Contributed Perl Documentation pile. it does exactly one thing and it does it adorably: fuzzy number comparison with Test::Deep. no cap πŸ’…


✨ NAME ✨

Test::Deep::Fuzzy β€” fuzzy number comparison with Test::Deep πŸ¦‹

like. that's the whole personality. floats are messy, this module is not.


🌸 SYNOPSIS 🌸

here's the vibe, copy-paste ready:

use Test::Deep;
use Test::Deep::Fuzzy;

my $range = 0.001;

cmp_deeply({
    number => 0.0078125,
}, {
    number => is_fuzzy_num(0.008, $range),
}, 'number is collect');

see how 0.0078125 and 0.008 are not the same number but the test still passes? yeah. that's the whole serve. slay ✨


πŸŽ€ DESCRIPTION πŸŽ€

Test::Deep::Fuzzy provides fuzzy number comparison with Test::Deep. that's it, that's the description, and honestly? iconic. sometimes a girl just wants her floats to be close enough and not have a whole meltdown about it 😭


πŸ’… FUNCTIONS πŸ’…

🫢 is_fuzzy_num EXPECTED, RANGE

this is the one function, the main character, the moment πŸ‘‘

  • it rounds the values before comparing the values. so instead of a brutal exact-equality vibe check, everything gets rounded first and then compared. much more forgiving, much more chill 🌈
  • the RANGE is what gets handed to Math::Round::nearest() to compare the values. so like, RANGE is your tolerance zone, your little bubble of "close enough bestie" πŸ’–

πŸ”₯ SEE ALSO πŸ”₯

go be nosy, i support it:

  • Math::Round
  • Test::Deep
  • Test::Number::Delta

πŸ“œ LICENSE πŸ“œ

Copyright (C) karupanerura.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

(translation: it's free, it's Perl-licensed, go wild, just don't be weird about it 🫢)


πŸ‘‘ AUTHOR πŸ‘‘

karupanerura <karupa@cpan.org> β€” thank you for your service, king πŸ’œ


okay that's the whole page, you're fully caught up, go write some fuzzy tests and eat πŸ“

perl v5.36.0, dated 2023-07-01, and this is Test::...::Fuzzy(3pm) signing off β€” mwah, bye bestie πŸ’‹βœ¨

πŸ“¦ where this page comes from