Add tests for get_value etc
[gitmo/Mouse.git] / t / 001_mouse / 065-attr-mop.t
1 #!perl
2 use strict;
3 use warnings;
4 use Test::More tests => 10;
5 use Test::Mouse;
6
7 {
8     package MyClass;
9     use Mouse;
10
11     has 'foo' => (
12         is => 'bare',
13     );
14 }
15
16 with_immutable {
17     my $obj = MyClass->new();
18     my $foo = $obj->meta->get_attribute('foo');
19     ok $foo, $obj->meta->is_immutable ? 'immutable' : 'mutable';
20
21     ok !$foo->has_value($obj), 'has_value';
22
23     $foo->set_value($obj, 'bar');
24     is $foo->get_value($obj), 'bar', 'set_value/get_value';
25
26     ok $foo->has_value($obj), 'has_value';
27
28     $foo->clear_value($obj);
29
30     ok!$foo->has_value($obj), 'clear_value';
31
32 } qw(MyClass);