test: correct the assertion for the ES6 object properties#11862
test: correct the assertion for the ES6 object properties#11862AnnaMag wants to merge 1 commit intonodejs:masterfrom
Conversation
|
cc/ @fhinkel |
test/known_issues/test-vm-getters.js
Outdated
There was a problem hiding this comment.
Have you checked whether using assert.deepStrictEqual(Object.assign({}, result), descriptor) instead works too? I am not a 100 % sure it’s more readable so feel free to ignore me. 😄
There was a problem hiding this comment.
@addaleax, I double-checked and your alternative does work! Upps...
IMHO, it is more elegant, so I'd choose to use it in the test. Not sure about readability, so maybe I'll hold off with the change until an extra view on that :)
addaleax
left a comment
There was a problem hiding this comment.
LGTM with or without the suggestion :)
fhinkel
left a comment
There was a problem hiding this comment.
According to #11803, the problem is that assert.strictEqual() is false on two functions (functions that look the same way but are different objects).
I replaced the last assert.strictEqual() in #11803 with the changes in this PR, and it fails:
AssertionError: [Function: get] === [Function: get]
Seems to me like this change does not fix that problem. Can you explain how the patch is checking something different for getters than before? Thanks!
|
I believe that those are distinct issues...? This patch is not meant to fix possible 'shortcomings' of |
|
I thought the issue is about comparing two getter functions. Your commit message says accessors, which accessors do you mean? This is the test I ran: |
|
Sorry, right, I should have looked at the commit message here 🙈 The problem is that |
|
Ah. Thanks! That's why I was looking for something different and this commit didn't make much sense to me 😃 |
0d948bf to
808a93d
Compare
|
I see where it was confusing. It is updated now. Thanks @fhinkel 👍 |
|
I still find the commit message very confusing. Can you describe the change you made rather than what the test is testing? If the change is because of different prototypes (because they're coming from different contexts), why is that not mentioned in the commit message? To me, mentioning ES6 style properties, flattening, and sandbox is confusing with respect to this commit. How about something like this:
|
Prototypes are not strict equal when they are from different contexts. Therefore, assert.strictEqual() fails for objects that are created in different contexts, e.g., in vm.runInContext(). Instead of expecting the prototypes to be equal, only check the properties of the objects for equality.
|
Thanks! Landed in 7ef2d90. |
Prototypes are not strict equal when they are from different contexts. Therefore, assert.strictEqual() fails for objects that are created in different contexts, e.g., in vm.runInContext(). Instead of expecting the prototypes to be equal, only check the properties of the objects for equality. PR-URL: #11862 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Prototypes are not strict equal when they are from different contexts. Therefore, assert.strictEqual() fails for objects that are created in different contexts, e.g., in vm.runInContext(). Instead of expecting the prototypes to be equal, only check the properties of the objects for equality. PR-URL: nodejs#11862 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Prototypes are not strict equal when they are from different contexts. Therefore, assert.strictEqual() fails for objects that are created in different contexts, e.g., in vm.runInContext(). Instead of expecting the prototypes to be equal, only check the properties of the objects for equality. PR-URL: nodejs#11862 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Prototypes are not strict equal when they are from different contexts. Therefore, assert.strictEqual() fails for objects that are created in different contexts, e.g., in vm.runInContext(). Instead of expecting the prototypes to be equal, only check the properties of the objects for equality. PR-URL: #11862 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Prototypes are not strict equal when they are from different contexts. Therefore, assert.strictEqual() fails for objects that are created in different contexts, e.g., in vm.runInContext(). Instead of expecting the prototypes to be equal, only check the properties of the objects for equality. PR-URL: #11862 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
Prototypes are not strict equal when they are from different contexts. Therefore, assert.strictEqual() fails for objects that are created in different contexts, e.g., in vm.runInContext(). Instead of expecting the prototypes to be equal, only check the properties of the objects for equality. PR-URL: nodejs/node#11862 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com>
test: fix assertion in a vm test
Prototypes are not strict equal when they are
from different contexts. Therefore, assert.strictEqual()
fails for objects that are created in different
contexts, e.g. in vm.runInContext().
Instead of expecting the prototypes to be equal,
only check the properties of the objects for equality.
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
test