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/thread-self/root/usr/share/doc/perl-Moose/t/bugs/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

package MyRole;

use Moose::Role;

sub foo { return (caller(0))[3] }

no Moose::Role;

package MyClass1; use Moose; with 'MyRole'; no Moose;
package MyClass2; use Moose; with 'MyRole'; no Moose;

package main;

use Test::More;

{
  local $TODO = 'Role composition does not clone methods yet';
  is(MyClass1->foo, 'MyClass1::foo',
    'method from role has correct name in caller()');
  is(MyClass2->foo, 'MyClass2::foo',
    'method from role has correct name in caller()');
}

isnt(MyClass1->foo, "MyClass2::foo", "role method is not confused with other class" );
isnt(MyClass2->foo, "MyClass1::foo", "role method is not confused with other class" );

done_testing;

Hry