-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// Copyright 2018 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-symbol.prototype.description | ||
description: > | ||
Test the descriptor of Symbol.prototype.description. | ||
info: | | ||
`Symbol.prototype.description` is an accessor property whose | ||
set accessor function is undefined. | ||
includes: [propertyHelper.js] | ||
features: [Symbol.prototype.description] | ||
---*/ | ||
|
||
|
||
var desc = Object.getOwnPropertyDescriptor(Symbol.prototype, 'description'); | ||
|
||
assert.sameValue(desc.set, undefined); | ||
assert.sameValue(desc.writable, undefined); | ||
assert.sameValue(typeof desc.get, 'function'); | ||
|
||
verifyProperty(Symbol.prototype, 'description', { | ||
enumerable: false, | ||
configurable: true, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2018 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-symbol.prototype.description | ||
description: > | ||
Test the get accessor function of Symbol.prototype.description. | ||
info: | | ||
1. Let s be the this value. | ||
2. Let sym be ? thisSymbolValue(s). | ||
3. Return sym.[[Description]]. | ||
features: [Symbol.prototype.description] | ||
---*/ | ||
|
||
const symbol = Symbol('test'); | ||
assert.sameValue(symbol.description, 'test'); | ||
assert.sameValue(symbol.hasOwnProperty('description'), false); | ||
|
||
const empty = Symbol(); | ||
assert.sameValue(empty.description, undefined); | ||
assert.sameValue(empty.hasOwnProperty('description'), false); | ||
|
||
const undef = Symbol(undefined); | ||
assert.sameValue(undef.description, undefined); | ||
assert.sameValue(undef.hasOwnProperty('description'), false); | ||
|
||
const emptyStr = Symbol(''); | ||
assert.sameValue(emptyStr.description, ''); | ||
assert.sameValue(emptyStr.hasOwnProperty('description'), false); |
46 changes: 46 additions & 0 deletions
46
test/built-ins/Symbol/prototype/description/this-val-non-symbol.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2018 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-symbol.prototype.description | ||
description: > | ||
Behavior when `this` value is an object without a [[SymbolData]] internal | ||
slot. | ||
info: | | ||
1. Let s be the this value. | ||
2. Let sym be ? thisSymbolValue(s). | ||
3. Return sym.[[Description]]. | ||
features: [Symbol.prototype.description] | ||
---*/ | ||
|
||
const getter = Object.getOwnPropertyDescriptor( | ||
Symbol.prototype, 'description' | ||
).get; | ||
|
||
assert.throws(TypeError, function() { | ||
getter.call(null); | ||
}); | ||
|
||
assert.throws(TypeError, function() { | ||
getter.call(123); | ||
}); | ||
|
||
assert.throws(TypeError, function() { | ||
getter.call('test'); | ||
}); | ||
|
||
assert.throws(TypeError, function() { | ||
getter.call(true); | ||
}); | ||
|
||
assert.throws(TypeError, function() { | ||
getter.call(undefined); | ||
}); | ||
|
||
assert.throws(TypeError, function() { | ||
getter.call(new Proxy({}, {})); | ||
}); | ||
|
||
assert.throws(TypeError, function() { | ||
getter.call({}); | ||
}); |
33 changes: 33 additions & 0 deletions
33
test/built-ins/Symbol/prototype/description/this-val-symbol.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2018 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-symbol.prototype.description | ||
description: > | ||
Test that calling the getter on a Symbol or a Symbol wrapper object works. | ||
info: | | ||
1. Let s be the this value. | ||
2. Let sym be ? thisSymbolValue(s). | ||
3. Return sym.[[Description]]. | ||
features: [Symbol.prototype.description] | ||
---*/ | ||
|
||
const getter = Object.getOwnPropertyDescriptor( | ||
Symbol.prototype, 'description' | ||
).get; | ||
|
||
const symbol = Symbol('test'); | ||
assert.sameValue(getter.call(symbol), 'test'); | ||
assert.sameValue(getter.call(Object(symbol)), 'test'); | ||
|
||
const empty = Symbol(); | ||
assert.sameValue(getter.call(empty), undefined); | ||
assert.sameValue(getter.call(Object(empty)), undefined); | ||
|
||
const undef = Symbol(undefined); | ||
assert.sameValue(getter.call(undef), undefined); | ||
assert.sameValue(getter.call(Object(undef)), undefined); | ||
|
||
const emptyStr = Symbol(''); | ||
assert.sameValue(getter.call(emptyStr), ''); | ||
assert.sameValue(getter.call(Object(emptyStr)), ''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright 2018 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-symbol.prototype.description | ||
description: > | ||
Test Symbol.prototype.description called on wrapper objects. | ||
info: | | ||
1. Let s be the this value. | ||
2. Let sym be ? thisSymbolValue(s). | ||
3. Return sym.[[Description]]. | ||
features: [Symbol.prototype.description] | ||
---*/ | ||
|
||
const symbol = Object(Symbol('test')); | ||
assert.sameValue(symbol.description, 'test'); | ||
assert.sameValue(symbol.hasOwnProperty('description'), false); | ||
|
||
const empty = Object(Symbol()); | ||
assert.sameValue(empty.description, undefined); | ||
assert.sameValue(empty.hasOwnProperty('description'), false); | ||
|
||
const undef = Object(Symbol(undefined)); | ||
assert.sameValue(undef.description, undefined); | ||
assert.sameValue(undef.hasOwnProperty('description'), false); | ||
|
||
const emptyStr = Object(Symbol('')); | ||
assert.sameValue(emptyStr.description, ''); | ||
assert.sameValue(emptyStr.hasOwnProperty('description'), false); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This comment was marked as resolved.
Sorry, something went wrong.