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

Improve tests for BigInt.prototype.valueOf #1256

Merged
merged 4 commits into from
Oct 3, 2017

Conversation

leobalter
Copy link
Member

No description provided.

Copy link
Contributor

@spectranaut spectranaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me!

info: >
description: >
BigInt.prototype.valueOf returns the primitive BigInt value.
info: |
BigInt.prototype.valueOf ( )

Return ? thisBigIntValue(this value).
includes: [typeCoercion.js]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to remove the includes... That's why the linter triggered an error

@leobalter
Copy link
Member Author

@spectranaut the commits d729577 and b307b80 should fix the remaining parts.

var valueOf = BigInt.prototype.valueOf;

assert.sameValue(valueOf.call(0n), 0n, "0n");
assert.sameValue(valueOf.call(Object(0n)), 0n, "Object(0n)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

var s = Symbol();
assert.throws(TypeError, function() {
valueOf.call(s);
}, "symbol");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very clear, glad to see the helper going away where possible. Thanks for taking the extra time to refine these.

@rwaldron rwaldron merged commit 9737a5f into tc39:master Oct 3, 2017
@leobalter leobalter deleted the bigint-valueof-fix branch October 3, 2017 20:54
@littledan
Copy link
Member

littledan commented Oct 12, 2017

Note that although there were only valueOf tests checked in which used this infrastructure, there are more places in the spec where it would be applicable, namely in BigInt.prototype.toString and toLocaleString. cc @thejoshwolfe @cxielarko

@leobalter
Copy link
Member Author

There is a PR for toString already which I'm working to apply fixes at this very moment. We should have an update soon.

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.

4 participants