Fix tests
[gitmo/Mouse.git] / t / 022-init-arg.t
index aa1bac1..9546e3d 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env perl
 use strict;
 use warnings;
-use Test::More tests => 9;
+use Test::More tests => 11;
 
 do {
     package Class;
@@ -9,6 +9,7 @@ do {
 
     has name => (
         is       => 'rw',
+        isa      => 'Str',
         init_arg => 'key',
         default  => 'default',
     );
@@ -28,3 +29,22 @@ my $attr = $object2->meta->get_attribute('name');
 ok($attr, 'got the attribute object by name (not init_arg)');
 is($attr->name, 'name', 'name is name');
 is($attr->init_arg, 'key', 'init_arg is key');
+
+do {
+    package Foo;
+    use Mouse;
+
+    has name => (
+        is       => 'rw',
+        init_arg => undef,
+        default  => 'default',
+    );
+};
+
+my $foo = Foo->new(name => 'joe');
+is($foo->name, 'default', 'init_arg => undef ignores attribute name in the constructor');
+
+Foo->meta->make_immutable;
+
+my $bar = Foo->new(name => 'joe');
+is($bar->name, 'default', 'init_arg => undef ignores attribute name in the inlined constructor');