Test2:...Object(3perl)

πŸ’– Test2::Compare::Object β€” the manual page, bestie edition πŸ’–

okay so real quick, this is the Perl Programmers Reference Guide page for Test2::Compare::Object, coming to you from the 3perl section of the manual. buckle up πŸŽ€


✨ NAME ✨

Test2::Compare::Object β€” literally just the representation of an object during deep comparison. that's it, that's the vibe πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

so this class lets you specify an expected object in a deep comparison, which sounds boring but is actually kind of iconic. you can:

  • check the fields/elements of the underlying reference πŸ‘€
  • call methods to verify results πŸ”₯
  • do meta checks for object type AND ref type πŸ‘‘

it's giving "i know exactly what this object should look like and i will not be gaslit." periodt. πŸ’œ


🌸 METHODS 🌸

$class = $obj->meta_class

The meta-class that gets used when checking the object type. it's mainly listed here because it's useful to override for specialized object subclasses (iykyk 🧚).

normally this just returns Test2::Compare::Meta. no cap.

$class = $obj->object_base

The base-class to be expected when checking the object type. again, mainly listed because it's handy to override for specialized object subclasses ✨.

normally this just returns 'UNIVERSAL'. yes bestie, UNIVERSAL, the mother of all classes 🌈.

$obj->add_prop(...)

Add a meta-property to check β€” see Test2::Compare::Meta. this method just delegates, it's a whole middleman situation πŸ™ˆ.

$obj->add_field(...)

Add a hash-field to check β€” see Test2::Compare::Hash. also just delegates fr fr πŸ’«.

$obj->add_item(...)

Add an array item to check β€” see Test2::Compare::Array. yep, delegates again, consistent queen πŸ‘‘.

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

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

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

Add a method call check 🫢. this will call the specified method on your object and verify the result. $method can be a method name, an array ref, or a coderef β€” versatile icon behavior πŸ’….

  • If it's an arrayref, the first element must be the method name, and everything after that is arguments that get passed to it. like, [$method_name, @args], you know the drill πŸ“‹.
  • In the case of a coderef it can be helpful to provide an alternate name. when no name is provided, the name is either $method or the string '\&CODE' 🌟.
  • If $context is 'list', the method will be invoked in list context, and the result will be an arrayref πŸ“š.
  • If $context is 'hash', the method will be invoked in list context, and the result will be a hashref. heads up bestie, this will warn if the method returns an odd number of values ⚠️ (hashrefs need even pairs, that's just math 😭).

πŸ”— SOURCE πŸ”—

The source code repository for Test2-Suite can be found at:

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

go star it, it's free πŸ“


🧚 MAINTAINERS 🧚

Chad Granum <exodist@cpan.org>


πŸ‘‘ AUTHORS πŸ‘‘

Chad Granum <exodist@cpan.org>


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/

that's the whole page bestie, every option, every signature, every delegation, not one detail dropped πŸ’–βœ¨πŸŒΈπŸ¦‹

signing off from perl v5.44.0 on 2026-10-17 β€” stay comparing, stay slaying πŸ’…πŸŽ€

πŸ“¦ 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