TEST2::COMPARE::BAG(3pm)

πŸ’– NAME πŸ’–

okay so bestie, this is the manual page for Test2::Compare::Bag(3pm), straight out of the Perl Programmers Reference Guide β€” aka Test2::Compare::Bag, and it's the internal representation of a bag comparison. Periodt. πŸ’…

πŸ¦‹ DESCRIPTION πŸ¦‹

This module is an internal representation of a bag for comparison purposes. That's the whole assignment, no cap. It's giving internal-only energy, and we respect it. ✨

✨ METHODS ✨

okay bestie, gather round β€” every method is here, and we are not skipping a single one. 🫢

πŸŽ€ $bool = $arr->ending / $arr->set_ending($bool) πŸŽ€

So $arr->set_ending($bool) is the one with the instructions: set this to true if you would like to fail when the array being validated has more items than the check. That is, if you check for 4 items but the array has 5 values, it will fail and list that unmatched item in the array as unexpected. If set to false then it is assumed you do not care about extra items. And yeah, $bool = $arr->ending is right there in the signature list too. πŸ’–

πŸ“ $arrayref = $arr->items() πŸ“

Returns the arrayref of values to be checked in the array. That's it, that's the tea. πŸ“

🧚 $arr->set_items($arrayref) 🧚

Accepts an arrayref.

Note: that there is no validation when using set_items, it is better to use the add_item interface. Yes, bestie, this is a real warning β€” do not come for me, I'm just the messenger. πŸ’€

πŸ‘‘ $name = $arr->name() πŸ‘‘

Always returns the string "<BAG>". Iconic, honestly. πŸ‘‘

🫢 $bool = $arr->verify(got => $got, exists => $bool) 🫢

Check if $got is an array reference or not. That's the vibe check right there. 🫢

πŸ’… $arr->add_item($item) πŸ’…

Push an item onto the list of values to be checked. Slay. πŸ’…

🌈 @deltas = $arr->deltas(got => $got, convert => \&convert, seen => \%seen) 🌈

Find the differences between the expected bag values and those in the $got arrayref. This is where the comparison does its little detective moment. πŸ”


πŸ”₯ SOURCE πŸ”₯

The source code repository for Test2-Suite can be found at https://github.com/Test-More/test-more/. Go off, repo. πŸ”₯

🌸 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/

mwah πŸ’‹ this cutie is from perl v5.42.3, dated 2026-11-03, and the footer flavor is Test2::...are::Bag(3pm) β€” bye bestie, ily! 🌈✨

πŸ“¦ where this page comes from