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
Object.{values,entries} tests #453
Conversation
/*--- | ||
description: Object.entries should terminate if getting a value throws an exception | ||
es7id: pending | ||
includes: [Test262Error.js] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test262Error.js is auto-included.
And tests using Proxies could be useful to check implementations perform the operations in the correct order. For example something simple like: var log = "";
var object = {a: 0, b: 0, c: 0};
var handler = {
get: function(target, propertyKey, receiver) {
assert.sameValue(target, object, "get target");
assert.sameValue(receiver, proxy, "get receiver");
log += "|get:" + propertyKey;
return target[propertyKey];
},
getOwnPropertyDescriptor: function(target, propertyKey) {
assert.sameValue(target, object, "getOwnPropertyDescriptor");
log += "|getOwnPropertyDescriptor:" + propertyKey;
return Object.getOwnPropertyDescriptor(target, propertyKey);
},
ownKeys: function(target) {
assert.sameValue(target, object, "ownKeys");
log += "|ownKeys";
return Object.getOwnPropertyNames(target);
}
};
var check = {
get: function(target, propertyKey, receiver) {
assert(propertyKey in target, "handler check: " + propertyKey);
return target[propertyKey];
}
};
var proxy = new Proxy(object, new Proxy(handler, check));
var result = Object.values(proxy);
assert.sameValue(log, "|ownKeys|getOwnPropertyDescriptor:a|get:a|getOwnPropertyDescriptor:b|get:b|getOwnPropertyDescriptor:c|get:c", log); |
b56b415
to
48a8839
Compare
Proxy tests added, thanks for the suggestion! |
I believe the only remaining issue is the Please let me know if there's anything else! |
117b5da
to
cfe707a
Compare
cfe707a
to
f1d072d
Compare
Object.{values,entries} tests
Thanks @goyakin! |
I'm putting this PR up now for https://github.com/tc39/proposal-object-values-entries to hopefully work out any kinks before the next meeting, and to aid in implementation in various browsers.
I'll be happy to correct any tweaks pointed out, no matter how minor, including adding missing test cases. Thanks!