diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/create/properties-arg-to-object-non-empty-string.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Object/create/properties-arg-to-object-non-empty-string.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/create/properties-arg-to-object-non-empty-string.js b/js/src/tests/test262/built-ins/Object/create/properties-arg-to-object-non-empty-string.js new file mode 100644 index 0000000000..d14c034557 --- /dev/null +++ b/js/src/tests/test262/built-ins/Object/create/properties-arg-to-object-non-empty-string.js @@ -0,0 +1,37 @@ +// Copyright (C) 2019 Leo Balter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-object.create +description: > + Throws a TypeError if the Properties argument is a non-empty string +info: | + Object.create ( O, Properties ) + + 3. If Properties is not undefined, then + a. Return ? ObjectDefineProperties(obj, Properties). + + Runtime Semantics: ObjectDefineProperties ( O, Properties ) + + 2. Let props be ? ToObject(Properties). + 3. Let keys be ? props.[[OwnPropertyKeys]](). + 4. Let descriptors be a new empty List. + 5. For each element nextKey of keys in List order, do + a. Let propDesc be ? props.[[GetOwnProperty]](nextKey). + b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then + i. Let descObj be ? Get(props, nextKey). + ii. Let desc be ? ToPropertyDescriptor(descObj). + + ToPropertyDescriptor ( Obj ) + + 1. If Type(Obj) is not Object, throw a TypeError exception. +---*/ + +// The first nextKey is 'h' and its OwnProperty in the String object is enumerable +// Get(props, nextKey) is an equivalent of Object('hello')[nextKey] +// The first descObj will be 'h', so it will throw in ToPropertyDescriptor +assert.throws(TypeError, function() { + Object.create({}, 'hello'); +}); + +reportCompare(0, 0); |