10 require_ok(File::Spec->catfile('examples', 'LazyClass.pod'));
17 'attribute_metaclass' => 'LazyClass::Attribute',
18 'instance_metaclass' => 'LazyClass::Instance',
21 BinaryTree->meta->add_attribute('node' => (
26 BinaryTree->meta->add_attribute('left' => (
28 default => sub { BinaryTree->new() }
31 BinaryTree->meta->add_attribute('right' => (
33 default => sub { BinaryTree->new() }
38 bless $class->meta->new_object(@_) => $class;
42 my $root = BinaryTree->new('node' => 0);
43 isa_ok($root, 'BinaryTree');
45 ok(exists($root->{'node'}), '... node attribute has been initialized yet');
46 ok(!exists($root->{'left'}), '... left attribute has not been initialized yet');
47 ok(!exists($root->{'right'}), '... right attribute has not been initialized yet');
49 isa_ok($root->left, 'BinaryTree');
50 isa_ok($root->right, 'BinaryTree');
52 ok(exists($root->{'left'}), '... left attribute has now been initialized');
53 ok(exists($root->{'right'}), '... right attribute has now been initialized');
55 ok(!exists($root->left->{'node'}), '... node attribute has not been initialized yet');
56 ok(!exists($root->left->{'left'}), '... left attribute has not been initialized yet');
57 ok(!exists($root->left->{'right'}), '... right attribute has not been initialized yet');
59 ok(!exists($root->right->{'node'}), '... node attribute has not been initialized yet');
60 ok(!exists($root->right->{'left'}), '... left attribute has not been initialized yet');
61 ok(!exists($root->right->{'right'}), '... right attribute has not been initialized yet');
63 is($root->left->node(), undef, '... the left node is uninitialized');
65 ok(exists($root->left->{'node'}), '... node attribute has now been initialized');
68 is($root->left->node(), 1, '... the left node == 1');
70 ok(!exists($root->left->{'left'}), '... left attribute still has not been initialized yet');
71 ok(!exists($root->left->{'right'}), '... right attribute still has not been initialized yet');
73 is($root->right->node(), undef, '... the right node is uninitialized');
75 ok(exists($root->right->{'node'}), '... node attribute has now been initialized');
77 $root->right->node(2);
78 is($root->right->node(), 2, '... the right node == 1');
80 ok(!exists($root->right->{'left'}), '... left attribute still has not been initialized yet');
81 ok(!exists($root->right->{'right'}), '... right attribute still has not been initialized yet');