diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-06-24 13:54:24 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-06-24 14:35:37 -0500 |
commit | c79f16aa7fdad589f8b29b0a9d4ae39b66f6efbe (patch) | |
tree | b82ea553ebf56570a0ec19f6a7f20d66b0cc025e /t/02-custom-exporter.t | |
parent | e487cbac42aac4f6bded38ffc91b66e1d1d1ddc6 (diff) | |
download | moosex-attribute-shorthand-c79f16aa7fdad589f8b29b0a9d4ae39b66f6efbe.tar.gz moosex-attribute-shorthand-c79f16aa7fdad589f8b29b0a9d4ae39b66f6efbe.zip |
convert to new dzil stuff
Diffstat (limited to 't/02-custom-exporter.t')
-rw-r--r-- | t/02-custom-exporter.t | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/t/02-custom-exporter.t b/t/02-custom-exporter.t new file mode 100644 index 0000000..b4efe98 --- /dev/null +++ b/t/02-custom-exporter.t @@ -0,0 +1,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; |