6 use Test::More tests => 28;
11 require_ok(File::Spec->catdir('examples', 'AttributesWithHistory.pod'));
18 Foo->meta->add_attribute(AttributesWithHistory->new('foo' => (
20 history_accessor => 'get_foo_history',
23 Foo->meta->add_attribute(AttributesWithHistory->new('bar' => (
26 history_accessor => 'get_bar_history',
31 $class->meta->new_object(@_);
39 can_ok($foo, 'get_foo_history');
40 can_ok($foo, 'set_bar');
41 can_ok($foo, 'get_bar');
42 can_ok($foo, 'get_bar_history');
44 my $foo2 = Foo->new();
47 is($foo->foo, undef, '... foo is not yet defined');
49 [ $foo->get_foo_history() ],
51 '... got correct empty history for foo');
53 is($foo2->foo, undef, '... foo2 is not yet defined');
55 [ $foo2->get_foo_history() ],
57 '... got correct empty history for foo2');
60 is($foo->foo, 42, '... foo == 42');
62 [ $foo->get_foo_history() ],
64 '... got correct history for foo');
66 is($foo2->foo, undef, '... foo2 is still not yet defined');
68 [ $foo2->get_foo_history() ],
70 '... still got correct empty history for foo2');
73 is($foo->foo, 42, '... foo is still == 42');
75 [ $foo->get_foo_history() ],
77 '... still got correct history for foo');
79 is($foo2->foo, 100, '... foo2 == 100');
81 [ $foo2->get_foo_history() ],
83 '... got correct empty history for foo2');
91 [ $foo->get_foo_history() ],
92 [ 42, 43, 44, 45, 46 ],
93 '... got correct history for foo');
95 is($foo->get_bar, undef, '... bar is not yet defined');
97 [ $foo->get_bar_history() ],
99 '... got correct empty history for foo');
102 $foo->set_bar("FOO");
103 is($foo->get_bar, "FOO", '... bar == "FOO"');
105 [ $foo->get_bar_history() ],
107 '... got correct history for foo');
109 $foo->set_bar("BAR");
110 $foo->set_bar("BAZ");
113 [ $foo->get_bar_history() ],
115 '... got correct history for bar');
118 [ $foo->get_foo_history() ],
119 [ 42, 43, 44, 45, 46 ],
120 '... still have the correct history for foo');