| 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 |
ToObject conversion from Object: The result is the input |
| 7 |
argument (no conversion) |
| 8 |
es5id: 9.9_A6 |
| 9 |
description: Converting from Objects to Object |
| 10 |
---*/ |
| 11 |
|
| 12 |
function MyObject(val) { |
| 13 |
this.value = val; |
| 14 |
this.valueOf = function() { |
| 15 |
return this.value; |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
var x = new MyObject(1); |
| 20 |
var y = Object(x); |
| 21 |
|
| 22 |
// CHECK#1 |
| 23 |
if (y.valueOf() !== x.valueOf()) { |
| 24 |
$ERROR('#1: Object(obj).valueOf() === obj.valueOf(). Actual: ' + (Object(obj).valueOf())); |
| 25 |
} |
| 26 |
|
| 27 |
// CHECK#2 |
| 28 |
if (typeof y !== typeof x) { |
| 29 |
$ERROR('#2: typeof Object(obj) === typeof obj. Actual: ' + (typeof Object(obj))); |
| 30 |
} |
| 31 |
|
| 32 |
// CHECK#3 |
| 33 |
if (y.constructor.prototype !== x.constructor.prototype) { |
| 34 |
$ERROR('#3: Object(obj).constructor.prototype === obj.constructor.prototype. Actual: ' + (Object(obj).constructor.prototype)); |
| 35 |
} |
| 36 |
|
| 37 |
|
| 38 |
// CHECK#4 |
| 39 |
if (y !== x) { |
| 40 |
$ERROR('#4: Object(obj) === obj'); |
| 41 |
} |