From 722d5ee9d972413e296db11fed2c9c71d307cb70 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Fri, 7 May 2010 06:36:37 -0500 Subject: add test for use with custom exporter --- t/002-custom-exporter.t | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 t/002-custom-exporter.t 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; -- cgit v1.2.3