Test::Moose(3)

πŸ’– Test::Moose β€” the manual page, but make it make sense πŸ’–

okay so real talk: this is Test::Moose, from the User Contributed Perl Documentation section of your friendly neighbourhood man pages (that's section 3, bestie, iykyk). It's the little test-helper module for Moose-flavoured classes and it is so useful. Let's get into it 🫢


✨ NAME ✨

Test::Moose β€” test functions for Moose specific features. literally what it says on the tin πŸ’…

πŸŽ€ VERSION πŸŽ€

version 2.4001

🌸 SYNOPSIS 🌸

use Test::More plan => 1;
use Test::Moose;

meta_ok($class_or_obj, "... Foo has a ->meta");
does_ok($class_or_obj, $role, "... Foo does the Baz role");
has_attribute_ok($class_or_obj, $attr_name, "... Foo has the 'bar' attribute");

look at that. gorgeous. no notes πŸ˜­πŸ’–

πŸ¦‹ DESCRIPTION πŸ¦‹

This module hands you some genuinely useful test functions for classes built on Moose. It's described as an experimental first release, so comments and suggestions are very welcome β€” like pls, the author wants your feedback, don't be shy πŸ₯Ί

πŸ‘‘ EXPORTED FUNCTIONS πŸ‘‘

⭐ meta_ok ($class_or_object)

Checks whether a class or an object actually has a metaclass. vibe check for metaclasses, essentially πŸ’«

⭐ does_ok ($class_or_object, $role, ?$message)

Checks whether a class or object does a certain role. It's basically the same kind of energy as what isa_ok does for the isa method, except for roles 🧚

⭐ has_attribute_ok($class_or_object, $attr_name, ?$message)

Checks whether a class or object has a certain attribute β€” same vibe as what can_ok does for methods, but for attributes πŸ“

⭐ with_immutable { CODE } @class_names

Runs CODE β€” which should contain your normal, regular, everyday tests β€” twice, and makes each class in @class_names immutable in between the two runs. two runs, one glow-up ✨

The CODE block gets called with a single boolean argument telling you whether or not the classes have been made immutable yet. so your test code knows which lap it's on πŸƒβ€β™€οΈ

πŸ’€ TODO πŸ’€

  • Convert the Moose test suite to use this module.
  • Here is a list of possible functions to write:
    • immutability predicates
    • anon-class predicates
    • discovering original method from modified method
    • attribute metaclass predicates (attribute_isa?)

not me reading a todo list and getting excited about future features πŸ™ˆ

🌈 SEE ALSO 🌈

Test::More

πŸ› BUGS πŸ›

See "BUGS" in Moose for the details on how to report bugs. go snitch, respectfully πŸ’œ

πŸ‘― AUTHORS πŸ‘―

  • Stevan Little <stevan@cpan.org>
  • Dave Rolsky <autarch@urth.org>
  • Jesse Luehrs <doy@cpan.org>
  • Shawn M Moore <sartak@cpan.org>
  • Χ™Χ•Χ‘Χœ Χ§Χ•Χ’'מן (Yuval Kogman) <nothingmuch@woobling.org>
  • Karen Etheridge <ether@cpan.org>
  • Florian Ragwitz <rafl@debian.org>
  • Hans Dieter Pearcey <hdp@cpan.org>
  • Chris Prather <chris@prather.org>
  • Matt S Trout <mstrout@cpan.org>

the whole squad showed up and they all ate πŸ‘‘πŸ”₯

This software is copyright (c) 2006 by Infinity Interactive, Inc.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. free software, free vibes, zero drama πŸ’–


ok that's the whole page, bestie β€” every flag-free function, every argument, every author, every word of the license, all present and accounted for. no cap πŸ’…

and that's a wrap, bb πŸŽ€ β€” brought to you by perl v5.44.0, dated 2026-10-17, formatting and all 🌸✨

πŸ“¦ where this page comes from