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

Object.{values,entries} tests #453

Merged
merged 8 commits into from Jan 13, 2016
Merged

Conversation

ljharb
Copy link
Member

@ljharb ljharb commented Dec 13, 2015

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!

/*---
description: Object.entries should terminate if getting a value throws an exception
es7id: pending
includes: [Test262Error.js]
Copy link
Contributor

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.

@anba
Copy link
Contributor

anba commented Dec 14, 2015

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);

ljharb added a commit to tc39/proposal-object-values-entries that referenced this pull request Dec 14, 2015
@ljharb
Copy link
Member Author

ljharb commented Dec 15, 2015

Proxy tests added, thanks for the suggestion!

@ljharb
Copy link
Member Author

ljharb commented Dec 15, 2015

I believe the only remaining issue is the verifyConfigurable ordering, which I'd prefer to be obviated by #452.

Please let me know if there's anything else!

goyakin pushed a commit that referenced this pull request Jan 13, 2016
@goyakin goyakin merged commit 34a917f into tc39:master Jan 13, 2016
@ljharb
Copy link
Member Author

ljharb commented Jan 13, 2016

Thanks @goyakin!

@ljharb ljharb deleted the object_values_entries branch January 17, 2016 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants