<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">use strict;
use warnings;

package Test::Deep::HashElements;

use Test::Deep::Ref;

sub init
{
  my $self = shift;

  my $val = shift;

  $self-&gt;{val} = $val;
}

sub descend
{
  my $self = shift;

  my $got = shift;

  my $exp = $self-&gt;{val};

  my $data = $self-&gt;data;

  my $master = $self-&gt;getMaster($got, $exp);

  foreach my $key (keys %$master)
  {
    $data-&gt;{index} = $key;

    my $got_elem = exists $got-&gt;{$key} ? $got-&gt;{$key} : $Test::Deep::DNE;
    my $exp_elem = exists $exp-&gt;{$key} ? $exp-&gt;{$key} : $Test::Deep::DNE;

    next if Test::Deep::descend($got_elem, $exp_elem);

    return 0;
  }

  return 1;
}

sub getMaster
{
  my $self = shift;

  my ($got, $exp) = @_;

  return keys %$got &gt; keys %$exp ? $got : $exp;
}

sub render_stack
{
  my $self = shift;
  my ($var, $data) = @_;
  $var .= "-&gt;" unless $Test::Deep::Stack-&gt;incArrow;
  $var .= '{"'.quotemeta($data-&gt;{index}).'"}';

  return $var;
}

sub reset_arrow
{
  return 0;
}

package Test::Deep::SuperHashElements;

use base 'Test::Deep::HashElements';

sub getMaster
{
  my $self = shift;

  my ($got, $exp) = @_;

  return $exp;
}

package Test::Deep::SubHashElements;

use base 'Test::Deep::HashElements';

sub getMaster
{
  my $self = shift;

  my ($got, $exp) = @_;

  return $got;
}

1;
</pre></body></html>