From db5b9c1dd937c6a5e443a6f8ecebd1452b4d25b1 Mon Sep 17 00:00:00 2001 From: Rick Waldron Date: Wed, 16 Sep 2020 15:20:45 -0400 Subject: [PATCH] Object.defineProperties: Property description must be an object. Fixes gh-1754 --- ...escription-must-be-an-object-not-bigint.js | 29 +++++++++++++++++++ ...description-must-be-an-object-not-false.js | 28 ++++++++++++++++++ ...-description-must-be-an-object-not-null.js | 28 ++++++++++++++++++ ...escription-must-be-an-object-not-number.js | 28 ++++++++++++++++++ ...escription-must-be-an-object-not-string.js | 28 ++++++++++++++++++ ...escription-must-be-an-object-not-symbol.js | 29 +++++++++++++++++++ ...-description-must-be-an-object-not-true.js | 28 ++++++++++++++++++ ...ription-must-be-an-object-not-undefined.js | 28 ++++++++++++++++++ 8 files changed, 226 insertions(+) create mode 100644 test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-bigint.js create mode 100644 test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-false.js create mode 100644 test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-null.js create mode 100644 test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-number.js create mode 100644 test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-string.js create mode 100644 test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-symbol.js create mode 100644 test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-true.js create mode 100644 test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-undefined.js diff --git a/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-bigint.js b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-bigint.js new file mode 100644 index 0000000000..168a093b47 --- /dev/null +++ b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-bigint.js @@ -0,0 +1,29 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-objectdefineproperties +description: > + Property description must be an object (bigint) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +features: [BigInt] +---*/ + +assert.throws(TypeError, () => { + Object.defineProperties({}, { + a: 0n + }); +}); diff --git a/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-false.js b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-false.js new file mode 100644 index 0000000000..a522824ab4 --- /dev/null +++ b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-false.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-objectdefineproperties +description: > + Property description must be an object (false) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperties({}, { + a: false + }); +}); diff --git a/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-null.js b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-null.js new file mode 100644 index 0000000000..38bae861a6 --- /dev/null +++ b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-null.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-objectdefineproperties +description: > + Property description must be an object (null) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperties({}, { + a: null + }); +}); diff --git a/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-number.js b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-number.js new file mode 100644 index 0000000000..a3c6f40aed --- /dev/null +++ b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-number.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-objectdefineproperties +description: > + Property description must be an object (number) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperties({}, { + a: 1 + }); +}); diff --git a/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-string.js b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-string.js new file mode 100644 index 0000000000..e1f2b26e2a --- /dev/null +++ b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-string.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-objectdefineproperties +description: > + Property description must be an object (string) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperties({}, { + a: '' + }); +}); diff --git a/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-symbol.js b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-symbol.js new file mode 100644 index 0000000000..2847f77a60 --- /dev/null +++ b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-symbol.js @@ -0,0 +1,29 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-objectdefineproperties +description: > + Property description must be an object (symbol) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +features: [Symbol] +---*/ + +assert.throws(TypeError, () => { + Object.defineProperties({}, { + a: Symbol() + }); +}); diff --git a/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-true.js b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-true.js new file mode 100644 index 0000000000..babc75d0be --- /dev/null +++ b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-true.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-objectdefineproperties +description: > + Property description must be an object (true) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperties({}, { + a: true + }); +}); diff --git a/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-undefined.js b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-undefined.js new file mode 100644 index 0000000000..34335f880e --- /dev/null +++ b/test/built-ins/Object/defineProperties/property-description-must-be-an-object-not-undefined.js @@ -0,0 +1,28 @@ +// Copyright (C) 2020 Rick Waldron. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-objectdefineproperties +description: > + Property description must be an object (undefined) +info: | + ObjectDefineProperties ( O, Properties ) + + ... + For each element nextKey of keys, do + Let propDesc be ? props.[[GetOwnProperty]](nextKey). + If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + Let descObj be ? Get(props, nextKey). + Let desc be ? ToPropertyDescriptor(descObj). + ... + + ToPropertyDescriptor ( Obj ) + + If Type(Obj) is not Object, throw a TypeError exception. + ... +---*/ + +assert.throws(TypeError, () => { + Object.defineProperties({}, { + a: undefined + }); +});