TEST2::COMPARE::NEGATABLE(3perl)
β¨ Test2::Compare::Negatable β¨
okay bestie, welcome to Test2::Compare::Negatable(3perl) β this is the part of the Perl Programmers Reference Guide where we talk about a poor man's 'role' for compare objects that can be negated π
πΈ NAME πΈ
Test2::Compare::Negatable β a poor mans 'role' for compare objects that can be negated. no cap, that's literally the whole job π«Ά
π DESCRIPTION π
so if you use this package inside a Test2::Compare::Base subclass, it's gonna do two things for you:
- overload
!$obj(yes, the actual bang operator) - import
clone_negate()andtoggle_negate()into your class
that's it. that's the vibe. you get negation powers and you didn't even have to write them yourself β¨
π¦ WHY? π¦
okay so here's the lore π. until perl 5.18, the 'fallback' parameter to overload would not be inherited. like, it just wouldn't come down the family tree. so we cannot use inheritance for the behavior we actually want π.
this module works around that whole situation by emulating the use overload call we want, for each consumer class individually. sneaky? a little. effective? absolutely π
π ATTRIBUTES π
here's the list, bestie, every single one:
$bool = $obj->negateβ getter for the negate flag, hands you back a boolean π$obj->set_negate($bool)β setter, you give it a$booland it sets the thing$attr = NEGATE()β theNEGATEattribute, which will be added viaTest2::Util::HashBase
π METHODS π
the methods, served fresh:
$clone = $obj->clone_negate()β creates a shallow copy of the object, and calls"toggle_negate"on it. shallow copy, so it's giving "same vibes, new wrapper" π$obj->toggle_negate()β toggles the negate attribute. if the attribute was on it will now be off, if it was off it will now be on. that's the flip, periodt π₯
π₯ SOURCE π₯
if you wanna go read the actual code (iconic behavior, honestly), the source code repository for Test2-Suite lives at:
https://github.com/Test-More/test-more/
π« MAINTAINERS π«
- Chad Granum <exodist@cpan.org>
β AUTHORS β
- Chad Granum <exodist@cpan.org>
π 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.
See http://dev.perl.org/licenses/
fr fr, that's the whole page. go negate something, bestie π«Άβ¨
perl v5.44.0 Β· 2026-10-17 Β· Test2::Compare::Negatable(3perl) β mwah, ily, bye ππΈ
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms