{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/11803","repository_url":"https://api.github.com/repos/nodejs/node","labels_url":"https://api.github.com/repos/nodejs/node/issues/11803/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/11803/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/11803/events","html_url":"https://github.com/nodejs/node/issues/11803","id":213528698,"number":11803,"title":"assert.deepStrictEqual() fails to compare ES6 style object properties","user":{"login":"AnnaMag","id":13561163,"avatar_url":"https://avatars0.githubusercontent.com/u/13561163?v=3","gravatar_id":"","url":"https://api.github.com/users/AnnaMag","html_url":"https://github.com/AnnaMag","followers_url":"https://api.github.com/users/AnnaMag/followers","following_url":"https://api.github.com/users/AnnaMag/following{/other_user}","gists_url":"https://api.github.com/users/AnnaMag/gists{/gist_id}","starred_url":"https://api.github.com/users/AnnaMag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnnaMag/subscriptions","organizations_url":"https://api.github.com/users/AnnaMag/orgs","repos_url":"https://api.github.com/users/AnnaMag/repos","events_url":"https://api.github.com/users/AnnaMag/events{/privacy}","received_events_url":"https://api.github.com/users/AnnaMag/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-03-11T13:24:43Z","updated_at":"2017-03-11T13:32:05Z","closed_at":null,"body":"<!--\r\nThank you for reporting an issue.\r\n\r\nThis issue tracker is for bugs and issues found within Node.js core.\r\nIf you require more general support please file an issue on our help\r\nrepo. https://github.com/nodejs/help\r\n\r\n\r\nPlease fill in as much of the template below as you're able.\r\n\r\nVersion: output of `node -v`\r\nPlatform: output of `uname -a` (UNIX), or version and 32 or 64-bit (Windows)\r\nSubsystem: if known, please specify affected core module name\r\n\r\nIf possible, please provide code that demonstrates the problem, keeping it as\r\nsimple and free of external dependencies as you are able.\r\n-->\r\n\r\n* **Version**: v7.7.1\r\n* **Platform**: Mac OSX X86_64\r\n* **Subsystem**:\r\n\r\n<!-- Enter your issue details below this comment. -->\r\nThe following assertion fails when objects are property descriptors:\r\n\r\n```\r\n'use strict';\r\nrequire('../common');\r\nconst assert = require('assert');\r\n\r\nconst x = {};\r\n\r\nObject.defineProperty(x, 'prop', {\r\n  get() {\r\n    return 'foo';\r\n  }\r\n});\r\n\r\nconst y = {};\r\n\r\nObject.defineProperty(y, 'prop', {\r\n  get() {\r\n    return 'foo';\r\n  }\r\n});\r\n\r\nconst descriptorx = Object.getOwnPropertyDescriptor(x, 'prop');\r\nconst descriptory = Object.getOwnPropertyDescriptor(y, 'prop');\r\n\r\nassert.deepStrictEqual(x, y); // ok\r\nassert.deepStrictEqual(descriptorx, descriptory); // throws an error\r\n```\r\n\r\nWhat seems to happen is that (in both cases) ```Object.getPrototypeOf(descriptor)```\r\n results in ```{}```, which leads to the condition \r\nhttps://github.com/nodejs/node/blob/master/lib/assert.js#L200\r\nreturning *false*. Same is true for ```assert.strictEqual()```\r\n"},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/285866871","html_url":"https://github.com/nodejs/node/issues/11803#issuecomment-285866871","issue_url":"https://api.github.com/repos/nodejs/node/issues/11803","id":285866871,"user":{"login":"AnnaMag","id":13561163,"avatar_url":"https://avatars0.githubusercontent.com/u/13561163?v=3","gravatar_id":"","url":"https://api.github.com/users/AnnaMag","html_url":"https://github.com/AnnaMag","followers_url":"https://api.github.com/users/AnnaMag/followers","following_url":"https://api.github.com/users/AnnaMag/following{/other_user}","gists_url":"https://api.github.com/users/AnnaMag/gists{/gist_id}","starred_url":"https://api.github.com/users/AnnaMag/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnnaMag/subscriptions","organizations_url":"https://api.github.com/users/AnnaMag/orgs","repos_url":"https://api.github.com/users/AnnaMag/repos","events_url":"https://api.github.com/users/AnnaMag/events{/privacy}","received_events_url":"https://api.github.com/users/AnnaMag/received_events","type":"User","site_admin":false},"created_at":"2017-03-11T13:32:05Z","updated_at":"2017-03-11T13:32:05Z","body":"With the changes in the new V8 API, accessor properties are not flattened anymore (patch hopefully coming soon as we are working on it with @fhinkel :)) and descriptors can have attributes that are functions (getters/setters).  E.g. the following test will not throw:\r\nhttps://github.com/nodejs/node/blob/master/test/known_issues/test-vm-getters.js\r\nbut current assertions do not work for deep object comparison with functions as attributes.\r\nThat is, this will not work:\r\nhttps://github.com/nodejs/node/blob/master/test/known_issues/test-vm-getters.js#L19\r\n\r\nI wrote a piece of code that fixed the issue:\r\n\r\n```\r\nconst aKeys = Object.keys(descriptory);\r\nconst bKeys = Object.keys(descriptorx);\r\n\r\nvar keya, keyb, vala, valb, i;\r\n\r\nif (aKeys.length !== bKeys.length)\r\n  return false;\r\n\r\naKeys.sort();\r\nbKeys.sort();\r\n\r\nfor (i = 0; i < aKeys.length; i++) {\r\n  keya = aKeys[i];\r\n  keyb = bKeys[i];\r\n  if (keya === keyb) {\r\n      if (typeof descriptory[keya] === 'function' &&\r\n          typeof descriptorx[keyb] === 'function') {\r\n              vala = descriptory[keya].toString();\r\n              valb = descriptorx[keyb].toString();\r\n              if (vala !== valb) {return false;}\r\n              else continue;\r\n       }\r\n\r\n      if (descriptory[keya] !== descriptorx[keyb]) return false; //different values\r\n    } else  return false; // keys are different\r\n}\r\n```\r\n\r\nHappy to contribute it to assert.js.... could not figure out how to wave it in though."}}
{"actor":{"display_login":"AnnaMag"}}