diff --git a/test/built-ins/Symbol/prototype/description/description-symboldescriptivestring.js b/test/built-ins/Symbol/prototype/description/description-symboldescriptivestring.js new file mode 100644 index 0000000000..0bf5e63993 --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/description-symboldescriptivestring.js @@ -0,0 +1,32 @@ +// Copyright (C) 2018 Rick Waldron. All rights reserved. +// Copyright (C) 2018 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-symbol.prototype.description +description: > + SymbolDescriptiveString(sym) via Symbol.prototype.toString() +info: | + SymbolDescriptiveString ( sym ) + + Assert: Type(sym) is Symbol. + Let desc be sym's [[Description]] value. + If desc is undefined, let desc be the empty string. + Assert: Type(desc) is String. + Return the string-concatenation of "Symbol(", desc, and ")". + +includes: [propertyHelper.js] +features: [Symbol.prototype.description] +---*/ + +const symbol = Symbol('foo'); + +assert.sameValue( + symbol.description, + 'foo', + 'The value of symbol.description is "foo"' +); +assert.sameValue( + symbol.toString(), + `Symbol(${symbol.description})`, + `symbol.toString() returns "Symbol(${symbol.description})"` +); diff --git a/test/built-ins/Symbol/prototype/description/descriptor.js b/test/built-ins/Symbol/prototype/description/descriptor.js index bc66519624..25c4f14d54 100644 --- a/test/built-ins/Symbol/prototype/description/descriptor.js +++ b/test/built-ins/Symbol/prototype/description/descriptor.js @@ -15,9 +15,23 @@ 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'); +assert.sameValue( + desc.set, + undefined, + 'The value of desc.set is `undefined`' +); + +assert.sameValue( + desc.writable, + undefined, + 'The value of desc.writable is `undefined`' +); + +assert.sameValue( + typeof desc.get, + 'function', + 'The value of `typeof desc.get` is "function"' +); verifyProperty(Symbol.prototype, 'description', { enumerable: false, diff --git a/test/built-ins/Symbol/prototype/description/get.js b/test/built-ins/Symbol/prototype/description/get.js index 54c0fb06b2..e6530cba8f 100644 --- a/test/built-ins/Symbol/prototype/description/get.js +++ b/test/built-ins/Symbol/prototype/description/get.js @@ -13,17 +13,29 @@ features: [Symbol.prototype.description] ---*/ const symbol = Symbol('test'); -assert.sameValue(symbol.description, 'test'); -assert.sameValue(symbol.hasOwnProperty('description'), false); +assert.sameValue( + symbol.description, + 'test', + 'The value of symbol.description is "test"' +); const empty = Symbol(); -assert.sameValue(empty.description, undefined); -assert.sameValue(empty.hasOwnProperty('description'), false); +assert.sameValue( + empty.description, + undefined, + 'The value of empty.description is `undefined`' +); const undef = Symbol(undefined); -assert.sameValue(undef.description, undefined); -assert.sameValue(undef.hasOwnProperty('description'), false); +assert.sameValue( + undef.description, + undefined, + 'The value of undef.description is `undefined`' +); const emptyStr = Symbol(''); -assert.sameValue(emptyStr.description, ''); -assert.sameValue(emptyStr.hasOwnProperty('description'), false); +assert.sameValue( + emptyStr.description, + '', + 'The value of emptyStr.description is ""' +); diff --git a/test/built-ins/Symbol/prototype/description/is-not-own-property.js b/test/built-ins/Symbol/prototype/description/is-not-own-property.js new file mode 100644 index 0000000000..88ad30fd5e --- /dev/null +++ b/test/built-ins/Symbol/prototype/description/is-not-own-property.js @@ -0,0 +1,14 @@ +// 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: Ensure that 'description' is not an own property of Symbols +features: [Symbol.prototype.description] +---*/ + +assert.sameValue( + Symbol().hasOwnProperty('description'), + false, + 'Symbol().hasOwnProperty("description") returns 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 index 0d2fc40b18..b85c48cbf4 100644 --- a/test/built-ins/Symbol/prototype/description/this-val-non-symbol.js +++ b/test/built-ins/Symbol/prototype/description/this-val-non-symbol.js @@ -4,7 +4,7 @@ /*--- esid: sec-symbol.prototype.description description: > - Behavior when `this` value is an object without a [[SymbolData]] internal + Behavior when "this" value is an object without a [[SymbolData]] internal slot. info: | 1. Let s be the this value. @@ -19,28 +19,28 @@ const getter = Object.getOwnPropertyDescriptor( assert.throws(TypeError, function() { getter.call(null); -}); +}, 'getter.call(null) throws TypeError'); assert.throws(TypeError, function() { getter.call(123); -}); +}, 'getter.call(123) throws TypeError'); assert.throws(TypeError, function() { getter.call('test'); -}); +}, 'getter.call("test") throws TypeError'); assert.throws(TypeError, function() { getter.call(true); -}); +}, 'getter.call(true) throws TypeError'); assert.throws(TypeError, function() { getter.call(undefined); -}); +}, 'getter.call(undefined) throws TypeError'); assert.throws(TypeError, function() { getter.call(new Proxy({}, {})); -}); +}, 'getter.call(new Proxy({}, {})) throws TypeError'); assert.throws(TypeError, function() { getter.call({}); -}); +}, 'getter.call({}) throws TypeError'); diff --git a/test/built-ins/Symbol/prototype/description/this-val-symbol.js b/test/built-ins/Symbol/prototype/description/this-val-symbol.js index 604e4e47ea..d49359a8a3 100644 --- a/test/built-ins/Symbol/prototype/description/this-val-symbol.js +++ b/test/built-ins/Symbol/prototype/description/this-val-symbol.js @@ -17,17 +17,49 @@ const getter = Object.getOwnPropertyDescriptor( ).get; const symbol = Symbol('test'); -assert.sameValue(getter.call(symbol), 'test'); -assert.sameValue(getter.call(Object(symbol)), 'test'); +assert.sameValue( + getter.call(symbol), + 'test', + 'getter.call(symbol) returns "test"' +); +assert.sameValue( + getter.call(Object(symbol)), + 'test', + 'getter.call(Object(symbol)) returns "test"' +); const empty = Symbol(); -assert.sameValue(getter.call(empty), undefined); -assert.sameValue(getter.call(Object(empty)), undefined); +assert.sameValue( + getter.call(empty), + undefined, + 'getter.call(empty) returns `undefined`' +); +assert.sameValue( + getter.call(Object(empty)), + undefined, + 'getter.call(Object(empty)) returns `undefined`' +); const undef = Symbol(undefined); -assert.sameValue(getter.call(undef), undefined); -assert.sameValue(getter.call(Object(undef)), undefined); +assert.sameValue( + getter.call(undef), + undefined, + 'getter.call(undef) returns `undefined`' +); +assert.sameValue( + getter.call(Object(undef)), + undefined, + 'getter.call(Object(undef)) returns `undefined`' +); const emptyStr = Symbol(''); -assert.sameValue(getter.call(emptyStr), ''); -assert.sameValue(getter.call(Object(emptyStr)), ''); +assert.sameValue( + getter.call(emptyStr), + '', + 'getter.call(emptyStr) returns ""' +); +assert.sameValue( + getter.call(Object(emptyStr)), + '', + 'getter.call(Object(emptyStr)) returns ""' +); diff --git a/test/built-ins/Symbol/prototype/description/wrapper.js b/test/built-ins/Symbol/prototype/description/wrapper.js index c117f1b73c..8aac889d7b 100644 --- a/test/built-ins/Symbol/prototype/description/wrapper.js +++ b/test/built-ins/Symbol/prototype/description/wrapper.js @@ -13,17 +13,29 @@ features: [Symbol.prototype.description] ---*/ const symbol = Object(Symbol('test')); -assert.sameValue(symbol.description, 'test'); -assert.sameValue(symbol.hasOwnProperty('description'), false); +assert.sameValue( + symbol.description, + 'test', + 'The value of symbol.description is "test"' +); const empty = Object(Symbol()); -assert.sameValue(empty.description, undefined); -assert.sameValue(empty.hasOwnProperty('description'), false); +assert.sameValue( + empty.description, + undefined, + 'The value of empty.description is `undefined`' +); const undef = Object(Symbol(undefined)); -assert.sameValue(undef.description, undefined); -assert.sameValue(undef.hasOwnProperty('description'), false); +assert.sameValue( + undef.description, + undefined, + 'The value of undef.description is `undefined`' +); const emptyStr = Object(Symbol('')); -assert.sameValue(emptyStr.description, ''); -assert.sameValue(emptyStr.hasOwnProperty('description'), false); +assert.sameValue( + emptyStr.description, + '', + 'The value of emptyStr.description is ""' +);