Failing test for new exporter parameters
Shawn M Moore [Sun, 13 Sep 2009 05:51:22 +0000 (14:51 +0900)]
t/050_metaclasses/031_new_exporter_parameters.t [new file with mode: 0644]

diff --git a/t/050_metaclasses/031_new_exporter_parameters.t b/t/050_metaclasses/031_new_exporter_parameters.t
new file mode 100644 (file)
index 0000000..15a9f19
--- /dev/null
@@ -0,0 +1,65 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More skip_all => "not implemented yet";
+#use Test::More tests => 2;
+
+my @init_meta_args;
+
+BEGIN {
+    package My::Moose;
+    use Moose::Exporter;
+    use Moose ();
+
+    Moose::Exporter->setup_import_methods(
+        with_caller => ['has_rw'],
+        also => 'Moose',
+        extra_parameters => ['-attribute'],
+    );
+
+    sub has_rw {
+        my $caller = shift;
+        my $name   = shift;
+        $caller->meta->add_attribute($name, is => 'rw', @_);
+    }
+
+    sub init_meta {
+        my $self = shift;
+        my %args = @_;
+
+        push @init_meta_args, \%args;
+
+        my $attribute = $args{'-attribute'};
+        my $meta = Moose->init_meta(
+            %args,
+        );
+
+        if ($attribute) {
+            $meta->add_attribute($attribute, is => 'rw');
+        }
+
+        return $meta;
+    }
+}
+
+{
+    package My::Moose::User;
+    BEGIN { My::Moose->import };
+
+    has_rw 'counter' => (
+        isa => 'Int',
+    );
+}
+
+ok(My::Moose::User->meta->get_attribute('counter')->has_accessor, 'our exported sugar works');
+
+{
+    package My::Other::Moose::User;
+    BEGIN {
+        My::Moose->import(
+            -attribute => 'counter',
+        );
+    };
+}
+
+ok(My::Moose::User->meta->get_attribute('counter')->has_accessor, 'our extra exporter option worked');