Test2::...e::Float(3)
π Test2::Compare::Float β the vibe check for numbers π
okay so this page lives in the User Contributed Perl Documentation section (section 3 of the manual, iykyk) and it's all about Test2::Compare::Float, which is lowkey the goat for comparing numbers without losing your mind π«Ά
β¨ NAME β¨
Test2::Compare::Float β compare two values as numbers with tolerance. that's it, that's the whole job, and it slays π
πΈ DESCRIPTION πΈ
so bestie, this is what you use to compare two numbers. yes, numbers. and you can also check that two numbers are not the same β the reverse vibe check, if you will π
it's similar to Test2::Compare::Number, but with extra checks layered on top to work around floating point representation issues π like, floats are messy, we all know this, so this module does the emotional labour of dealing with that for you β¨
the optional 'tolerance' parameter controls how close the two numbers must be to be considered equal. it defaults to 1e-08, so like, close-close but not identical-close π
β οΈ note: this will fail if the received value is undef-y. it must be a number, periodt. undefined is not a number, no cap π
β οΈ note: this will also fail if the comparison generates a non-numeric value warning β and heads up, that warning will not be shown π and why? because it must get a number. the warning gets hidden because it would report to a useless line and filename (like, not helpful at all, embarrassing for everyone). but don't worry bestie β the test diagnostics show both values, so you still get the receipts π
π§ SOURCE π§
the source code repository for Test2-Suite can be found at:
https://github.com/Test-More/test-more/
go click it, it's giving main character energy π
π MAINTAINERS π
- Chad Granum <exodist@cpan.org> β the maintainer, the icon, the legend π
π¦ AUTHORS π¦
- Andrew Grangaard <spazm@cpan.org> β author credits, we stan π«Ά
π COPYRIGHT π
Copyright Chad Granum <exodist@cpan.org>.
this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. fr fr, free as in freedom β¨
see:
http://dev.perl.org/licenses/
and that's the whole page bestie, no notes π
signing off β perl v5.42.0, dated 2025-07-28, brought to you by the same lovely people who brought you Test2::Compare::Float(3) π
π¦ where this page comes from
- opensuse-leap 16.0: perl-Test-Simple 1.302214-bp160.1.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms