mirror of
https://github.com/tc39/test262.git
synced 2025-05-31 04:00:34 +02:00
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
|
String.prototype.matchAll
|
||||||
Symbol.matchAll
|
Symbol.matchAll
|
||||||
|
|
||||||
|
# Symbol.prototype.description
|
||||||
|
# https://github.com/tc39/proposal-symbol-description
|
||||||
|
Symbol.prototype.description
|
||||||
|
|
||||||
# ECMAScript ⊃ JSON
|
# ECMAScript ⊃ JSON
|
||||||
# https://github.com/tc39/proposal-json-superset
|
# https://github.com/tc39/proposal-json-superset
|
||||||
json-superset
|
json-superset
|
||||||
|
19
test/built-ins/Symbol/prototype/description/descriptor.js
vendored
Normal file
19
test/built-ins/Symbol/prototype/description/descriptor.js
vendored
Normal file
@ -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);
|
21
test/built-ins/Symbol/prototype/description/get.js
vendored
Normal file
21
test/built-ins/Symbol/prototype/description/get.js
vendored
Normal file
@ -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);
|
42
test/built-ins/Symbol/prototype/description/this-val-non-symbol.js
vendored
Normal file
42
test/built-ins/Symbol/prototype/description/this-val-non-symbol.js
vendored
Normal file
@ -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({});
|
||||||
|
});
|
21
test/built-ins/Symbol/prototype/description/wrapper.js
vendored
Normal file
21
test/built-ins/Symbol/prototype/description/wrapper.js
vendored
Normal file
@ -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…
x
Reference in New Issue
Block a user