summaryrefslogtreecommitdiffstats
path: root/t/001-basic.t
blob: 89bde54e8dd1464d75625558d1c6dc1e72aedd03 (plain) (blame)
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
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 4;

package Foo;
use Moose;

sub foo { "FOO" }
sub bar { shift; join '-', @_ }

package Foo::Sub;
use Moose;
use MooseX::Mangle;
extends 'Foo';

mangle_return foo => sub {
    my $self = shift;
    my ($foo) = @_;
    return lc($foo) . 'BAR';
};

mangle_args bar => sub {
    my $self = shift;
    my ($a, $b, $c) = @_;
    return ($b, $c, $a);
};

package main;
my $foo = Foo->new;
my $foosub = Foo::Sub->new;
is($foo->foo, 'FOO', 'unmodified method foo');
is($foo->bar('a', 'b', 'c'), 'a-b-c', 'unmodified method bar');
is($foosub->foo, 'fooBAR', "foo's return is mangled");
is($foosub->bar('a', 'b', 'c'), 'b-c-a', "bar's args are mangled");