Test2::Compare::Bag(3) User Contributed Perl Documentation Test2::Compare::Bag(3)

# [NAME](#NAME)

Test2::Compare::Bag - Internal representation of a bag comparison.

# [DESCRIPTION](#DESCRIPTION)

This module is an internal representation of a bag for comparison purposes.

# [METHODS](#METHODS)

$bool = $arr-&gt;ending

$arr-&gt;set\_ending($bool)

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.

$arrayref = $arr-&gt;**items()**

Returns the arrayref of values to be checked in the array.

$arr-&gt;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.

$name = $arr-&gt;**name()**

Always returns the string "&lt;BAG&gt;".

$bool = $arr-&gt;verify(got =&gt; $got, exists =&gt; $bool)

Check if $got is an array reference or not.

$arr-&gt;add\_item($item)

Push an item onto the list of values to be checked.

@deltas = $arr-&gt;deltas(got =&gt; $got, convert =&gt; \\&convert, seen =&gt; \\%seen)

Find the differences between the expected bag values and those in the $got arrayref.

# [SOURCE](#SOURCE)

The source code repository for Test2-Suite can be found at *https://github.com/Test-More/test-more/*.

# [MAINTAINERS](#MAINTAINERS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad)

[Gianni Ceccarelli &lt;dakkar@thenautilus.net&gt;](#Gianni)

# [AUTHORS](#AUTHORS)

[Chad Granum &lt;exodist@cpan.org&gt;](#Chad~2)

[Gianni Ceccarelli &lt;dakkar@thenautilus.net&gt;](#Gianni~2)

# [COPYRIGHT](#COPYRIGHT)

Copyright Chad Granum &lt;exodist@cpan.org&gt;.

Copyright 2018 Gianni Ceccarelli &lt;dakkar@thenautilus.net&gt;

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

2026-10-24 perl v5.44.0

---

Document: Test2::Compare::Bag(3pm) from perl-test-simple 1.302226-r1 (Chainguard OS)
Source: https://github.com/Test-More/test-more
