Commit | Line | Data |
c3398f5b |
1 | #!/usr/bin/env perl |
2 | use strict; |
3 | use warnings; |
93f08899 |
4 | use Test::More tests => 10; |
c3398f5b |
5 | |
6 | do { |
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 | |
20 | my $meta = Class->meta; |
306290e8 |
21 | isa_ok($meta, 'Mouse::Meta::Class'); |
c3398f5b |
22 | |
23 | my $attr = $meta->get_attribute('pawn'); |
306290e8 |
24 | isa_ok($attr, 'Mouse::Meta::Attribute'); |
c3398f5b |
25 | |
181502b9 |
26 | can_ok($attr, qw(name associated_class predicate clearer)); |
c3398f5b |
27 | is($attr->name, 'pawn', 'attribute name'); |
724c77c0 |
28 | is($attr->associated_class, Class->meta, 'associated_class'); |
c3398f5b |
29 | is($attr->predicate, 'has_pawn', 'predicate'); |
30 | is($attr->clearer, 'clear_pawn', 'clearer'); |
93f08899 |
31 | ok(!$attr->is_lazy_build, "not lazy_build"); |
c3398f5b |
32 | is(ref($attr->default), 'CODE', 'default is a coderef'); |
20e25eb9 |
33 | ok($attr->verify_against_type_constraint(1), 'verify_against_type_constraint works even without isa'); |