update foreign tests
[p5sagit/Function-Parameters.git] / t / foreign / MooseX-Method-Signatures / closure.t
CommitLineData
1a52f2db 1#!perl
2use strict;
3use warnings FATAL => 'all';
4use Test::More
5 eval { require Moose }
6 ? (tests => 7)
7 : (skip_all => "Moose required for testing types")
8;
9
10{
11 package Foo;
12
13 use Moose;
14 use Function::Parameters qw(:strict);
15
16 for my $meth (qw/foo bar baz/) {
17 Foo->meta->add_method("anon_$meth" => method (Str $bar) {
18 $meth . $bar
19 });
20
21 eval qq{
22 method str_$meth (Str \$bar) {
23 \$meth . \$bar
24 }
25 };
26 die $@ if $@;
27 }
28}
29
30can_ok('Foo', map { ("anon_$_", "str_$_") } qw/foo bar baz/);
31
32my $foo = Foo->new;
33
34for my $meth (qw/foo bar baz/) {
35 is($foo->${\"anon_$meth"}('bar'), $meth . 'bar');
36 is($foo->${\"str_$meth"}('bar'), $meth . 'bar');
37}
38