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

Add tests for Symbol.prototype.description #1590

Merged
merged 3 commits into from
Jun 8, 2018

Conversation

joyeecheung
Copy link
Contributor

@joyeecheung
Copy link
Contributor Author

const desc = Object.getOwnPropertyDescriptor(Symbol.prototype, 'description');
assert.sameValue(typeof desc.get, 'function');
assert.sameValue(desc.set, undefined);
assert.sameValue(desc.writable, undefined);
Copy link
Member

Choose a reason for hiding this comment

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

There’s a propertyHelper that could be used here

assert.sameValue(symbol.description, 'test');
assert.sameValue(symbol.hasOwnProperty('description'), false);

const empty = Symbol();

This comment was marked as resolved.

---*/

assert.throws(TypeError, function() {
Symbol.prototype.description.call(null);
Copy link
Member

Choose a reason for hiding this comment

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

This fails, but for the wrong reason. The getter is being called on Symbol.prototype. You should instead extract the getter with Object.getOwnPropertyDescriptor.

@joyeecheung
Copy link
Contributor Author

@ljharb @michaelficarra Thanks for the reviews. I have updated the PR, PTAL.

michaelficarra
michaelficarra previously approved these changes Jun 7, 2018
ljharb
ljharb previously approved these changes Jun 7, 2018
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

LGTM - we may also want to add some tests that .call-ing the getter on real symbols works too?

gsathya
gsathya previously approved these changes Jun 7, 2018
@joyeecheung joyeecheung dismissed stale reviews from gsathya, ljharb, and michaelficarra via 21c2bab June 7, 2018 21:36
@joyeecheung
Copy link
Contributor Author

LGTM - we may also want to add some tests that .call-ing the getter on real symbols works too?

@ljharb Sure! I've updated the PR, PTAL.

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.

5 participants