diff options
author | Mark Murray <markm@FreeBSD.org> | 2002-03-16 20:14:31 +0000 |
---|---|---|
committer | Mark Murray <markm@FreeBSD.org> | 2002-03-16 20:14:31 +0000 |
commit | cf90a21ebd2262e09730a5a55c5ccb62f1622fad (patch) | |
tree | 116739180f0198b4d3857979a8e84444c2fe0949 /contrib/perl5/t/lib/class-struct.t | |
parent | fc75d0664419eb8c8f264d8f298df2cd155c8966 (diff) |
Notes
Diffstat (limited to 'contrib/perl5/t/lib/class-struct.t')
-rwxr-xr-x | contrib/perl5/t/lib/class-struct.t | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/contrib/perl5/t/lib/class-struct.t b/contrib/perl5/t/lib/class-struct.t new file mode 100755 index 000000000000..26505bacfc6b --- /dev/null +++ b/contrib/perl5/t/lib/class-struct.t @@ -0,0 +1,66 @@ +#!./perl -w + +BEGIN { + chdir 't' if -d 't'; + @INC = '../lib'; +} + +print "1..8\n"; + +package aClass; + +sub new { bless {}, shift } + +sub meth { 42 } + +package MyObj; + +use Class::Struct; +use Class::Struct 'struct'; # test out both forms + +use Class::Struct SomeClass => { SomeElem => '$' }; + +struct( s => '$', a => '@', h => '%', c => 'aClass' ); + +my $obj = MyObj->new; + +$obj->s('foo'); + +print "not " unless $obj->s() eq 'foo'; +print "ok 1\n"; + +my $arf = $obj->a; + +print "not " unless ref $arf eq 'ARRAY'; +print "ok 2\n"; + +$obj->a(2, 'secundus'); + +print "not " unless $obj->a(2) eq 'secundus'; +print "ok 3\n"; + +my $hrf = $obj->h; + +print "not " unless ref $hrf eq 'HASH'; +print "ok 4\n"; + +$obj->h('x', 10); + +print "not " unless $obj->h('x') == 10; +print "ok 5\n"; + +my $orf = $obj->c; + +print "not " unless ref $orf eq 'aClass'; +print "ok 6\n"; + +print "not " unless $obj->c->meth() == 42; +print "ok 7\n"; + +my $obk = SomeClass->new(); + +$obk->SomeElem(123); + +print "not " unless $obk->SomeElem() == 123; +print "ok 8\n"; + |