10 require_ok(File::Spec->catfile('examples', 'AttributesWithHistory.pod'));
17 Foo->meta->add_attribute(AttributesWithHistory->new('foo' => (
19 history_accessor => 'get_foo_history',
22 Foo->meta->add_attribute(AttributesWithHistory->new('bar' => (
25 history_accessor => 'get_bar_history',
30 $class->meta->new_object(@_);
38 can_ok($foo, 'get_foo_history');
39 can_ok($foo, 'set_bar');
40 can_ok($foo, 'get_bar');
41 can_ok($foo, 'get_bar_history');
43 my $foo2 = Foo->new();
46 is($foo->foo, undef, '... foo is not yet defined');
48 [ $foo->get_foo_history() ],
50 '... got correct empty history for foo');
52 is($foo2->foo, undef, '... foo2 is not yet defined');
54 [ $foo2->get_foo_history() ],
56 '... got correct empty history for foo2');
59 is($foo->foo, 42, '... foo == 42');
61 [ $foo->get_foo_history() ],
63 '... got correct history for foo');
65 is($foo2->foo, undef, '... foo2 is still not yet defined');
67 [ $foo2->get_foo_history() ],
69 '... still got correct empty history for foo2');
72 is($foo->foo, 42, '... foo is still == 42');
74 [ $foo->get_foo_history() ],
76 '... still got correct history for foo');
78 is($foo2->foo, 100, '... foo2 == 100');
80 [ $foo2->get_foo_history() ],
82 '... got correct empty history for foo2');
90 [ $foo->get_foo_history() ],
91 [ 42, 43, 44, 45, 46 ],
92 '... got correct history for foo');
94 is($foo->get_bar, undef, '... bar is not yet defined');
96 [ $foo->get_bar_history() ],
98 '... got correct empty history for foo');
101 $foo->set_bar("FOO");
102 is($foo->get_bar, "FOO", '... bar == "FOO"');
104 [ $foo->get_bar_history() ],
106 '... got correct history for foo');
108 $foo->set_bar("BAR");
109 $foo->set_bar("BAZ");
112 [ $foo->get_bar_history() ],
114 '... got correct history for bar');
117 [ $foo->get_foo_history() ],
118 [ 42, 43, 44, 45, 46 ],
119 '... still have the correct history for foo');