mirror of https://github.com/tc39/test262.git
Add tests for Symbol.prototype.description
This commit is contained in:
parent
11f476cdbb
commit
cc53f64325
|
@ -77,6 +77,10 @@ numeric-separator-literal
|
|||
String.prototype.matchAll
|
||||
Symbol.matchAll
|
||||
|
||||
# Symbol.prototype.description
|
||||
# https://github.com/tc39/proposal-symbol-description
|
||||
Symbol.prototype.description
|
||||
|
||||
# ECMAScript ⊃ JSON
|
||||
# https://github.com/tc39/proposal-json-superset
|
||||
json-superset
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// 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.
|
||||
features: [Symbol.prototype.description]
|
||||
---*/
|
||||
|
||||
const desc = Object.getOwnPropertyDescriptor(Symbol.prototype, 'description');
|
||||
assert.sameValue(typeof desc.get, 'function');
|
||||
assert.sameValue(desc.set, undefined);
|
||||
assert.sameValue(desc.writable, undefined);
|
||||
assert.sameValue(desc.enumerable, false);
|
||||
assert.sameValue(desc.configurable, true);
|
|
@ -0,0 +1,21 @@
|
|||
// 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);
|
|
@ -0,0 +1,42 @@
|
|||
// 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]
|
||||
---*/
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol.prototype.description.call(null);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol.prototype.description.call(123);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol.prototype.description.call('test');
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol.prototype.description.call(true);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol.prototype.description.call(undefined);
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol.prototype.description.call(new Proxy({}, {}));
|
||||
});
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
Symbol.prototype.description.call({});
|
||||
});
|
|
@ -0,0 +1,21 @@
|
|||
// 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);
|
Loading…
Reference in New Issue