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 Number: create a new Number object michael@0: * whose [[value]] property is set to the value of the number michael@0: * michael@0: * @path ch09/9.9/S9.9_A4.js michael@0: * @description Converting from various numbers to Object michael@0: */ michael@0: michael@0: // CHECK#1 michael@0: if (Object(0).valueOf() !== 0){ michael@0: $ERROR('#1: Object(0).valueOf() === 0. Actual: ' + (Object(0).valueOf())); michael@0: } michael@0: michael@0: // CHECK#2 michael@0: if (typeof Object(0) !== "object"){ michael@0: $ERROR('#2: typeof Object(0) === "object". Actual: ' + (typeof Object(0))); michael@0: } michael@0: michael@0: // CHECK#3 michael@0: if (Object(0).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#3: Object(0).constructor.prototype === Number.prototype. Actual: ' + (Object(0).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#4 michael@0: if (Object(-0).valueOf() !== -0){ michael@0: $ERROR('#4.1: Object(-0).valueOf() === 0. Actual: ' + (Object(-0).valueOf())); michael@0: } else if (1/Object(-0).valueOf() !== Number.NEGATIVE_INFINITY) { michael@0: $ERROR('#4.2: Object(-0).valueOf() === -0. Actual: +0'); michael@0: } michael@0: michael@0: // CHECK#5 michael@0: if (typeof Object(-0) !== "object"){ michael@0: $ERROR('#5: typeof Object(-0) === "object". Actual: ' + (typeof Object(-0))); michael@0: } michael@0: michael@0: // CHECK#6 michael@0: if (Object(-0).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#6: Object(-0).constructor.prototype === Number.prototype. Actual: ' + (Object(-0).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#7 michael@0: if (Object(1).valueOf() !== 1){ michael@0: $ERROR('#7: Object(1).valueOf() === 1. Actual: ' + (Object(1).valueOf())); michael@0: } michael@0: michael@0: // CHECK#8 michael@0: if (typeof Object(1) !== "object"){ michael@0: $ERROR('#8: typeof Object(1) === "object". Actual: ' + (typeof Object(1))); michael@0: } michael@0: michael@0: // CHECK#9 michael@0: if (Object(1).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#9: Object(1).constructor.prototype === Number.prototype. Actual: ' + (Object(1).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#10 michael@0: if (Object(-1).valueOf() !== -1){ michael@0: $ERROR('#10: Object(-1).valueOf() === -1. Actual: ' + (Object(-1).valueOf())); michael@0: } michael@0: michael@0: // CHECK#11 michael@0: if (typeof Object(-1) !== "object"){ michael@0: $ERROR('#11: typeof Object(-1) === "object". Actual: ' + (typeof Object(-1))); michael@0: } michael@0: michael@0: // CHECK#12 michael@0: if (Object(-1).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#12: Object(-1).constructor.prototype === Number.prototype. Actual: ' + (Object(-1).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#13 michael@0: if (Object(Number.MIN_VALUE).valueOf() !== Number.MIN_VALUE){ michael@0: $ERROR('#13: Object(Number.MIN_VALUE).valueOf() === Number.MIN_VALUE. Actual: ' + (Object(Number.MIN_VALUE).valueOf())); michael@0: } michael@0: michael@0: // CHECK#14 michael@0: if (typeof Object(Number.MIN_VALUE) !== "object"){ michael@0: $ERROR('#14: typeof Object(Number.MIN_VALUE) === "object". Actual: ' + (typeof Object(Number.MIN_VALUE))); michael@0: } michael@0: michael@0: // CHECK#15 michael@0: if (Object(Number.MIN_VALUE).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#15: Object(Number.MIN_VALUE).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.MIN_VALUE).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#16 michael@0: if (Object(Number.MAX_VALUE).valueOf() !== Number.MAX_VALUE){ michael@0: $ERROR('#16: Object(Number.MAX_VALUE).valueOf() === Number.MAX_VALUE. Actual: ' + (Object(Number.MAX_VALUE).valueOf())); michael@0: } michael@0: michael@0: // CHECK#17 michael@0: if (typeof Object(Number.MAX_VALUE) !== "object"){ michael@0: $ERROR('#17: typeof Object(Number.MAX_VALUE) === "object". Actual: ' + (typeof Object(Number.MAX_VALUE))); michael@0: } michael@0: michael@0: // CHECK#18 michael@0: if (Object(Number.MAX_VALUE).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#18: Object(Number.MAX_VALUE).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.MAX_VALUE).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#19 michael@0: if (Object(Number.POSITIVE_INFINITY).valueOf() !== Number.POSITIVE_INFINITY){ michael@0: $ERROR('#19: Object(Number.POSITIVE_INFINITY).valueOf() === Number.POSITIVE_INFINITY. Actual: ' + (Object(Number.POSITIVE_INFINITY).valueOf())); michael@0: } michael@0: michael@0: // CHECK#20 michael@0: if (typeof Object(Number.POSITIVE_INFINITY) !== "object"){ michael@0: $ERROR('#20: typeof Object(Number.POSITIVE_INFINITY) === "object". Actual: ' + (typeof Object(Number.POSITIVE_INFINITY))); michael@0: } michael@0: michael@0: // CHECK#21 michael@0: if (Object(Number.POSITIVE_INFINITY).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#21: Object(Number.POSITIVE_INFINITY).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.POSITIVE_INFINITY).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#22 michael@0: if (Object(Number.NEGATIVE_INFINITY).valueOf() !== Number.NEGATIVE_INFINITY){ michael@0: $ERROR('#22: Object(Number.NEGATIVE_INFINITY).valueOf() === Number.NEGATIVE_INFINITY. Actual: ' + (Object(Number.NEGATIVE_INFINITY).valueOf())); michael@0: } michael@0: michael@0: // CHECK#23 michael@0: if (typeof Object(Number.NEGATIVE_INFINITY) !== "object"){ michael@0: $ERROR('#23: typeof Object(Number.NEGATIVE_INFINITY) === "object". Actual: ' + (typeof Object(Number.NEGATIVE_INFINITY))); michael@0: } michael@0: michael@0: // CHECK#24 michael@0: if (Object(Number.NEGATIVE_INFINITY).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#24: Object(Number.NEGATIVE_INFINITY).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.NEGATIVE_INFINITY).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#25 michael@0: if (isNaN(Object(Number.NaN).valueOf()) !== true){ michael@0: $ERROR('#25: Object(Number.NaN).valueOf() === Not-a-Number. Actual: ' + (Object(Number.NaN).valueOf())); michael@0: } michael@0: michael@0: // CHECK#26 michael@0: if (typeof Object(Number.NaN) !== "object"){ michael@0: $ERROR('#26: typeof Object(Number.NaN) === "object". Actual: ' + (typeof Object(Number.NaN))); michael@0: } michael@0: michael@0: // CHECK#27 michael@0: if (Object(Number.NaN).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#27: Object(Number.NaN).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.NaN).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#28 michael@0: if (Object(1.2345).valueOf() !== 1.2345){ michael@0: $ERROR('#28: Object(1.2345).valueOf() === 1.2345. Actual: ' + (Object(1.2345).valueOf())); michael@0: } michael@0: michael@0: // CHECK#29 michael@0: if (typeof Object(1.2345) !== "object"){ michael@0: $ERROR('#29: typeof Object(1.2345) === "object". Actual: ' + (typeof Object(1.2345))); michael@0: } michael@0: michael@0: // CHECK#30 michael@0: if (Object(1.2345).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#30: Object(1.2345).constructor.prototype === Number.prototype. Actual: ' + (Object(1.2345).constructor.prototype)); michael@0: } michael@0: michael@0: // CHECK#31 michael@0: if (Object(-1.2345).valueOf() !== -1.2345){ michael@0: $ERROR('#31: Object(-1.2345).valueOf() === -1.2345. Actual: ' + (Object(-1.2345).valueOf())); michael@0: } michael@0: michael@0: // CHECK#32 michael@0: if (typeof Object(-1.2345) !== "object"){ michael@0: $ERROR('#32: typeof Object(-1.2345) === "object". Actual: ' + (typeof Object(-1.2345))); michael@0: } michael@0: michael@0: // CHECK#33 michael@0: if (Object(-1.2345).constructor.prototype !== Number.prototype){ michael@0: $ERROR('#33: Object(-1.2345).constructor.prototype === Number.prototype. Actual: ' + (Object(-1.2345).constructor.prototype)); michael@0: } michael@0: