Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert: Add support for Map and Set in deepEqual #12142

Closed
wants to merge 13 commits into from

Commits on Mar 31, 2017

  1. assert: Add support for Map and Set in deepEqual

    assert.deepEqual and assert.deepStrictEqual currently return true for
    any pair of Maps and Sets regardless of content. This patch adds
    support in deepEqual and deepStrictEqual to verify the contents of Maps
    and Sets.
    
    Unfortunately because there's no way to pairwise fetch set values or map
    values which are equivalent but not reference-equal, this change
    currently only supports reference equality checking in set values and
    map key values. Equivalence checking could be done, but it would be an
    O(n^2) operation, and worse, it would get slower exponentially if maps
    and sets were nested.
    
    Note that this change breaks compatibility with previous versions of
    deepEqual and deepStrictEqual if consumers were depending on all maps
    and sets to be seen as equivalent. The old behaviour was never
    documented, but nevertheless there are certainly some tests out there
    which depend on it.
    
    Support has stalled because the assert API was frozen, but was recently
    unfrozen in CTC#63
    
    Fixes: nodejs#2309
    Refs: tape-testing/tape#342
    Refs: nodejs#2315
    Refs: nodejs/CTC#63
    josephg committed Mar 31, 2017
    Configuration menu
    Copy the full SHA
    561561a View commit details
    Browse the repository at this point in the history
  2. assert: Use isSet and isMap from process.binding

    Updated PR based on comments
    
    Ref: nodejs#12142
    josephg committed Mar 31, 2017
    Configuration menu
    Copy the full SHA
    f051840 View commit details
    Browse the repository at this point in the history
  3. assert: Added deeper equality checking for Map,Set

    This change updates the checks for deep equality checking on Map and Set
    to check all set values / all map keys to see if any of them match the
    expected result.
    
    This change is much slower, but based on the conversation in the pull
    request its probably the right approach.
    
    Ref: nodejs#12142
    josephg committed Mar 31, 2017
    Configuration menu
    Copy the full SHA
    1d6cda6 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    800ae46 View commit details
    Browse the repository at this point in the history
  5. assert: Fixed typo in comment

    josephg committed Mar 31, 2017
    Configuration menu
    Copy the full SHA
    031f6f3 View commit details
    Browse the repository at this point in the history
  6. assert: var -> const and added tests

    Cleaned up as per comments in issue
    
    Ref: nodejs#6416
    josephg committed Mar 31, 2017
    Configuration menu
    Copy the full SHA
    d6baaee View commit details
    Browse the repository at this point in the history
  7. assert: restrict O(n^2) search

    Based on comments in the PR, this change restricts an O(n^2) to only
    happen when your set contains object-like objects, your map contains
    object-like keys or you're not in strict mode.
    
    ref: nodejs#12142 (review)
    josephg committed Mar 31, 2017
    Configuration menu
    Copy the full SHA
    8fb6ebf View commit details
    Browse the repository at this point in the history

Commits on Apr 1, 2017

  1. Configuration menu
    Copy the full SHA
    acef701 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ee131e8 View commit details
    Browse the repository at this point in the history
  3. assert: Updated based on PR

    - Added changes: entries in assert API documentation
    - Refactored setEquiv based on @joyeecheung's comments
    
    ref: nodejs#12142
    josephg committed Apr 1, 2017
    Configuration menu
    Copy the full SHA
    7bc29b0 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    6bdfcaf View commit details
    Browse the repository at this point in the history
  5. assert: fixed docs # link

    josephg committed Apr 1, 2017
    Configuration menu
    Copy the full SHA
    fc5196a View commit details
    Browse the repository at this point in the history
  6. assert: refactored based on PR

    Refactored setEquiv and mapEquiv based on @joyeecheung's stylistic
    preference to avoid labels.
    josephg committed Apr 1, 2017
    Configuration menu
    Copy the full SHA
    7f9d4d8 View commit details
    Browse the repository at this point in the history