Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Number/S9.3.1_A2.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: "The MV of StringNumericLiteral ::: StrWhiteSpace is 0"
6 es5id: 9.3.1_A2
7 description: >
8 Strings with various WhiteSpaces convert to Number by explicit
9 transformation
10 ---*/
11
12 // CHECK#1
13 if (Number("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000") !== 0) {
14 $ERROR('#1.1: Number("\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") === 0. Actual: ' + (Number("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000")));
15 } else {
16 if (1 / Number("\u0009\u000C\u0020\u00A0\u000B\u000A\u000D\u2028\u2029\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000") !== Number.POSITIVE_INFINITY) {
17 $ERROR('#1.2: Number("\\u0009\\u000C\\u0020\\u00A0\\u000B\\u000A\\u000D\\u2028\\u2029\\u1680\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200A\\u202F\\u205F\\u3000") === +0. Actual: -0');
18 }
19 }
20
21 // CHECK#2
22 if (Number(" ") !== 0) {
23 $ERROR('#2.1: Number(" ") === 0. Actual: ' + (Number(" ")));
24 } else {
25 if (1 / Number(" ") !== Number.POSITIVE_INFINITY) {
26 $ERROR('#2.2: Number(" ") === +0. Actual: -0');
27 }
28 }
29
30 // CHECK#3
31 if (Number("\t") !== 0) {
32 $ERROR('#3.1: Number("\\t") === 0. Actual: ' + (Number("\t")));
33 } else {
34 if (1 / Number("\t") !== Number.POSITIVE_INFINITY) {
35 $ERROR('#3.2: Number("\\t") === +0. Actual: -0');
36 }
37 }
38
39 // CHECK#4
40 if (Number("\r") !== 0) {
41 $ERROR('#4.1: Number("\\r") === 0. Actual: ' + (Number("\r")));
42 } else {
43 if (1 / Number("\r") !== Number.POSITIVE_INFINITY) {
44 $ERROR('#4.2: Number("\\r") === +0. Actual: -0');
45 }
46 }
47
48 // CHECK#5
49 if (Number("\n") !== 0) {
50 $ERROR('#5.1: Number("\\n") === 0. Actual: ' + (Number("\n")));
51 } else {
52 if (1 / Number("\n") !== Number.POSITIVE_INFINITY) {
53 $ERROR('#5.2: Number("\\n") === +0. Actual: -0');
54 }
55 }
56
57 // CHECK#6
58 if (Number("\f") !== 0) {
59 $ERROR('#6.1: Number("\\f") === 0. Actual: ' + (Number("\f")));
60 } else {
61 if (1 / Number("\f") !== Number.POSITIVE_INFINITY) {
62 $ERROR('#6.2: Number("\\f") === +0. Actual: -0');
63 }
64 }
65
66 // CHECK#7
67 if (Number("\u0009") !== 0) {
68 $ERROR('#7.1: Number("\\u0009") === 0. Actual: ' + (Number("\u0009")));
69 } else {
70 if (1 / Number("\u0009") !== Number.POSITIVE_INFINITY) {
71 $ERROR('#7.2: Number("\\u0009") === +0. Actual: -0');
72 }
73 }
74
75 // CHECK#8
76 if (Number("\u000A") !== 0) {
77 $ERROR('#8.1: Number("\\u000A") === 0. Actual: ' + (Number("\u000A")));
78 } else {
79 if (1 / Number("\u000A") !== Number.POSITIVE_INFINITY) {
80 $ERROR('#8.2: Number("\\u000A") === +0. Actual: -0');
81 }
82 }
83
84 // CHECK#9
85 if (Number("\u000B") !== 0) {
86 $ERROR('#9.1: Number("\\u000B") === 0. Actual: ' + (Number("\u000B")));
87 } else {
88 if (1 / Number("\u000B") !== Number.POSITIVE_INFINITY) {
89 $ERROR('#9.1.2: Number("\\u000B") === +0. Actual: -0');
90 }
91 }
92
93 // CHECK#10
94 if (Number("\u000C") !== 0) {
95 $ERROR('#10.1: Number("\\u000C") === 0. Actual: ' + (Number("\u000C")));
96 } else {
97 if (1 / Number("\u000C") !== Number.POSITIVE_INFINITY) {
98 $ERROR('#10.2: Number("\\u000C") === +0. Actual: -0');
99 }
100 }
101
102 // CHECK#11
103 if (Number("\u000D") !== 0) {
104 $ERROR('#11.1: Number("\\u000D") === 0. Actual: ' + (Number("\u000D")));
105 } else {
106 if (1 / Number("\u000D") !== Number.POSITIVE_INFINITY) {
107 $ERROR('#11.2: Number("\\u000D") === +0. Actual: -0');
108 }
109 }
110
111 // CHECK#12
112 if (Number("\u00A0") !== 0) {
113 $ERROR('#12.1: Number("\\u00A0") === 0. Actual: ' + (Number("\u00A0")));
114 } else {
115 if (1 / Number("\u00A0") !== Number.POSITIVE_INFINITY) {
116 $ERROR('#12.2: Number("\\u00A0") === +0. Actual: -0');
117 }
118 }
119
120 // CHECK#13
121 if (Number("\u0020") !== 0) {
122 $ERROR('#13.1: Number("\\u0020") === 0. Actual: ' + (Number("\u0020")));
123 } else {
124 if (1 / Number("\u0020") !== Number.POSITIVE_INFINITY) {
125 $ERROR('#13.2: Number("\\u0020") === +0. Actual: -0');
126 }
127 }
128
129 // CHECK#14
130 if (Number("\u2028") !== 0) {
131 $ERROR('#14.1: Number("\\u2028") === 0. Actual: ' + (Number("\u2028")));
132 } else {
133 if (1 / Number("\u2028") !== Number.POSITIVE_INFINITY) {
134 $ERROR('#14.2: Number("\\u2028") === +0. Actual: -0');
135 }
136 }
137
138 // CHECK#15
139 if (Number("\u2029") !== 0) {
140 $ERROR('#15.1: Number("\\u2029") === 0. Actual: ' + (Number("\u2029")));
141 } else {
142 if (1 / Number("\u2029") !== Number.POSITIVE_INFINITY) {
143 $ERROR('#15.2: Number("\\u2029") === +0. Actual: -0');
144 }
145 }
146
147 // CHECK#16
148 if (Number("\u1680") !== 0) {
149 $ERROR('#16.1: Number("\\u1680") === 0. Actual: ' + (Number("\u1680")));
150 } else {
151 if (1 / Number("\u1680") !== Number.POSITIVE_INFINITY) {
152 $ERROR('#16.2: Number("\\u1680") === +0. Actual: -0');
153 }
154 }
155
156 // CHECK#17
157 if (Number("\u2000") !== 0) {
158 $ERROR('#17.1: Number("\\u2000") === 0. Actual: ' + (Number("\u2000")));
159 } else {
160 if (1 / Number("\u2000") !== Number.POSITIVE_INFINITY) {
161 $ERROR('#17.2: Number("\\u2000") === +0. Actual: -0');
162 }
163 }
164
165 // CHECK#18
166 if (Number("\u2001") !== 0) {
167 $ERROR('#18.1: Number("\\u2001") === 0. Actual: ' + (Number("\u2001")));
168 } else {
169 if (1 / Number("\u2001") !== Number.POSITIVE_INFINITY) {
170 $ERROR('#18.2: Number("\\u2001") === +0. Actual: -0');
171 }
172 }
173
174 // CHECK#19
175 if (Number("\u2002") !== 0) {
176 $ERROR('#19.1: Number("\\u2002") === 0. Actual: ' + (Number("\u2002")));
177 } else {
178 if (1 / Number("\u2002") !== Number.POSITIVE_INFINITY) {
179 $ERROR('#19.2: Number("\\u2002") === +0. Actual: -0');
180 }
181 }
182
183 // CHECK#20
184 if (Number("\u2003") !== 0) {
185 $ERROR('#20.1: Number("\\u2003") === 0. Actual: ' + (Number("\u2003")));
186 } else {
187 if (1 / Number("\u2003") !== Number.POSITIVE_INFINITY) {
188 $ERROR('#20.2: Number("\\u2003") === +0. Actual: -0');
189 }
190 }
191
192 // CHECK#21
193 if (Number("\u2004") !== 0) {
194 $ERROR('#21.1: Number("\\u2004") === 0. Actual: ' + (Number("\u2004")));
195 } else {
196 if (1 / Number("\u2004") !== Number.POSITIVE_INFINITY) {
197 $ERROR('#21.2: Number("\\u2004") === +0. Actual: -0');
198 }
199 }
200
201 // CHECK#22
202 if (Number("\u2005") !== 0) {
203 $ERROR('#22.1: Number("\\u2005") === 0. Actual: ' + (Number("\u2005")));
204 } else {
205 if (1 / Number("\u2005") !== Number.POSITIVE_INFINITY) {
206 $ERROR('#22.2: Number("\\u2005") === +0. Actual: -0');
207 }
208 }
209
210 // CHECK#23
211 if (Number("\u2006") !== 0) {
212 $ERROR('#23.1: Number("\\u2006") === 0. Actual: ' + (Number("\u2006")));
213 } else {
214 if (1 / Number("\u2006") !== Number.POSITIVE_INFINITY) {
215 $ERROR('#23.2: Number("\\u2006") === +0. Actual: -0');
216 }
217 }
218
219 // CHECK#24
220 if (Number("\u2007") !== 0) {
221 $ERROR('#24.1: Number("\\u2007") === 0. Actual: ' + (Number("\u2007")));
222 } else {
223 if (1 / Number("\u2007") !== Number.POSITIVE_INFINITY) {
224 $ERROR('#24.2: Number("\\u2007") === +0. Actual: -0');
225 }
226 }
227
228 // CHECK#25
229 if (Number("\u2008") !== 0) {
230 $ERROR('#25.1: Number("\\u2008") === 0. Actual: ' + (Number("\u2008")));
231 } else {
232 if (1 / Number("\u2008") !== Number.POSITIVE_INFINITY) {
233 $ERROR('#25.2: Number("\\u2008") === +0. Actual: -0');
234 }
235 }
236
237 // CHECK#26
238 if (Number("\u2009") !== 0) {
239 $ERROR('#26.1: Number("\\u2009") === 0. Actual: ' + (Number("\u2009")));
240 } else {
241 if (1 / Number("\u2009") !== Number.POSITIVE_INFINITY) {
242 $ERROR('#26.2: Number("\\u2009") === +0. Actual: -0');
243 }
244 }
245
246 // CHECK#27
247 if (Number("\u200A") !== 0) {
248 $ERROR('#27.1: Number("\\u200A") === 0. Actual: ' + (Number("\u200A")));
249 } else {
250 if (1 / Number("\u200A") !== Number.POSITIVE_INFINITY) {
251 $ERROR('#27.2: Number("\\u200A") === +0. Actual: -0');
252 }
253 }
254
255 // CHECK#28
256 if (Number("\u202F") !== 0) {
257 $ERROR('#28.1: Number("\\u202F") === 0. Actual: ' + (Number("\u202F")));
258 } else {
259 if (1 / Number("\u202F") !== Number.POSITIVE_INFINITY) {
260 $ERROR('#28.2: Number("\\u202F") === +0. Actual: -0');
261 }
262 }
263
264 // CHECK#29
265 if (Number("\u205F") !== 0) {
266 $ERROR('#29.1: Number("\\u205F") === 0. Actual: ' + (Number("\u205F")));
267 } else {
268 if (1 / Number("\u205F") !== Number.POSITIVE_INFINITY) {
269 $ERROR('#29.2: Number("\\u205F") === +0. Actual: -0');
270 }
271 }
272
273 // CHECK#30
274 if (Number("\u3000") !== 0) {
275 $ERROR('#30.1: Number("\\u3000") === 0. Actual: ' + (Number("\u3000")));
276 } else {
277 if (1 / Number("\u3000") !== Number.POSITIVE_INFINITY) {
278 $ERROR('#30.2: Number("\\u3000") === +0. Actual: -0');
279 }
280 }