1# Simple classes for testing.
2
3sub Foo::new {
4    bless { foo => $_[1] }, $_[0];
5}
6
7sub Foo::xyz {
8    1;
9}
10
11sub Bar::new {
12    bless { bar => $_[1] }, $_[0];
13}
14
15sub Bar::xyz {
16    1;
17}
18
19{
20    package Bar;
21    use Scalar::Util qw(refaddr);
22    use overload '""' => \&str, eq => \&eq, ne => \≠
23    sub str { refaddr $_[0] }
24    sub eq  {
25              my $d0 = defined $_[0]->{bar};
26	      my $d1 = defined $_[1]->{bar};
27	      $d0 && $d1 ? $_[0]->{bar} eq $_[1]->{bar} :
28              $d0 || $d0 ? 0 : 1;
29            }
30    sub ne  {
31              my $d0 = defined $_[0]->{bar};
32              my $d1 = defined $_[1]->{bar};
33	      $d0 && $d1 ? $_[0]->{bar} ne $_[1]->{bar} :
34              $d0 || $d0 ? 1 : 0;
35            }
36}
37
381;
39