-
Notifications
You must be signed in to change notification settings - Fork 469
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
Conversation
const desc = Object.getOwnPropertyDescriptor(Symbol.prototype, 'description'); | ||
assert.sameValue(typeof desc.get, 'function'); | ||
assert.sameValue(desc.set, undefined); | ||
assert.sameValue(desc.writable, undefined); |
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.
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.
This comment was marked as resolved.
Sorry, something went wrong.
---*/ | ||
|
||
assert.throws(TypeError, function() { | ||
Symbol.prototype.description.call(null); |
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.
This fails, but for the wrong reason. The getter is being called on Symbol.prototype
. You should instead extract the getter with Object.getOwnPropertyDescriptor
.
@ljharb @michaelficarra Thanks for the reviews. I have updated the PR, PTAL. |
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.
LGTM - we may also want to add some tests that .call-ing the getter on real symbols works too?
21c2bab
@ljharb Sure! I've updated the PR, PTAL. |
Refs: tc39/proposal-Symbol-description#5
V8 implementation in https://chromium-review.googlesource.com/c/v8/v8/+/1088871