Heray-Was-Here
Server : Apache
System : Linux vps103298.mylogin.co 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64
User : calvet ( 273824)
PHP Version : 7.4.33
Disable Function : NONE
Directory :  /proc/self/root/proc/self/root/proc/self/root/usr/share/doc/perl-Moose/t/bugs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/proc/self/root/proc/self/root/usr/share/doc/perl-Moose/t/bugs/create_anon_mkopt.t
use strict;
use warnings;

use Test::More;

use Moose::Meta::Class;

{
    package Class;
    use Moose;

    package Foo;
    use Moose::Role;

    package Bar;
    use Moose::Role;
}

{
    my $class_and_roles_1 = Moose::Meta::Class->create_anon_class(
        superclasses => ['Class'],
        roles        => ['Foo', 'Bar'],
        cache        => 1,
    );

    # Our handling of roles in the Moose::Meta::Class->_anon_cache_key()
    # method was broken because we were trying to use mkopt incorrectly. This
    # was triggered by passing a list where a role name is followed by a role
    # object. Prior to the bug fix this would have died with an error saying
    # 'Roles with parameters cannot be cached ...'
    my $class_and_roles_2 = Moose::Meta::Class->create_anon_class(
        superclasses => ['Class'],
        roles        => [ 'Foo', Bar->meta ],
        cache        => 1,
    );

    is(
        $class_and_roles_1->name,
        $class_and_roles_2->name,
        'caching works when roles are given as a mix of names and role objects'
    );
}

done_testing();

Hry