Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /**
5 * ToObject conversion from Number: create a new Number object
6 * whose [[value]] property is set to the value of the number
7 *
8 * @path ch09/9.9/S9.9_A4.js
9 * @description Converting from various numbers to Object
10 */
12 // CHECK#1
13 if (Object(0).valueOf() !== 0){
14 $ERROR('#1: Object(0).valueOf() === 0. Actual: ' + (Object(0).valueOf()));
15 }
17 // CHECK#2
18 if (typeof Object(0) !== "object"){
19 $ERROR('#2: typeof Object(0) === "object". Actual: ' + (typeof Object(0)));
20 }
22 // CHECK#3
23 if (Object(0).constructor.prototype !== Number.prototype){
24 $ERROR('#3: Object(0).constructor.prototype === Number.prototype. Actual: ' + (Object(0).constructor.prototype));
25 }
27 // CHECK#4
28 if (Object(-0).valueOf() !== -0){
29 $ERROR('#4.1: Object(-0).valueOf() === 0. Actual: ' + (Object(-0).valueOf()));
30 } else if (1/Object(-0).valueOf() !== Number.NEGATIVE_INFINITY) {
31 $ERROR('#4.2: Object(-0).valueOf() === -0. Actual: +0');
32 }
34 // CHECK#5
35 if (typeof Object(-0) !== "object"){
36 $ERROR('#5: typeof Object(-0) === "object". Actual: ' + (typeof Object(-0)));
37 }
39 // CHECK#6
40 if (Object(-0).constructor.prototype !== Number.prototype){
41 $ERROR('#6: Object(-0).constructor.prototype === Number.prototype. Actual: ' + (Object(-0).constructor.prototype));
42 }
44 // CHECK#7
45 if (Object(1).valueOf() !== 1){
46 $ERROR('#7: Object(1).valueOf() === 1. Actual: ' + (Object(1).valueOf()));
47 }
49 // CHECK#8
50 if (typeof Object(1) !== "object"){
51 $ERROR('#8: typeof Object(1) === "object". Actual: ' + (typeof Object(1)));
52 }
54 // CHECK#9
55 if (Object(1).constructor.prototype !== Number.prototype){
56 $ERROR('#9: Object(1).constructor.prototype === Number.prototype. Actual: ' + (Object(1).constructor.prototype));
57 }
59 // CHECK#10
60 if (Object(-1).valueOf() !== -1){
61 $ERROR('#10: Object(-1).valueOf() === -1. Actual: ' + (Object(-1).valueOf()));
62 }
64 // CHECK#11
65 if (typeof Object(-1) !== "object"){
66 $ERROR('#11: typeof Object(-1) === "object". Actual: ' + (typeof Object(-1)));
67 }
69 // CHECK#12
70 if (Object(-1).constructor.prototype !== Number.prototype){
71 $ERROR('#12: Object(-1).constructor.prototype === Number.prototype. Actual: ' + (Object(-1).constructor.prototype));
72 }
74 // CHECK#13
75 if (Object(Number.MIN_VALUE).valueOf() !== Number.MIN_VALUE){
76 $ERROR('#13: Object(Number.MIN_VALUE).valueOf() === Number.MIN_VALUE. Actual: ' + (Object(Number.MIN_VALUE).valueOf()));
77 }
79 // CHECK#14
80 if (typeof Object(Number.MIN_VALUE) !== "object"){
81 $ERROR('#14: typeof Object(Number.MIN_VALUE) === "object". Actual: ' + (typeof Object(Number.MIN_VALUE)));
82 }
84 // CHECK#15
85 if (Object(Number.MIN_VALUE).constructor.prototype !== Number.prototype){
86 $ERROR('#15: Object(Number.MIN_VALUE).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.MIN_VALUE).constructor.prototype));
87 }
89 // CHECK#16
90 if (Object(Number.MAX_VALUE).valueOf() !== Number.MAX_VALUE){
91 $ERROR('#16: Object(Number.MAX_VALUE).valueOf() === Number.MAX_VALUE. Actual: ' + (Object(Number.MAX_VALUE).valueOf()));
92 }
94 // CHECK#17
95 if (typeof Object(Number.MAX_VALUE) !== "object"){
96 $ERROR('#17: typeof Object(Number.MAX_VALUE) === "object". Actual: ' + (typeof Object(Number.MAX_VALUE)));
97 }
99 // CHECK#18
100 if (Object(Number.MAX_VALUE).constructor.prototype !== Number.prototype){
101 $ERROR('#18: Object(Number.MAX_VALUE).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.MAX_VALUE).constructor.prototype));
102 }
104 // CHECK#19
105 if (Object(Number.POSITIVE_INFINITY).valueOf() !== Number.POSITIVE_INFINITY){
106 $ERROR('#19: Object(Number.POSITIVE_INFINITY).valueOf() === Number.POSITIVE_INFINITY. Actual: ' + (Object(Number.POSITIVE_INFINITY).valueOf()));
107 }
109 // CHECK#20
110 if (typeof Object(Number.POSITIVE_INFINITY) !== "object"){
111 $ERROR('#20: typeof Object(Number.POSITIVE_INFINITY) === "object". Actual: ' + (typeof Object(Number.POSITIVE_INFINITY)));
112 }
114 // CHECK#21
115 if (Object(Number.POSITIVE_INFINITY).constructor.prototype !== Number.prototype){
116 $ERROR('#21: Object(Number.POSITIVE_INFINITY).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.POSITIVE_INFINITY).constructor.prototype));
117 }
119 // CHECK#22
120 if (Object(Number.NEGATIVE_INFINITY).valueOf() !== Number.NEGATIVE_INFINITY){
121 $ERROR('#22: Object(Number.NEGATIVE_INFINITY).valueOf() === Number.NEGATIVE_INFINITY. Actual: ' + (Object(Number.NEGATIVE_INFINITY).valueOf()));
122 }
124 // CHECK#23
125 if (typeof Object(Number.NEGATIVE_INFINITY) !== "object"){
126 $ERROR('#23: typeof Object(Number.NEGATIVE_INFINITY) === "object". Actual: ' + (typeof Object(Number.NEGATIVE_INFINITY)));
127 }
129 // CHECK#24
130 if (Object(Number.NEGATIVE_INFINITY).constructor.prototype !== Number.prototype){
131 $ERROR('#24: Object(Number.NEGATIVE_INFINITY).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.NEGATIVE_INFINITY).constructor.prototype));
132 }
134 // CHECK#25
135 if (isNaN(Object(Number.NaN).valueOf()) !== true){
136 $ERROR('#25: Object(Number.NaN).valueOf() === Not-a-Number. Actual: ' + (Object(Number.NaN).valueOf()));
137 }
139 // CHECK#26
140 if (typeof Object(Number.NaN) !== "object"){
141 $ERROR('#26: typeof Object(Number.NaN) === "object". Actual: ' + (typeof Object(Number.NaN)));
142 }
144 // CHECK#27
145 if (Object(Number.NaN).constructor.prototype !== Number.prototype){
146 $ERROR('#27: Object(Number.NaN).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.NaN).constructor.prototype));
147 }
149 // CHECK#28
150 if (Object(1.2345).valueOf() !== 1.2345){
151 $ERROR('#28: Object(1.2345).valueOf() === 1.2345. Actual: ' + (Object(1.2345).valueOf()));
152 }
154 // CHECK#29
155 if (typeof Object(1.2345) !== "object"){
156 $ERROR('#29: typeof Object(1.2345) === "object". Actual: ' + (typeof Object(1.2345)));
157 }
159 // CHECK#30
160 if (Object(1.2345).constructor.prototype !== Number.prototype){
161 $ERROR('#30: Object(1.2345).constructor.prototype === Number.prototype. Actual: ' + (Object(1.2345).constructor.prototype));
162 }
164 // CHECK#31
165 if (Object(-1.2345).valueOf() !== -1.2345){
166 $ERROR('#31: Object(-1.2345).valueOf() === -1.2345. Actual: ' + (Object(-1.2345).valueOf()));
167 }
169 // CHECK#32
170 if (typeof Object(-1.2345) !== "object"){
171 $ERROR('#32: typeof Object(-1.2345) === "object". Actual: ' + (typeof Object(-1.2345)));
172 }
174 // CHECK#33
175 if (Object(-1.2345).constructor.prototype !== Number.prototype){
176 $ERROR('#33: Object(-1.2345).constructor.prototype === Number.prototype. Actual: ' + (Object(-1.2345).constructor.prototype));
177 }