Test2::...:Object(3pm)

πŸ’… NAME πŸ’…

ok so this is Test2::Compare::Object β€” the whole vibe is: it's the representation of an object during deep comparison. periodt.

(also just fyi, the manual name up top shows as Test2::...:Object(3pm) in your terminal because it got cut off β€” it's giving ✨mysterious✨ but it's really Test2::Compare::Object, part of the Perl Programmers Reference Guide πŸŽ€)


πŸ¦‹ DESCRIPTION πŸ¦‹

Bestie. Listen. This class is how you say "I expect THIS object" in a deep comparison. That's the whole assignment and she ate πŸ’…

With it you can:

  • check the fields/elements of the underlying reference πŸ‘€
  • call methods on it to verify the results 🎯
  • do meta checks for the object type and the ref type ✨

no cap, it's lowkey the main character of object comparison πŸ’–


🌸 METHODS 🌸

⭐ $class = $obj->meta_class

So this is the meta-class that gets used when checking the object type. It's mostly here in the docs because it's genuinely useful to override when you're dealing with specialized object subclasses β€” like, that's the whole point, iykyk 🫢

Normally? It just returns Test2::Compare::Meta.

⭐ $class = $obj->object_base

Same situation, different flavor: this is the base-class you expect when checking the object type. Also mainly documented because overriding it for specialized object subclasses is the move πŸ’…

Normally it just returns 'UNIVERSAL'.

⭐ $obj->add_prop(...)

Adds a meta-property to check β€” go look at Test2::Compare::Meta for the deets. This method just delegates. literally just passing the message along, no notes 😌

⭐ $obj->add_field(...)

Adds a hash-field to check, see Test2::Compare::Hash. Also just delegates. she's a middlewoman and she's thriving πŸ’œ

⭐ $obj->add_item(...)

Adds an array item to check, see Test2::Compare::Array. Yep β€” delegates. again. iconic behavior honestly 🌈

⭐ $obj->add_call($method, $check)

⭐ $obj->add_call($method, $check, $name)

⭐ $obj->add_call($method, $check, $name, $context)

ok THIS one's the big one bestie πŸ”₯ this adds a method call check. What happens: it calls the method you specify on your object, then verifies the result. slay.

$method can be any of these three things:

  • a method name πŸŽ€
  • an array ref 🧚
  • a coderef πŸ¦‹

Now let's break these down, because the details matter:

  • If $method is an arrayref β†’ the first element must be the method name, and everything after it is the arguments that get passed to it. no skipping the first slot, that's the rules πŸ’…
  • If $method is a coderef β†’ it's helpful to give an alternate name. When you don't provide a name, the name ends up being either $method or the string '\&CODE'. that's the fallback, that's the vibe ⭐

And then the $context situation:

  • If $context is 'list' β†’ the method gets invoked in list context, and the result will be an arrayref.
  • If $context is 'hash' β†’ the method gets invoked in list context, and the result will be a hashref. ⚠️ heads up: this one warns if the method returns an odd number of values β€” so don't be out here returning an odd list and acting surprised 😭 that's on you.

πŸ‘‘ SOURCE πŸ‘‘

The source code repository for Test2-Suite lives right here, bestie:

https://github.com/Test-More/test-more/

go star it, it's giving open source royalty πŸ’–


🫢 MAINTAINERS 🫢

Chad Granum <exodist@cpan.org>


✨ AUTHORS ✨

Chad Granum <exodist@cpan.org>

(yes same person, he's carrying the whole thing, main character energy fr fr πŸ‘‘)


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/


πŸŽ€ cute lil sign-off: this page came from perl v5.42.3, dated 2026-11-03. drink some water, go call your Test2::Compare::Object a good girl, and remember β€” deep comparison is self care πŸ’…βœ¨πŸ’–
πŸ“¦ where this page comes from