#!perl -w # # $Id: node_unit.t,v 1.1 2000/10/03 17:16:43 kmacleod Exp $ # use strict; use Test; BEGIN { plan tests => 10 } use Class::Orchard::Node; my $node = Class::Orchard::Node->new(); $node->{Foo} = 'hello'; ok($node->{Foo} eq 'hello'); # 1 eval { my $foo = $node->{ { Bad => 'index' } } }; ok($@); # 2 eval { my $foo = $node->{ [ 'one', 'two', 'three' ] } }; ok($@); # 3 eval { $node->{ { Bad => 'index' } } = 'foo' }; ok($@); # 4 eval { $node->{ [ 'one', 'two', 'three' ] } = 'foo' }; ok($@); # 5 my $node2 = Class::Orchard::Node->new( Alpha => 'Beta' ); ok($node2->{Alpha} eq 'Beta'); # 6 eval { my $node3 = Class::Orchard::Node->new( 'boo' ); }; ok($@); # 7 $node2->{['a:uri', 'Burger']} = 'with fries'; my %found; while (my ($key, $value) = each %$node2) { if (ref($key) eq 'ARRAY' and $key->[0] eq 'a:uri' and $key->[1] eq 'Burger' and $value eq 'with fries') { $found{Burger} = 1; } elsif (!ref($key) and $key eq 'Alpha' and $value eq 'Beta') { $found{Alpha} = 1; } else { $found{SomethingElse} = 1; } } ok($found{Burger}); # 8 ok($found{Alpha}); # 9 ok(!$found{SomethingElse}); # 10