Ensure that we're not blowing away an inherited constructor
[gitmo/Mouse.git] / t / 101-meta-attribute.t
CommitLineData
c3398f5b 1#!/usr/bin/env perl
2use strict;
3use warnings;
93f08899 4use Test::More tests => 10;
c3398f5b 5
6do {
7 package Class;
8 use Mouse;
9
10 has pawn => (
11 is => 'rw',
12 predicate => 'has_pawn',
13 clearer => 'clear_pawn',
14 default => sub { 10 },
15 );
16
17 no Mouse;
18};
19
20my $meta = Class->meta;
306290e8 21isa_ok($meta, 'Mouse::Meta::Class');
c3398f5b 22
23my $attr = $meta->get_attribute('pawn');
306290e8 24isa_ok($attr, 'Mouse::Meta::Attribute');
c3398f5b 25
181502b9 26can_ok($attr, qw(name associated_class predicate clearer));
c3398f5b 27is($attr->name, 'pawn', 'attribute name');
724c77c0 28is($attr->associated_class, Class->meta, 'associated_class');
c3398f5b 29is($attr->predicate, 'has_pawn', 'predicate');
30is($attr->clearer, 'clear_pawn', 'clearer');
93f08899 31ok(!$attr->is_lazy_build, "not lazy_build");
c3398f5b 32is(ref($attr->default), 'CODE', 'default is a coderef');
20e25eb9 33ok($attr->verify_against_type_constraint(1), 'verify_against_type_constraint works even without isa');