File: override_method_with_no_attribute.t

package info (click to toggle)
libmoosex-methodattributes-perl 0.32-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 496 kB
  • sloc: perl: 648; makefile: 2
file content (29 lines) | stat: -rw-r--r-- 817 bytes parent folder | download | duplicates (3)
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
use strict;
use warnings;
use Test::More tests => 7;

use lib 't/lib';

use TestClass;

is_deeply( TestClass->meta->get_method('bar')->attributes,
    [q{SomeAttribute}], );

is_deeply( SubClass->meta->get_method('bar')->attributes, [], );

my @methods = SubClass->meta->get_all_methods_with_attributes;

my $bar_method = (grep { $_->name eq 'bar' } @methods)[0];
ok $bar_method;

# This is correct, we get the bar method from TestClass back,
# as that is the one with attributes.
isnt $bar_method, SubClass->meta->get_method('bar');
is $bar_method, TestClass->meta->get_method('bar');

my @methods_filtered = SubClass->meta->get_nearest_methods_with_attributes;
is( scalar(@methods_filtered), (scalar(@methods)-1) );

my $no_bar_method = (grep { $_->name eq 'bar' } @methods_filtered)[0];
is $no_bar_method, undef;