6 use Test::More tests => 12;
10 use_ok('examples::InstanceCountingClass');
15 This is a trivial and contrived example of how to
16 make a metaclass which will count all the instances
17 created. It is not meant to be anything more than
18 a simple demonstration of how to make a metaclass.
25 sub meta { InstanceCountingClass->initialize($_[0]) }
28 bless $class->meta->construct_instance() => $class;
36 is(Foo->meta->get_count(), 0, '... our Foo count is 0');
37 is(Bar->meta->get_count(), 0, '... our Bar count is 0');
42 is(Foo->meta->get_count(), 1, '... our Foo count is now 1');
43 is(Bar->meta->get_count(), 0, '... our Bar count is still 0');
48 is(Foo->meta->get_count(), 1, '... our Foo count is still 1');
49 is(Bar->meta->get_count(), 1, '... our Bar count is now 1');
55 is(Foo->meta->get_count(), 10, '... our Foo count is now 10');
56 is(Bar->meta->get_count(), 1, '... our Bar count is still 1');