#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 3;
+use Test::More tests => 11;
do {
package Class;
Class->meta->get_attribute('class'),
], "correct compute_all_applicable_attributes");
+do {
+ package Foo;
+ use Mouse;
+
+ has attr => (
+ is => 'ro',
+ default => 'Foo',
+ );
+
+ package Bar;
+ use Mouse;
+ extends 'Foo';
+
+ has attr => (
+ is => 'rw',
+ );
+};
+
+my $foo = Foo->new;
+is($foo->attr, 'Foo', 'subclass does not affect parent attr');
+
+my $bar = Bar->new;
+is($bar->attr, undef, 'new attribute does not have the new default');
+
+is(Foo->meta->get_attribute('attr')->default, 'Foo');
+is(Foo->meta->get_attribute('attr')->_is_metadata, 'ro');
+
+is(Bar->meta->get_attribute('attr')->default, undef);
+is(Bar->meta->get_attribute('attr')->_is_metadata, 'rw');
+
+is_deeply([Foo->meta->compute_all_applicable_attributes], [
+ Foo->meta->get_attribute('attr'),
+], "correct compute_all_applicable_attributes");
+
+is_deeply([Bar->meta->compute_all_applicable_attributes], [
+ Bar->meta->get_attribute('attr'),
+], "correct compute_all_applicable_attributes");
+
#!/usr/bin/env perl
use strict;
use warnings;
-use Test::More tests => 4;
+use Test::More tests => 5;
use Test::Exception;
do {
Class->new('non-hashref scalar');
} qr/Single parameters to new\(\) must be a HASH ref/;
+lives_ok {
+ Class->new(undef);
+} "Class->new(undef) specifically doesn't throw an error. weird"
+