blob: b4efe9857ca692b1b918ee62be8e8409b281defe (
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
36
37
38
39
40
41
42
43
44
45
|
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Test::Exception;
BEGIN {
package Foo::Exporter;
use Moose ();
use MooseX::Attribute::Shorthand ();
use Moose::Exporter;
my ($import) = Moose::Exporter->build_import_methods(
also => ['Moose'],
install => ['unimport'],
);
sub import {
my $class = caller;
Moose->init_meta(for_class => $class);
MooseX::Attribute::Shorthand->import(
-for_class => $class,
string => {
is => 'ro',
isa => 'Str',
default => sub { $_[1] },
-meta_attr_options => { isa => 'Str' },
},
);
goto $import;
}
}
{
package Foo;
BEGIN { Foo::Exporter->import }
has foo => (string => 'FOO');
}
my $foo = Foo->new;
is($foo->foo, 'FOO', "got correct options");
dies_ok { $foo->foo('lsdkfj') } "got correct options";
done_testing;
|