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: fix _deepEqual and improve assert.md #11128

Closed
wants to merge 2 commits into from

Commits on Feb 25, 2017

  1. assert: fix premature deep strict comparison

    Refactors _deepEqual and fixes a few code paths that lead to
    behaviors contradicting what the doc says. Before this commit
    certain types of objects (Buffers, Dates, etc.) are not checked
    properly, and can get away with different prototypes AND different
    enumerable owned properties because _deepEqual would jump to
    premature conclusion for them.
    
    Since we no longer follow CommonJS unit testing spec,
    the checks for primitives and object prototypes are moved
    forward for faster failure.
    
    Improve regexp and float* array checks:
    
    * Don't compare lastIndex of regexps, because they are not
      enumerable, so according to the docs they should not be compared
    * Compare flags of regexps instead of separate properties
    * Use built-in tags to test for float* arrays instead of using
      instanceof
    
    Use full link to the archived GitHub repository.
    
    Use util.objectToString for future improvements to that function
    that makes sure the call won't be tampered with.
    
    Refs: nodejs#10282 (comment)
    Refs: nodejs#10258 (comment)
    joyeecheung committed Feb 25, 2017
    Configuration menu
    Copy the full SHA
    aa023db View commit details
    Browse the repository at this point in the history
  2. doc: improve assert.md regarding ECMAScript terms

    Use the term "Abstract Equality Comparison" and "Strict Equality
    Comparison" from ECMAScript specification to refer to the operations
    done by `==` and `===`, instead of "equal comparison operator" and
    "strict equality operator".
    
    Clarify that deep strict comparisons checks `[[Prototype]]`
    property, instead of the vague "object prototypes".
    
    Suggest using `Object.is()` to avoid the caveats of +0, -0 and NaN.
    
    Add a MDN link explaining what enumerable "own" properties are.
    joyeecheung committed Feb 25, 2017
    Configuration menu
    Copy the full SHA
    5fd9803 View commit details
    Browse the repository at this point in the history