selfrefactor/rambda

R.equals on sets do not appear to work

trajano opened this issue · 4 comments

import R from 'rambda';
describe("validate set equality", () => {
    it("equals on rambda", () => {
        expect(R.equals(new Set(['3', '2', '1']), new Set(['2', '3', '3', '2', '1']))).toBeTruthy();
        expect(R.equals(new Set(['3', '2', '0']), new Set(['2', '3', '3', '2', '1']))).toBeFalsy();
    })
})

fails on expect(R.equals(new Set(['3', '2', '1']), new Set(['2', '3', '3', '2', '1']))).toBeTruthy(); this works correctly in ramda

Thanks for the report as it found a deeper issue. It appears that R.type doesn't work with sets, so this is the main issue. I will try to apply the fix to 6.10.0. I'll write again once the issue is fixed.

I am currently in a sick leave, but afterwards I will look into the issue.

Issue is fixed and it will be available when 6.10.0 is published. I'll keep the issue open until the release.

This is the test to prove the fix:

test('compare sets', () => {
  const toCompareDifferent = new Set([{a: 1}, {a: 2}])
  const toCompareSame = new Set([{a: 1}, {a: 2}, {a: 1}])
  const testSet = new Set([{a: 1}, {a: 2}, {a: 1}])
  expect(equals(toCompareSame, testSet)).toBeTruthy()
  expect(equals(toCompareDifferent, testSet)).toBeFalsy()
  expect(equalsRamda(toCompareSame, testSet)).toBeTruthy()
  expect(equalsRamda(toCompareDifferent, testSet)).toBeFalsy()
})

I am closing the issue as the fix is released with version 7.0.0.