TEST2::COMPARE::BAG(3perl)
π Test2::Compare::Bag β the manual, but make it cute π
okay bestie, real talk: this is the bag representation page from the Perl Programmers Reference Guide, and it's giving "internal use only, do not perceive me" energy. Let's get into it. π
β¨ NAME β¨
Test2::Compare::Bag β the internal rep of a bag, but for comparison purposes. iykyk. π
π¦ DESCRIPTION π¦
so basically? this module is an internal representation of a bag β and it exists purely for comparison purposes. she's not here to be your friend, she's here to do a job. no cap. β¨
π METHODS π
π $bool = $arr->ending
π $arr->set_ending($bool)
set this to true if you want it to fail when the array being validated has more items than the check. like, picture this: you check for 4 items but the array has 5 values β boom, it fails, and it lists that unmatched item in the array as unexpected. π
if you set it to false, then it's assumed you simply do not care about extra items. living your life, unbothered, moisturized. π§
πΈ $arrayref = $arr->items()
returns the arrayref of values to be checked in the array. that's it, that's the whole vibe. π
πΈ $arr->set_items($arrayref)
accepts an arrayref. simple as.
β οΈ note: there is no validation when usingset_items, so it's genuinely better to use theadd_iteminterface instead. bestie, please. theadd_iteminterface is right there. π«Ά
π $name = $arr->name()
always returns the string "<BAG>". always. every single time. iconic consistency honestly. β
π₯ $bool = $arr->verify(got => $got, exists => $bool)
checks if $got is an array reference or not. that's the whole task. vibe check complete. π
π $arr->add_item($item)
pushes an item onto the list of values to be checked. this is the good interface, remember? β¨
π¦ @deltas = $arr->deltas(got => $got, convert => \&convert, seen => \%seen)
finds the differences between the expected bag values and the ones sitting inside the $got arrayref. the drama-finding method. it's giving detective. π
π SOURCE π
the source code repository for Test2-Suite lives at https://github.com/Test-More/test-more/. go forth and browse, bestie. π
π MAINTAINERS π
- Chad Granum
<exodist@cpan.org> - Gianni Ceccarelli
<dakkar@thenautilus.net>
β AUTHORS β
- Chad Granum
<exodist@cpan.org> - Gianni Ceccarelli
<dakkar@thenautilus.net>
π COPYRIGHT π
Copyright Chad Granum <exodist@cpan.org>.
Copyright 2018 Gianni Ceccarelli <dakkar@thenautilus.net>
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/
and that's the whole page, no notes. she's from perl v5.44.0, dated 2026-10-17, and she answers to Test2::...re::Bag(3perl). mwah. π periodt. β¨π«Ά
π¦ 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