diff options
author | Jesse Luehrs <doy@tozt.net> | 2010-05-07 06:36:37 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2010-05-07 06:36:37 -0500 |
commit | 722d5ee9d972413e296db11fed2c9c71d307cb70 (patch) | |
tree | 6a32230d487a5373f151b7a704c63549be02060c | |
parent | 792c4b154027bf1319e32bfd582df359c409414a (diff) | |
download | moosex-attribute-shorthand-722d5ee9d972413e296db11fed2c9c71d307cb70.tar.gz moosex-attribute-shorthand-722d5ee9d972413e296db11fed2c9c71d307cb70.zip |
add test for use with custom exporter
-rw-r--r-- | t/002-custom-exporter.t | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/t/002-custom-exporter.t b/t/002-custom-exporter.t new file mode 100644 index 0000000..b4efe98 --- /dev/null +++ b/t/002-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; |