michael@0: // Copyright 2009 the Sputnik authors. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * ToObject conversion from Object: The result is the input michael@0: * argument (no conversion) michael@0: * michael@0: * @path ch09/9.9/S9.9_A6.js michael@0: * @description Converting from Objects to Object michael@0: */ michael@0: michael@0: function MyObject( val ) { michael@0: this.value = val; michael@0: this.valueOf = function (){ return this.value; } michael@0: } michael@0: michael@0: var x = new MyObject(1); michael@0: var y = Object(x); michael@0: michael@0: // CHECK#1 michael@0: if (y.valueOf() !== x.valueOf()){ michael@0: $ERROR('#1: Object(obj).valueOf() === obj.valueOf(). Actual: ' + (Object(obj).valueOf())); michael@0: } michael@0: michael@0: // CHECK#2 michael@0: if (typeof y !== typeof x){ michael@0: $ERROR('#2: typeof Object(obj) === typeof obj. Actual: ' + (typeof Object(obj))); michael@0: } michael@0: michael@0: // CHECK#3 michael@0: if (y.constructor.prototype !== x.constructor.prototype){ michael@0: $ERROR('#3: Object(obj).constructor.prototype === obj.constructor.prototype. Actual: ' + (Object(obj).constructor.prototype)); michael@0: } michael@0: michael@0: michael@0: // CHECK#4 michael@0: if (y !== x){ michael@0: $ERROR('#4: Object(obj) === obj'); michael@0: } michael@0: