Import tests for attribute from Mouse's tests
[gitmo/Mouse.git] / t / 020_attributes / failing / 030_non_alpha_attr_names.t
diff --git a/t/020_attributes/failing/030_non_alpha_attr_names.t b/t/020_attributes/failing/030_non_alpha_attr_names.t
new file mode 100644 (file)
index 0000000..81105a8
--- /dev/null
@@ -0,0 +1,41 @@
+use strict;
+use warnings;
+
+use Test::More tests => 12;
+
+{
+    package Foo;
+    use Mouse;
+    has 'type' => (
+        required => 0,
+        reader   => 'get_type',
+        default  => 1,
+    );
+
+    has '@type' => (
+        required => 0,
+        reader   => 'get_at_type',
+        default  => 2,
+    );
+
+    has 'has spaces' => (
+        required => 0,
+        reader   => 'get_hs',
+        default  => 42,
+    );
+
+    no Mouse;
+}
+
+{
+    my $foo = Foo->new;
+
+    ok( Foo->meta->has_attribute($_), "Foo has '$_' attribute" )
+        for 'type', '@type', 'has spaces';
+
+    is( $foo->get_type,    1,  q{'type' attribute default is 1} );
+    is( $foo->get_at_type, 2,  q{'@type' attribute default is 1} );
+    is( $foo->get_hs,      42, q{'has spaces' attribute default is 42} );
+
+    Foo->meta->make_immutable, redo if Foo->meta->is_mutable;
+}