Debian Codegraph @

js/src/tests/test262/built-ins/Object/create/properties-arg-to-object-non-empty-string.js

raw
1 // Copyright (C) 2019 Leo Balter. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-object.create
6 description: >
7 Throws a TypeError if the Properties argument is a non-empty string
8 info: |
9 Object.create ( O, Properties )
10
11 3. If Properties is not undefined, then
12 a. Return ? ObjectDefineProperties(obj, Properties).
13
14 Runtime Semantics: ObjectDefineProperties ( O, Properties )
15
16 2. Let props be ? ToObject(Properties).
17 3. Let keys be ? props.[[OwnPropertyKeys]]().
18 4. Let descriptors be a new empty List.
19 5. For each element nextKey of keys in List order, do
20 a. Let propDesc be ? props.[[GetOwnProperty]](nextKey).
21 b. If propDesc is not undefined and propDesc.[[Enumerable]] is true, then
22 i. Let descObj be ? Get(props, nextKey).
23 ii. Let desc be ? ToPropertyDescriptor(descObj).
24
25 ToPropertyDescriptor ( Obj )
26
27 1. If Type(Obj) is not Object, throw a TypeError exception.
28 ---*/
29
30 // The first nextKey is 'h' and its OwnProperty in the String object is enumerable
31 // Get(props, nextKey) is an equivalent of Object('hello')[nextKey]
32 // The first descObj will be 'h', so it will throw in ToPropertyDescriptor
33 assert.throws(TypeError, function() {
34 Object.create({}, 'hello');
35 });
36
37 reportCompare(0, 0);