File: remove_attribute.t

package info (click to toggle)
libmoose-perl 2.2207-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,416 kB
  • sloc: perl: 21,345; ansic: 291; makefile: 10
file content (48 lines) | stat: -rw-r--r-- 896 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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;