Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Object/S9.9_A4.js

raw
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 Number: create a new Number object
7 whose [[value]] property is set to the value of the number
8 es5id: 9.9_A4
9 description: Converting from various numbers to Object
10 ---*/
11
12 // CHECK#1
13 if (Object(0).valueOf() !== 0) {
14 $ERROR('#1: Object(0).valueOf() === 0. Actual: ' + (Object(0).valueOf()));
15 }
16
17 // CHECK#2
18 if (typeof Object(0) !== "object") {
19 $ERROR('#2: typeof Object(0) === "object". Actual: ' + (typeof Object(0)));
20 }
21
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 }
26
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 }
33
34 // CHECK#5
35 if (typeof Object(-0) !== "object") {
36 $ERROR('#5: typeof Object(-0) === "object". Actual: ' + (typeof Object(-0)));
37 }
38
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 }
43
44 // CHECK#7
45 if (Object(1).valueOf() !== 1) {
46 $ERROR('#7: Object(1).valueOf() === 1. Actual: ' + (Object(1).valueOf()));
47 }
48
49 // CHECK#8
50 if (typeof Object(1) !== "object") {
51 $ERROR('#8: typeof Object(1) === "object". Actual: ' + (typeof Object(1)));
52 }
53
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 }
58
59 // CHECK#10
60 if (Object(-1).valueOf() !== -1) {
61 $ERROR('#10: Object(-1).valueOf() === -1. Actual: ' + (Object(-1).valueOf()));
62 }
63
64 // CHECK#11
65 if (typeof Object(-1) !== "object") {
66 $ERROR('#11: typeof Object(-1) === "object". Actual: ' + (typeof Object(-1)));
67 }
68
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 }
73
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 }
78
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 }
83
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 }
88
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 }
93
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 }
98
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 }
103
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 }
108
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 }
113
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 }
118
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 }
123
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 }
128
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 }
133
134 // CHECK#25
135 assert.sameValue(Object(NaN).valueOf(), NaN, "Object(NaN).valueOf()");
136
137 // CHECK#26
138 if (typeof Object(Number.NaN) !== "object") {
139 $ERROR('#26: typeof Object(Number.NaN) === "object". Actual: ' + (typeof Object(Number.NaN)));
140 }
141
142 // CHECK#27
143 if (Object(Number.NaN).constructor.prototype !== Number.prototype) {
144 $ERROR('#27: Object(Number.NaN).constructor.prototype === Number.prototype. Actual: ' + (Object(Number.NaN).constructor.prototype));
145 }
146
147 // CHECK#28
148 if (Object(1.2345).valueOf() !== 1.2345) {
149 $ERROR('#28: Object(1.2345).valueOf() === 1.2345. Actual: ' + (Object(1.2345).valueOf()));
150 }
151
152 // CHECK#29
153 if (typeof Object(1.2345) !== "object") {
154 $ERROR('#29: typeof Object(1.2345) === "object". Actual: ' + (typeof Object(1.2345)));
155 }
156
157 // CHECK#30
158 if (Object(1.2345).constructor.prototype !== Number.prototype) {
159 $ERROR('#30: Object(1.2345).constructor.prototype === Number.prototype. Actual: ' + (Object(1.2345).constructor.prototype));
160 }
161
162 // CHECK#31
163 if (Object(-1.2345).valueOf() !== -1.2345) {
164 $ERROR('#31: Object(-1.2345).valueOf() === -1.2345. Actual: ' + (Object(-1.2345).valueOf()));
165 }
166
167 // CHECK#32
168 if (typeof Object(-1.2345) !== "object") {
169 $ERROR('#32: typeof Object(-1.2345) === "object". Actual: ' + (typeof Object(-1.2345)));
170 }
171
172 // CHECK#33
173 if (Object(-1.2345).constructor.prototype !== Number.prototype) {
174 $ERROR('#33: Object(-1.2345).constructor.prototype === Number.prototype. Actual: ' + (Object(-1.2345).constructor.prototype));
175 }