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 using set_items, so it's genuinely better to use the add_item interface instead. bestie, please. the add_item interface 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 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