Deno: assertEquals doesn't deeply verify Map equality

Created on 29 Oct 2019  路  6Comments  路  Source: denoland/deno

It would seem that the equal function consumed by assertEquals in the asserts module doesn't verify the deep equality of Map instances. Therefore:

assertEquals(
  new Map([['foo', 'bar']]),
  new Map([['bar', 'foo']]),
);

doesn't throw an AssertionError, whereas I'd certainly expect a test failure.

Was it an intentional decision to omit Map support, or is it an oversight? If it's the latter, I'm happy to raise a PR to fix it.

bug good first issue

All 6 comments

Looking at the labels, I'd say it's a bug. I'm thus happy to take a look at this @ry.

Closed in #3236 but it was a specific solution for Map, but I also assume this would have been valid for Set or in fact any iterable.

It might have been a better solution to detect iterables, iterate over their values, and compare those values deeply as well.

I didn't think of that @kitsonk, but I agree that would have been a lot more succinct. Probably one for next time!

Actually @kitsonk, I'll raise another PR to consolidate the Map and Set branches into a single Symbol.iterator in a...-esque conditional. I'll tackle it in a week or so.

Actually @kitsonk, I'll raise another PR to consolidate the Map and Set branches into a single Symbol.iterator in a...-esque conditional. I'll tackle it in a week or so.

Addressed in #3258, although it's a bit more involved than it may appear on the surface.

Fixed in v0.23 馃嵕

Was this page helpful?
0 / 5 - 0 ratings

Related issues

doutchnugget picture doutchnugget  路  3Comments

metakeule picture metakeule  路  3Comments

somombo picture somombo  路  3Comments

CruxCv picture CruxCv  路  3Comments

motss picture motss  路  3Comments