From cc53f64325599bf0c583dd034b762282b9485976 Mon Sep 17 00:00:00 2001 From: Joyee Cheung <joyee@igalia.com> Date: Thu, 7 Jun 2018 21:39:02 +0800 Subject: [PATCH] Add tests for Symbol.prototype.description --- features.txt | 4 ++ .../prototype/description/descriptor.js | 19 +++++++++ .../Symbol/prototype/description/get.js | 21 ++++++++++ .../description/this-val-non-symbol.js | 42 +++++++++++++++++++ .../Symbol/prototype/description/wrapper.js | 21 ++++++++++ 5 files changed, 107 insertions(+) create mode 100644 test/built-ins/Symbol/prototype/description/descriptor.js create mode 100644 test/built-ins/Symbol/prototype/description/get.js create mode 100644 test/built-ins/Symbol/prototype/description/this-val-non-symbol.js create mode 100644 test/built-ins/Symbol/prototype/description/wrapper.js 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..0b3d2db3c3 --- /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 0000000000..64c18dced0 --- /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 0000000000..89e222d444 --- /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 0000000000..4acb78fe6a --- /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); -- GitLab