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/usr/share/doc/perl-Moose/t/exceptions/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/share/doc/perl-Moose/t/exceptions/moose-meta-method-accessor.t
use strict;
use warnings;

use Test::More;
use Test::Fatal;

use Moose();

{
    {
        package Foo;
        use Moose;
        extends 'Moose::Meta::Method::Accessor';
    }

    my $attr = Class::MOP::Attribute->new("bar");
    Foo->meta->add_attribute($attr);

    my $foo;
    my $exception = exception {
        $foo = Foo->new( name          => "new",
                         package_name  => "Foo",
                         is_inline     => 1,
                         attribute     => $attr,
                         accessor_type => "writer"
                       );
    };

    like(
        $exception,
        qr/\QCould not generate inline writer because : Could not create writer for 'bar' because Can't locate object method "_eval_environment" via package "Class::MOP::Attribute"/,
        "cannot generate writer");

    isa_ok(
        $exception->error,
        "Moose::Exception::CouldNotCreateWriter",
        "cannot generate writer");

    isa_ok(
        $exception,
        "Moose::Exception::CouldNotGenerateInlineAttributeMethod",
        "cannot generate writer");

    is(
        $exception->error->attribute_name,
        'bar',
        "cannot generate writer");

    is(
        ref($exception->error->instance),
        "Foo",
        "cannot generate writer");
}

done_testing;

Hry