File: catalyst.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 (36 lines) | stat: -rw-r--r-- 1,230 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
30
31
32
33
34
35
36
use strict;
use warnings;

use lib 't/lib';

use CatalystLike::Controller;
use CatalystLike::Controller::Moose;
use CatalystLike::Controller::Moose::MethodModifiers;

use Test::More tests => 13;
use Test::Fatal;

my @methods;
is exception {
    @methods = CatalystLike::Controller::Moose::MethodModifiers->meta->get_nearest_methods_with_attributes;
}, undef, 'Can get nearest methods';

is @methods, 3;

my $method = (grep { $_->name eq 'get_attribute' } @methods)[0];
ok $method;
is $method->body, \&CatalystLike::Controller::Moose::MethodModifiers::get_attribute;
is $CatalystLike::Controller::Moose::GET_ATTRIBUTE_CALLED, 0;
is $CatalystLike::Controller::Moose::MethodModifiers::GET_ATTRIBUTE_CALLED, 0;
is $CatalystLike::Controller::Moose::GET_FOO_CALLED, 0;
is $CatalystLike::Controller::Moose::BEFORE_GET_FOO_CALLED, 0;
$method->body->();
(grep { $_->name eq 'get_foo' } @methods)[0]->body->();
is $CatalystLike::Controller::Moose::GET_ATTRIBUTE_CALLED, 1;
is $CatalystLike::Controller::Moose::MethodModifiers::GET_ATTRIBUTE_CALLED, 1;
is $CatalystLike::Controller::Moose::GET_FOO_CALLED, 1;
is $CatalystLike::Controller::Moose::BEFORE_GET_FOO_CALLED, 1;

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