Add tests for Symbol.prototype.description

This commit is contained in:
Joyee Cheung 2018-06-07 21:39:02 +08:00
parent 11f476cdbb
commit cc53f64325
No known key found for this signature in database
GPG Key ID: 92B78A53C8303B8D
5 changed files with 107 additions and 0 deletions

View File

@ -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

View 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);

View 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);

View 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({});
});

View 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);