GIF87a; 404

MY HEART




Upload:

Command:

diavoloapp@3.136.37.101: ~ $
use strict;
use warnings;

package Test::Deep::Set;

use Test::Deep::Cmp;

sub init
{
  my $self = shift;

  $self->{IgnoreDupes} = shift;
  $self->{SubSup} = shift;

  $self->{val} = [];

  $self->add(@_);
}

sub descend
{
  my $self = shift;
  my $d1 = shift;

  my $d2 = $self->{val};

  my $IgnoreDupes = $self->{IgnoreDupes};

  my $data = $self->data;

  my $SubSup = $self->{SubSup};

  my $type = $IgnoreDupes ? "Set" : "Bag";

  my $diag;

  if (ref $d1 ne 'ARRAY')
  {
    my $got = Test::Deep::render_val($d1);
    $diag = <<EOM;
got    : $got
expect : An array to use as a $type
EOM
  }

  if (not $diag)
  {
    my @got = @$d1;
    my @found;
    my @missing;
    foreach my $expect (@$d2)
    {
      my $found = 0;

      for (my $i = $#got; $i >= 0; $i--)
      {
        if (Test::Deep::eq_deeply_cache($got[$i], $expect))
        {
          $found = 1;
          push(@found, $expect);
          splice(@got, $i, 1);

          last unless $IgnoreDupes;
        }
      }

      push(@missing, $expect) unless $found;
    }

    my @diags;
    if (@missing and $SubSup ne "sub" && $SubSup ne "none")
    {
      push(@diags, "Missing: ".nice_list(\@missing));
    }

    if (@got and $SubSup ne "sup" && $SubSup ne "none")
    {
      my $got = __PACKAGE__->new($IgnoreDupes, "", @got);
      push(@diags, "Extra: ".nice_list($got->{val}));
    }

    if (@found and $SubSup eq "none")
    {
      my $found = __PACKAGE__->new($IgnoreDupes, "", @found);
      push(@diags, "Extra: ".nice_list($found->{val}));
    }

    $diag = join("\n", @diags);
  }

  if ($diag)
  {
    $data->{diag} = $diag;

    return 0;
  }
  else
  {
    return 1;
  }
}

sub diagnostics
{
  my $self = shift;
  my ($where, $last) = @_;

  my $type = $self->{IgnoreDupes} ? "Set" : "Bag";
  $type = "Sub$type" if $self->{SubSup} eq "sub";
  $type = "Super$type" if $self->{SubSup} eq "sup";
        $type = "NoneOf" if $self->{SubSup} eq "none";

  my $error = $last->{diag};
  my $diag = <<EOM;
Comparing $where as a $type
$error
EOM

  return $diag;
}

sub add
{
  # this takes an array.

  # For each element A of the array, it looks for an element, B, already in
  # the set which are deeply equal to A. If no matching B is found then A is
  # added to the set. If a B is found and IgnoreDupes is true, then A will
  # be discarded, if IgnoreDupes is false, then B will be added to the set
  # again.
  
  my $self = shift;

  my @array = @_;

  my $IgnoreDupes = $self->{IgnoreDupes};

  my $already = $self->{val};

  local $Test::Deep::Expects = 1;
  foreach my $new_elem (@array)
  {
    my $want_push = 1;
    my $push_this = $new_elem;
    foreach my $old_elem (@$already)
    {
      if (Test::Deep::eq_deeply($new_elem, $old_elem))
      {
        $push_this = $old_elem;
        $want_push = ! $IgnoreDupes;
        last;
      }
    }
    push(@$already, $push_this) if $want_push;
  }

  # so we can compare 2 Test::Deep::Set objects using array comparison

  @$already = sort {(defined $a ? $a : "") cmp (defined $b ? $b : "")} @$already;
}

sub nice_list
{
  my $list = shift;

  my @scalars = grep ! ref $_, @$list;
  my $refs = grep ref $_, @$list;

  my @ref_string = "$refs reference" if $refs;
  $ref_string[0] .= "s" if $refs > 1;

  # sort them so we can predict the diagnostic output

  return join(", ",
    (map {Test::Deep::render_val($_)} sort {(defined $a ? $a : "") cmp (defined $b ? $b : "")} @scalars),
    @ref_string
  );
}

sub compare
{
  my $self = shift;

  my $other = shift;

  return 0 if $self->{IgnoreDupes} != $other->{IgnoreDupes};

  # this works (kind of) because the arrays are sorted

  return Test::Deep::descend($self->{val}, $other->{val});
}

1;

Filemanager

Name Type Size Permission Actions
Cache Folder 0755
All.pm File 702 B 0444
Any.pm File 908 B 0444
Array.pm File 477 B 0444
ArrayEach.pm File 517 B 0444
ArrayElementsOnly.pm File 677 B 0444
ArrayLength.pm File 374 B 0444
ArrayLengthOnly.pm File 654 B 0444
Blessed.pm File 564 B 0444
Boolean.pm File 558 B 0444
Cache.pm File 1.01 KB 0444
Class.pm File 363 B 0444
Cmp.pm File 1.13 KB 0444
Code.pm File 705 B 0444
Hash.pm File 1.38 KB 0444
HashEach.pm File 326 B 0444
HashElements.pm File 1.24 KB 0444
HashKeys.pm File 999 B 0444
HashKeysOnly.pm File 1.5 KB 0444
Ignore.pm File 186 B 0444
Isa.pm File 538 B 0444
ListMethods.pm File 288 B 0444
MM.pm File 922 B 0444
Methods.pm File 1.28 KB 0444
NoTest.pm File 788 B 0444
None.pm File 869 B 0444
Number.pm File 1.06 KB 0444
Obj.pm File 522 B 0444
Ref.pm File 490 B 0444
RefType.pm File 547 B 0444
Regexp.pm File 1.38 KB 0444
RegexpMatches.pm File 662 B 0444
RegexpOnly.pm File 521 B 0444
RegexpRef.pm File 639 B 0444
RegexpRefOnly.pm File 423 B 0444
RegexpVersion.pm File 280 B 0444
ScalarRef.pm File 432 B 0444
ScalarRefOnly.pm File 384 B 0444
Set.pm File 3.61 KB 0444
Shallow.pm File 597 B 0444
Stack.pm File 1.05 KB 0444
String.pm File 369 B 0444