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