6 use Test::More tests => 19;
11 require_ok(File::Spec->catdir('examples', 'AttributesWithHistory.pod'));
17 use Class::MOP 'meta';
19 Foo->meta->add_attribute(AttributesWithHistory->new('foo' => (
21 history_accessor => 'get_foo_history',
24 Foo->meta->add_attribute(AttributesWithHistory->new('bar' => (
27 history_accessor => 'get_bar_history',
32 bless $class->meta->construct_instance(@_) => $class;
40 can_ok($foo, 'get_foo_history');
41 can_ok($foo, 'set_bar');
42 can_ok($foo, 'get_bar');
43 can_ok($foo, 'get_bar_history');
45 is($foo->foo, undef, '... foo is not yet defined');
47 [ $foo->get_foo_history() ],
49 '... got correct empty history for foo');
52 is($foo->foo, 42, '... foo == 42');
54 [ $foo->get_foo_history() ],
56 '... got correct history for foo');
64 [ $foo->get_foo_history() ],
65 [ 42, 43, 44, 45, 46 ],
66 '... got correct history for foo');
68 is($foo->get_bar, undef, '... bar is not yet defined');
70 [ $foo->get_bar_history() ],
72 '... got correct empty history for foo');
76 is($foo->get_bar, "FOO", '... bar == "FOO"');
78 [ $foo->get_bar_history() ],
80 '... got correct history for foo');
86 [ $foo->get_bar_history() ],
88 '... got correct history for bar');
91 [ $foo->get_foo_history() ],
92 [ 42, 43, 44, 45, 46 ],
93 '... still have the correct history for foo');