4 use Test::More tests => 27;
8 require_ok(File::Spec->catfile('examples', 'AttributesWithHistory.pod'));
15 Foo->meta->add_attribute(AttributesWithHistory->new('foo' => (
17 history_accessor => 'get_foo_history',
20 Foo->meta->add_attribute(AttributesWithHistory->new('bar' => (
23 history_accessor => 'get_bar_history',
28 $class->meta->new_object(@_);
36 can_ok($foo, 'get_foo_history');
37 can_ok($foo, 'set_bar');
38 can_ok($foo, 'get_bar');
39 can_ok($foo, 'get_bar_history');
41 my $foo2 = Foo->new();
44 is($foo->foo, undef, '... foo is not yet defined');
46 [ $foo->get_foo_history() ],
48 '... got correct empty history for foo');
50 is($foo2->foo, undef, '... foo2 is not yet defined');
52 [ $foo2->get_foo_history() ],
54 '... got correct empty history for foo2');
57 is($foo->foo, 42, '... foo == 42');
59 [ $foo->get_foo_history() ],
61 '... got correct history for foo');
63 is($foo2->foo, undef, '... foo2 is still not yet defined');
65 [ $foo2->get_foo_history() ],
67 '... still got correct empty history for foo2');
70 is($foo->foo, 42, '... foo is still == 42');
72 [ $foo->get_foo_history() ],
74 '... still got correct history for foo');
76 is($foo2->foo, 100, '... foo2 == 100');
78 [ $foo2->get_foo_history() ],
80 '... got correct empty history for foo2');
88 [ $foo->get_foo_history() ],
89 [ 42, 43, 44, 45, 46 ],
90 '... got correct history for foo');
92 is($foo->get_bar, undef, '... bar is not yet defined');
94 [ $foo->get_bar_history() ],
96 '... got correct empty history for foo');
100 is($foo->get_bar, "FOO", '... bar == "FOO"');
102 [ $foo->get_bar_history() ],
104 '... got correct history for foo');
106 $foo->set_bar("BAR");
107 $foo->set_bar("BAZ");
110 [ $foo->get_bar_history() ],
112 '... got correct history for bar');
115 [ $foo->get_foo_history() ],
116 [ 42, 43, 44, 45, 46 ],
117 '... still have the correct history for foo');