Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/S15.2.2.1_A1_T4.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_T4
14 description: Creating new Object(undefined) and checking its properties
15 ---*/
16
17 var obj = new Object(undefined);
18
19 // CHECK#0
20 if (obj === undefined) {
21 $ERROR('#0: new Object(undefined) return the newly created native object.');
22 }
23
24 // CHECK#1
25 if (obj.constructor !== Object) {
26 $ERROR('#1: new Object(undefined) create a new native ECMAScript object');
27 }
28
29 // CHECK#2
30 if (!(Object.prototype.isPrototypeOf(obj))) {
31 $ERROR('#2: when new Object(undefined) calls the [[Prototype]] property of the newly constructed object is set to the Object prototype object.');
32 }
33
34 // CHECK#3
35 var to_string_result = '[object ' + 'Object' + ']';
36 if (obj.toString() !== to_string_result) {
37 $ERROR('#3: when new Object(undefined) calls the [[Class]] property of the newly constructed object is set to "Object".');
38 }
39
40 // CHECK#4
41 if (obj.valueOf().toString() !== to_string_result.toString()) {
42 $ERROR('#4: when new Object(undefined) calls the newly constructed object has no [[Value]] property.');
43 }