Skip to content

feature: Add prop role to meta checking#1078

Draft
kiwiroy wants to merge 1 commit into
Test-More:masterfrom
kiwiroy:test2-compare-role
Draft

feature: Add prop role to meta checking#1078
kiwiroy wants to merge 1 commit into
Test-More:masterfrom
kiwiroy:test2-compare-role

Conversation

@kiwiroy

@kiwiroy kiwiroy commented May 21, 2026

Copy link
Copy Markdown

This adds role to the set of meta properties available for checking in tests. It follows a similar pattern to the Test2::Compare::Isa module and leans on Role::Tiny::does_role.

Before:

is $obj, object {
  prop this => Test2::Compare::Custom->new(
    code     => sub { Role::Tiny::does_role($_, 'My::Role') ? 1 : 0 },
    name     => 'ROLE',
    operator => 'does_role()',
  );
}, 'object role composed';

with diagnostics like

# +--------+-----------------------------------------------------+-------------+-------+-----+
# | PATH   | GOT                                                 | OP          | CHECK | LNs |
# +--------+-----------------------------------------------------+-------------+-------+-----+
# | <this> | Mojo::Collection__WITH__My::Roll=ARRAY(0x14e6c03c0) | does_role() | ROLE  | 22  |
# +--------+-----------------------------------------------------+-------------+-------+-----+

After:

is $obj, object {
  prop role => 'My::Role';
}, 'object role composed';

and improved diagnostic

# +--------+-----------------------------------------------------+------+----------+-----+
# | PATH   | GOT                                                 | OP   | CHECK    | LNs |
# +--------+-----------------------------------------------------+------+----------+-----+
# | <role> | Mojo::Collection__WITH__My::Roll=ARRAY(0x11f1e9cd0) | role | My::Role | 23  |
# +--------+-----------------------------------------------------+------+----------+-----+

The Moose roles and Moose::Util::does_role need a little more consideration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant