diff --git a/features.txt b/features.txt index 257f379ee6..a0b1565d3d 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 0000000000..bc66519624 --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/descriptor.js @@ -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, +}); 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 0000000000..54c0fb06b2 --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/get.js @@ -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); 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 0000000000..0d2fc40b18 --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/this-val-non-symbol.js @@ -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({}); +}); diff --git a/test/built-ins/Symbol/prototype/description/this-val-symbol.js b/test/built-ins/Symbol/prototype/description/this-val-symbol.js new file mode 100644 index 0000000000..604e4e47ea --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/this-val-symbol.js @@ -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)), ''); 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 0000000000..c117f1b73c --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/wrapper.js @@ -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);