Debian Codegraph @

js/src/tests/test262/built-ins/Number/S9.3.1_A5_T3.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 The MV of StrDecimalLiteral::: - StrUnsignedDecimalLiteral is the negative
7 of the MV of StrUnsignedDecimalLiteral. (the negative of this 0 is also 0)
8 es5id: 9.3.1_A5_T3
9 description: Compare Number('-' + 'any_number') with -Number('any_number')
10 ---*/
11
12 function dynaString(s1, s2) {
13 return String(s1) + String(s2);
14 }
15
16 assert.sameValue(Number(dynaString("-", "0")), -0, 'Number(dynaString("-", "0")) must return -Number("0")');
17
18 assert.sameValue(
19 Number(dynaString("-Infi", "nity")),
20 -Infinity
21 );
22
23 assert.sameValue(
24 Number(dynaString("-12345", "67890")),
25 -1234567890
26 );
27
28 assert.sameValue(
29 Number(dynaString("-1234.", "5678")),
30 -1234.5678
31 );
32
33 assert.sameValue(
34 Number(dynaString("-1234.", "5678e90")),
35 -1234.5678e90
36 );
37
38 assert.sameValue(
39 Number(dynaString("-1234.", "5678E90")),
40 -1234.5678E90
41 );
42
43 assert.sameValue(
44 Number(dynaString("-1234.", "5678e-90")),
45 -1234.5678e-90
46 );
47
48 assert.sameValue(
49 Number(dynaString("-1234.", "5678E-90")),
50 -1234.5678E-90
51 );
52
53 assert.sameValue(
54 Number(dynaString("-Infi", "nity")),
55 Number.NEGATIVE_INFINITY
56 );
57
58 reportCompare(0, 0);