Debian Codegraph @

js/src/tests/test262/built-ins/parseFloat/S15.1.2.3_A1_T2.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: Operator use ToString
6 esid: sec-parsefloat-string
7 description: Checking for number primitive
8 ---*/
9
10 //CHECK#1
11 if (parseFloat(-1.1) !== parseFloat("-1.1")) {
12 throw new Test262Error('#1: parseFloat(-1.1) === parseFloat("-1.1"). Actual: ' + (parseFloat(-1.1)));
13 }
14
15 //CHECK#2
16 if (parseFloat(Infinity) !== parseFloat("Infinity")) {
17 throw new Test262Error('#2: parseFloat(Infinity) === parseFloat("Infinity"). Actual: ' + (parseFloat(Infinity)));
18 }
19
20 //CHECK#3
21 if (String(parseFloat(NaN)) !== "NaN") {
22 throw new Test262Error('#3: String(parseFloat(NaN)) === "NaN". Actual: ' + (String(parseFloat(NaN))));
23 }
24
25 //CHECK#4
26 if (parseFloat(.01e+2) !== parseFloat(".01e+2")) {
27 throw new Test262Error('#4: parseFloat(.01e+2) === parseFloat(".01e+2"). Actual: ' + (parseFloat(.01e+2)));
28 }
29
30 //CHECK#5
31 if (parseFloat(-0) !== 0) {
32 throw new Test262Error('#5: parseFloat(-0) === 0. Actual: ' + (parseFloat(-0)));
33 } else {
34 if (1 / parseFloat(-0) !== Number.POSITIVE_INFINITY) {
35 throw new Test262Error('#5: parseFloat(-0) === +0. Actual: ' + (parseFloat(-0)));
36 }
37 }
38
39 reportCompare(0, 0);