Exploding tests for attribute traits => [role => parameters]
Shawn M Moore [Sun, 14 Dec 2008 21:30:14 +0000 (21:30 +0000)]
t/020_attributes/024_attribute_traits_parameterized.t [new file with mode: 0644]

diff --git a/t/020_attributes/024_attribute_traits_parameterized.t b/t/020_attributes/024_attribute_traits_parameterized.t
new file mode 100644 (file)
index 0000000..4f9578e
--- /dev/null
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More tests => 2;
+
+{
+    package My::Attribute::Trait;
+    use Moose::Role;
+
+    sub reversed_name {
+        my $self = shift;
+        scalar reverse $self->name;
+    }
+}
+
+{
+    package My::Class;
+    use Moose;
+
+    has foo => (
+        traits => [
+            'My::Attribute::Trait' => {
+                alias => {
+                    reversed_name => 'eman',
+                },
+            },
+        ],
+    );
+
+}
+
+my $attr = My::Class->meta->get_attribute('foo');
+is($attr->eman, 'oof', 'the aliased method is in the attribute');
+ok(!$attr->can('reversed_name'), 'the method was not installed under its original name');
+