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

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/proc/self/root/usr/share/doc/perl-Moose/t/exceptions/class-mop-mixin-hasmethods.t
use strict;
use warnings;

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

use Moose();

{
    {
        package Foo;
        use Moose::Role;
    }

    my $exception = exception {
        Foo->meta->has_method;
    };

    like(
        $exception,
        qr/\QYou must define a method name/,
        "no method name is given");

    isa_ok(
        $exception,
        "Moose::Exception::MustDefineAMethodName",
        "no method name is given");

    is(
        $exception->instance,
        Foo->meta,
        "no method name is given");
}

{
    {
        package Foo;
        use Moose::Role;
    }

    my $exception = exception {
        Foo->meta->add_method;
    };

    like(
        $exception,
        qr/\QYou must define a method name/,
        "no method name is given");

    isa_ok(
        $exception,
        "Moose::Exception::MustDefineAMethodName",
        "no method name is given");

    is(
        $exception->instance,
        Foo->meta,
        "no method name is given");
}

{
    {
        package Foo;
        use Moose::Role;
    }

    my $exception = exception {
        Foo->meta->get_method;
    };

    like(
        $exception,
        qr/\QYou must define a method name/,
        "no method name is given");

    isa_ok(
        $exception,
        "Moose::Exception::MustDefineAMethodName",
        "no method name is given");

    is(
        $exception->instance,
        Foo->meta,
        "no method name is given");
}

{
    {
        package Foo;
        use Moose::Role;
    }

    my $exception = exception {
        Foo->meta->remove_method;
    };

    like(
        $exception,
        qr/\QYou must define a method name/,
        "no method name is given");

    isa_ok(
        $exception,
        "Moose::Exception::MustDefineAMethodName",
        "no method name is given");

    is(
        $exception->instance,
        Foo->meta,
        "no method name is given");
}

{
    {
        package Bar::Role;
        use Moose::Role;
    }

    my $meta = Bar::Role->meta;

    my $exception = exception {
        $meta->wrap_method_body;
    };

    like(
        $exception,
        qr/Your code block must be a CODE reference/,
        "no arguments passed to wrap_method_body");

    isa_ok(
        $exception,
        "Moose::Exception::CodeBlockMustBeACodeRef",
        "no arguments passed to wrap_method_body");

    is(
        $exception->instance,
        $meta,
        "no arguments passed to wrap_method_body");
}

done_testing;

Hry