7 unshift @INC, '../lib' if -d '../lib';
9 if ($_[0] =~ /^Hides field 'b1' in base class/) {
21 use fields qw(b1 b2 b3);
25 use fields qw(b1 _b2 b2);
27 sub new { bless [], shift }
31 use fields qw(d1 d2 d3);
35 use fields qw(_d1 _d2);
40 use fields qw(b1 d1 _b1 _d1); # hide b1
44 use fields qw(_d3 d3);
55 package Foo::Bar::Baz;
57 use fields qw(foo bar baz);
65 for my $k (sort {$h->{$a} <=> $h->{$b}} keys %$h) {
69 my $str = join(",", @tmp);
70 print "$h => $str\n" if $DEBUG;
75 B1 => "b1:1,b2:2,b3:3",
76 B2 => "_b1:1,b1:2,_b2:3,b2:4",
77 D1 => "b1:1,b2:2,b3:3,d1:4,d2:5,d3:6",
78 D2 => "b1:1,b2:2,b3:3,_d1:4,_d2:5,d1:6,d2:7",
79 D3 => "b2:4,b1:5,d1:6,_b1:7,_d1:8",
80 D4 => "b2:4,b1:5,d1:6,_d3:9,d3:10",
82 'Foo::Bar::Baz' => 'b1:1,b2:2,b3:3,foo:4,bar:5,baz:6',
85 print "1..", int(keys %expect)+5, "\n";
87 while (my($class, $exp) = each %expect) {
89 my $fstr = fstr(\%{$class."::FIELDS"});
90 print "EXP: $exp\nGOT: $fstr\nnot " unless $fstr eq $exp;
91 print "ok ", ++$testno, "\n";
94 # Did we get the appropriate amount of warnings?
95 print "not " unless $w == 1;
96 print "ok ", ++$testno, "\n";
98 # A simple object creation and AVHV attribute access test
99 my B2 $obj1 = D3->new;
104 print "not " unless $obj1->[2] eq "B2" && $obj1->[5] eq "D3";
105 print "ok ", ++$testno, "\n";
107 # We should get compile time failures field name typos
108 eval q(my D3 $obj3 = $obj2; $obj3->{notthere} = "");
109 print "not " unless $@ && $@ =~ /^No such field "notthere"/;
110 print "ok ", ++$testno, "\n";
117 use fields qw(foo bar);
118 sub new { bless [], $_[0]; }
121 my Foo $a = Foo->new();
122 $a->{foo} = ['a', 'ok ' . ++$testno, 'c'];
123 $a->{bar} = { A => 'ok ' . ++$testno };
124 print $a->{foo}[1], "\n";
125 print $a->{bar}->{A}, "\n";