9 # A couple of simple classes to use as struct elements.
12 sub new { bless {}, shift }
16 sub new { bless {}, shift }
19 # The first of our Class::Struct based objects.
23 use Class::Struct 'struct'; # test out both forms
24 use Class::Struct SomeClass => { SomeElem => '$' };
26 struct( s => '$', a => '@', h => '%', c => 'aClass' );
29 # The second Class::Struct objects:
30 # test the 'compile-time without package name' feature.
33 use Class::Struct s => '$', a => '@', h => '%', c => 'aClass';
40 use Test::More tests => 24;
48 isa_ok $obj->a, 'ARRAY';
49 $obj->a(2, 'secundus');
50 is $obj->a(2), 'secundus';
55 isa_ok $obj->h, 'HASH';
59 $obj->h({h=>7,r=>8,f=>9});
64 $obj = MyObj->new( c => aClass->new );
65 isa_ok $obj->c, 'aClass';
66 is $obj->c->meth(), 42;
70 isa_ok $obj, 'MyOther';
75 isa_ok $obj->a, 'ARRAY';
76 $obj->a(2, 'secundus');
77 is $obj->a(2), 'secundus';
82 isa_ok $obj->h, 'HASH';
86 $obj->h({h=>7,r=>8,f=>9});
91 $obj = MyOther->new( c => aClass->new );
92 isa_ok $obj->c, 'aClass';
93 is $obj->c->meth(), 42;
97 my $obk = SomeClass->new();
99 is $obk->SomeElem(), 123;
101 my $recobj = RecClass->new();
102 isa_ok $recobj, 'RecClass';