diff --git a/features.txt b/features.txt index 257f379ee658f006a17b7868ce5259353ff84f9a..a0b1565d3d4854d5369702a227468db0bc90db5a 100644 --- a/features.txt +++ b/features.txt @@ -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 diff --git a/test/built-ins/Symbol/prototype/description/descriptor.js b/test/built-ins/Symbol/prototype/description/descriptor.js new file mode 100644 index 0000000000000000000000000000000000000000..0b3d2db3c32b4a7702c92ea3e4a5c0feb189cc1d --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/descriptor.js @@ -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); diff --git a/test/built-ins/Symbol/prototype/description/get.js b/test/built-ins/Symbol/prototype/description/get.js new file mode 100644 index 0000000000000000000000000000000000000000..64c18dced0f3838f1958e670729b46589a08b9bf --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/get.js @@ -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); diff --git a/test/built-ins/Symbol/prototype/description/this-val-non-symbol.js b/test/built-ins/Symbol/prototype/description/this-val-non-symbol.js new file mode 100644 index 0000000000000000000000000000000000000000..89e222d444d052bb23c917b79d2988702bff7326 --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/this-val-non-symbol.js @@ -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({}); +}); diff --git a/test/built-ins/Symbol/prototype/description/wrapper.js b/test/built-ins/Symbol/prototype/description/wrapper.js new file mode 100644 index 0000000000000000000000000000000000000000..4acb78fe6abc7c2b6177459415dca1d4035efda7 --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/wrapper.js @@ -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);