summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/intl402/NumberFormat/prototype/format/engineering-scientific-de-DE.js
blob: 8c70c5e94ac3aed3b0f0f1701c83425dfaf04625 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Copyright 2019 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-intl.numberformat.prototype.format
description: Checks handling of the engineering and scientific notations.
locale: [de-DE]
features: [Intl.NumberFormat-unified]
---*/


const tests = [
  [
    0.000345,
    "345E-6",
    "3,45E-4",
  ],
  [
    0.345,
    "345E-3",
    "3,45E-1",
  ],
  [
    3.45,
    "3,45E0",
    "3,45E0",
  ],
  [
    34.5,
    "34,5E0",
    "3,45E1",
  ],
  [
    543,
    "543E0",
    "5,43E2",
  ],
  [
    5430,
    "5,43E3",
    "5,43E3",
  ],
  [
    543000,
    "543E3",
    "5,43E5",
  ],
  [
    543211.1,
    "543,211E3",
    "5,432E5",
  ],
  [
    -Infinity,
    "-∞",
    "-∞",
  ],
  [
    Infinity,
    "∞",
    "∞",
  ],
  [
    NaN,
    "NaN",
    "NaN",
  ],
];

for (const [number, engineering, scientific] of tests) {
  const nfEngineering = (new Intl.NumberFormat("de-DE", { notation: "engineering" }));
  assert.sameValue(nfEngineering.format(number), engineering);
  const nfScientific = (new Intl.NumberFormat("de-DE", { notation: "scientific" }));
  assert.sameValue(nfScientific.format(number), scientific);
}


reportCompare(0, 0);