Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/S15.2.2.1_A1_T5.js

raw
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 info: |
6 When the Object constructor is called with no arguments the following steps are taken:
7 (The argument value was not supplied or its type was Null or Undefined.)
8 i) Create a new native ECMAScript object.
9 ii) The [[Prototype]] property of the newly constructed object is set to the Object prototype object.
10 iii) The [[Class]] property of the newly constructed object is set to "Object".
11 iv) The newly constructed object has no [[Value]] property.
12 v) Return the newly created native object
13 es5id: 15.2.2.1_A1_T5
14 description: >
15 Creating new Object(x), where x is "undefined", and checking it
16 properties
17 ---*/
18
19 var obj = new Object(x);
20
21 // CHECK#0
22 if (obj === undefined) {
23 $ERROR('#0: new Object(undefined) return the newly created native object.');
24 }
25
26 // CHECK#1
27 if (obj.constructor !== Object) {
28 $ERROR('#1: new Object(undefined) create a new native ECMAScript object');
29 }
30
31 // CHECK#2
32 if (!(Object.prototype.isPrototypeOf(obj))) {
33 $ERROR('#2: when new Object(undefined) calls the [[Prototype]] property of the newly constructed object is set to the Object prototype object.');
34 }
35
36 // CHECK#3
37 var to_string_result = '[object ' + 'Object' + ']';
38 if (obj.toString() !== to_string_result) {
39 $ERROR('#3: when new Object(undefined) calls the [[Class]] property of the newly constructed object is set to "Object".');
40 }
41
42 // CHECK#4
43 if (obj.valueOf().toString() !== to_string_result.toString()) {
44 $ERROR('#4: when new Object(undefined) calls the newly constructed object has no [[Value]] property.');
45 }
46
47 var x;