| 1 |
// Copyright 2021 the V8 project authors. All rights reserved. |
| 2 |
// Copyright 2022 Apple Inc. All rights reserved. |
| 3 |
// Copyright 2022 Igalia, S.L. All rights reserved. |
| 4 |
// This code is governed by the BSD license found in the LICENSE file. |
| 5 |
|
| 6 |
/*--- |
| 7 |
esid: sec-initializenumberformat |
| 8 |
description: Tests that the option useGrouping is processed correctly. |
| 9 |
info: | |
| 10 |
The "Intl.NumberFormat v3" proposal contradicts the behavior required by the |
| 11 |
latest revision of ECMA402. |
| 12 |
features: [Intl.NumberFormat-v3] |
| 13 |
---*/ |
| 14 |
|
| 15 |
function render(options) { |
| 16 |
var nf = new Intl.NumberFormat(undefined, options); |
| 17 |
return nf.resolvedOptions().useGrouping; |
| 18 |
} |
| 19 |
|
| 20 |
assert.sameValue(render({}), 'auto', '(omitted)'); |
| 21 |
assert.sameValue(render({useGrouping: undefined}), 'auto', 'undefined'); |
| 22 |
assert.sameValue(render({useGrouping: 'auto'}), 'auto', '"auto"'); |
| 23 |
assert.sameValue(render({useGrouping: true}), 'always', 'true'); |
| 24 |
assert.sameValue(render({useGrouping: 'always'}), 'always', '"always"'); |
| 25 |
assert.sameValue(render({useGrouping: false}), false, 'false'); |
| 26 |
assert.sameValue(render({useGrouping: null}), false, 'null'); |
| 27 |
assert.sameValue(render({useGrouping: 'min2'}), 'min2', '"min2"'); |
| 28 |
|
| 29 |
assert.sameValue(render({notation: 'compact'}), 'min2', 'compact, (omitted)'); |
| 30 |
assert.sameValue(render({notation: 'compact', useGrouping: undefined}), 'min2', 'compact, undefined'); |
| 31 |
assert.sameValue(render({notation: 'compact', useGrouping: 'auto'}), 'auto', 'compact, "auto"'); |
| 32 |
assert.sameValue(render({notation: 'compact', useGrouping: true}), 'always', 'compact, true'); |
| 33 |
assert.sameValue(render({notation: 'compact', useGrouping: 'always'}), 'always', 'compact, "always"'); |
| 34 |
assert.sameValue(render({notation: 'compact', useGrouping: false}), false, 'compact, false'); |
| 35 |
assert.sameValue(render({notation: 'compact', useGrouping: null}), false, 'compact, null'); |
| 36 |
assert.sameValue(render({notation: 'compact', useGrouping: 'min2'}), 'min2', 'compact, "min2"'); |
| 37 |
|
| 38 |
assert.sameValue(render({useGrouping: 'false'}), 'auto', 'use fallback value'); |
| 39 |
assert.sameValue(render({useGrouping: 'true'}), 'auto', 'use fallback value'); |
| 40 |
|
| 41 |
reportCompare(0, 0); |