fixup! Add tests for "Intl NumberFormat v3" proposal

This commit is contained in:
Mike Pennisi 2021-11-11 13:35:02 -05:00 committed by Rick Waldron
parent ef78452924
commit ae9440df36
10 changed files with 26 additions and 127 deletions

View File

@ -15,15 +15,17 @@ nf = new Intl.NumberFormat('de-DE', {});
assert.sameValue(nf.format(100), '100', '(omitted)');
assert.sameValue(nf.format(1000), '1.000', '(omitted)');
assert.sameValue(nf.format(10000), '10.000', '(omitted)');
assert.sameValue(nf.format(100000), '100.000', '(omitted)');
nf = new Intl.NumberFormat('de-DE', {useGrouping: true});
assert.sameValue(nf.format(100), '100', 'true');
assert.sameValue(nf.format(1000), '1.000', 'true');
assert.sameValue(nf.format(10000), '10.000', 'true');
assert.sameValue(nf.format(100000), '100.000', 'true');
nf = new Intl.NumberFormat('de-DE', {useGrouping: false});
assert.sameValue(nf.format(100), '100', 'false');
assert.sameValue(nf.format(1000), '1000', 'false');
assert.sameValue(nf.format(10000), '10000', 'false');
assert.sameValue(nf.format(100000), '100000', 'false');

View File

@ -5,25 +5,28 @@
esid: sec-intl.numberformat.prototype.format
description: |
Checks handling of the useGrouping option to the NumberFormat constructor.
locale: [ko-KR]
locale: [en-IN]
---*/
var nf;
nf = new Intl.NumberFormat('ko-KR', {});
nf = new Intl.NumberFormat('en-IN', {});
assert.sameValue(nf.format(100), '100', '(omitted)');
assert.sameValue(nf.format(1000), '1,000', '(omitted)');
assert.sameValue(nf.format(10000), '10,000', '(omitted)');
assert.sameValue(nf.format(100000), '1,00,000', '(omitted)');
nf = new Intl.NumberFormat('ko-KR', {useGrouping: true});
nf = new Intl.NumberFormat('en-IN', {useGrouping: true});
assert.sameValue(nf.format(100), '100', 'true');
assert.sameValue(nf.format(1000), '1,000', 'true');
assert.sameValue(nf.format(10000), '10,000', 'true');
assert.sameValue(nf.format(100000), '1,00,000', 'true');
nf = new Intl.NumberFormat('ko-KR', {useGrouping: false});
nf = new Intl.NumberFormat('en-IN', {useGrouping: false});
assert.sameValue(nf.format(100), '100', 'false');
assert.sameValue(nf.format(1000), '1000', 'false');
assert.sameValue(nf.format(10000), '10000', 'false');
assert.sameValue(nf.format(100000), '100000', 'false');

View File

@ -15,15 +15,18 @@ nf = new Intl.NumberFormat('en-US', {});
assert.sameValue(nf.format(100), '100', '(omitted)');
assert.sameValue(nf.format(1000), '1,000', '(omitted)');
assert.sameValue(nf.format(10000), '10,000', '(omitted)');
assert.sameValue(nf.format(100000), '100,000', '(omitted)');
nf = new Intl.NumberFormat('en-US', {useGrouping: true});
assert.sameValue(nf.format(100), '100', 'true');
assert.sameValue(nf.format(1000), '1,000', 'true');
assert.sameValue(nf.format(10000), '10,000', 'true');
assert.sameValue(nf.format(100000), '100,000', 'true');
nf = new Intl.NumberFormat('en-US', {useGrouping: false});
assert.sameValue(nf.format(100), '100', 'false');
assert.sameValue(nf.format(1000), '1000', 'false');
assert.sameValue(nf.format(10000), '10000', 'false');
assert.sameValue(nf.format(100000), '100000', 'false');

View File

@ -16,15 +16,18 @@ nf = new Intl.NumberFormat('de-DE', {useGrouping: 'always'});
assert.sameValue(nf.format(100), '100', '"always"');
assert.sameValue(nf.format(1000), '1.000', '"always"');
assert.sameValue(nf.format(10000), '10.000', '"always"');
assert.sameValue(nf.format(100000), '100.000', '"always"');
nf = new Intl.NumberFormat('de-DE', {useGrouping: 'min2'});
assert.sameValue(nf.format(100), '100', '"min2"');
assert.sameValue(nf.format(1000), '1000', '"min2"');
assert.sameValue(nf.format(10000), '10.000', '"min2"');
assert.sameValue(nf.format(100000), '100.000', '"min2"');
nf = new Intl.NumberFormat('de-DE', {notation: 'compact'});
assert.sameValue(nf.format(100), '100', 'notation: "compact"');
assert.sameValue(nf.format(1000), '1000', 'notation: "compact"');
assert.sameValue(nf.format(10000), '10.000', 'notation: "compact"');
assert.sameValue(nf.format(100000), '100.000', 'notation: "compact"');

View File

@ -5,26 +5,29 @@
esid: sec-intl.numberformat.prototype.format
description: |
Checks handling of the useGrouping option to the NumberFormat constructor.
locale: [ja-JP]
locale: [en-IN]
features: [Intl.NumberFormat-v3]
---*/
var nf;
nf = new Intl.NumberFormat('ja-JP', {useGrouping: 'always'});
nf = new Intl.NumberFormat('en-IN', {useGrouping: 'always'});
assert.sameValue(nf.format(100), '100', '"always"');
assert.sameValue(nf.format(1000), '1,000', '"always"');
assert.sameValue(nf.format(10000), '10,000', '"always"');
assert.sameValue(nf.format(100000), '1,00,000', '"always"');
nf = new Intl.NumberFormat('ja-JP', {useGrouping: 'min2'});
nf = new Intl.NumberFormat('en-IN', {useGrouping: 'min2'});
assert.sameValue(nf.format(100), '100', '"min2"');
assert.sameValue(nf.format(1000), '1000', '"min2"');
assert.sameValue(nf.format(10000), '10,000', '"min2"');
assert.sameValue(nf.format(100000), '100,000', '"min2"');
nf = new Intl.NumberFormat('ja-JP', {notation: 'compact'});
nf = new Intl.NumberFormat('en-IN', {notation: 'compact'});
assert.sameValue(nf.format(100), '100', 'notation: "compact"');
assert.sameValue(nf.format(1000), '1000', 'notation: "compact"');
assert.sameValue(nf.format(10000), '10,000', 'notation: "compact"');
assert.sameValue(nf.format(100000), '100,000', 'notation: "compact"');

View File

@ -16,15 +16,18 @@ nf = new Intl.NumberFormat('en-US', {useGrouping: 'always'});
assert.sameValue(nf.format(100), '100', '"always"');
assert.sameValue(nf.format(1000), '1,000', '"always"');
assert.sameValue(nf.format(10000), '10,000', '"always"');
assert.sameValue(nf.format(100000), '100,000', '"always"');
nf = new Intl.NumberFormat('en-US', {useGrouping: 'min2'});
assert.sameValue(nf.format(100), '100', '"min2"');
assert.sameValue(nf.format(1000), '1000', '"min2"');
assert.sameValue(nf.format(10000), '10,000', '"min2"');
assert.sameValue(nf.format(100000), '100,000', '"min2"');
nf = new Intl.NumberFormat('en-US', {notation: 'compact'});
assert.sameValue(nf.format(100), '100', 'notation: "compact"');
assert.sameValue(nf.format(1000), '1000', 'notation: "compact"');
assert.sameValue(nf.format(10000), '10,000', 'notation: "compact"');
assert.sameValue(nf.format(100000), '100,000', 'notation: "compact"');

View File

@ -1,30 +0,0 @@
// Copyright 2021 the V8 project authors. 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 useGrouping option to the NumberFormat constructor.
locale: [ko-KR]
features: [Intl.NumberFormat-v3]
---*/
var nf;
nf = new Intl.NumberFormat('ko-KR', {useGrouping: 'always'});
assert.sameValue(nf.format(100), '100', '"always"');
assert.sameValue(nf.format(1000), '1,000', '"always"');
assert.sameValue(nf.format(10000), '10,000', '"always"');
nf = new Intl.NumberFormat('ko-KR', {useGrouping: 'min2'});
assert.sameValue(nf.format(100), '100', '"min2"');
assert.sameValue(nf.format(1000), '1000', '"min2"');
assert.sameValue(nf.format(10000), '10,000', '"min2"');
nf = new Intl.NumberFormat('ko-KR', {notation: 'compact'});
assert.sameValue(nf.format(100), '100', 'notation: "compact"');
assert.sameValue(nf.format(1000), '1000', 'notation: "compact"');
assert.sameValue(nf.format(10000), '10,000', 'notation: "compact"');

View File

@ -1,30 +0,0 @@
// Copyright 2021 the V8 project authors. 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 useGrouping option to the NumberFormat constructor.
locale: [zh-TW]
features: [Intl.NumberFormat-v3]
---*/
var nf;
nf = new Intl.NumberFormat('zh-TW', {useGrouping: 'always'});
assert.sameValue(nf.format(100), '100', '"always"');
assert.sameValue(nf.format(1000), '1,000', '"always"');
assert.sameValue(nf.format(10000), '10,000', '"always"');
nf = new Intl.NumberFormat('zh-TW', {useGrouping: 'min2'});
assert.sameValue(nf.format(100), '100', '"min2"');
assert.sameValue(nf.format(1000), '1000', '"min2"');
assert.sameValue(nf.format(10000), '10,000', '"min2"');
nf = new Intl.NumberFormat('zh-TW', {notation: 'compact'});
assert.sameValue(nf.format(100), '100', 'notation: "compact"');
assert.sameValue(nf.format(1000), '1000', 'notation: "compact"');
assert.sameValue(nf.format(10000), '10,000', 'notation: "compact"');

View File

@ -1,29 +0,0 @@
// Copyright 2021 the V8 project authors. 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 useGrouping option to the NumberFormat constructor.
locale: [ja-JP]
---*/
var nf;
nf = new Intl.NumberFormat('ja-JP', {});
assert.sameValue(nf.format(100), '100', '(omitted)');
assert.sameValue(nf.format(1000), '1,000', '(omitted)');
assert.sameValue(nf.format(10000), '10,000', '(omitted)');
nf = new Intl.NumberFormat('ja-JP', {useGrouping: true});
assert.sameValue(nf.format(100), '100', 'true');
assert.sameValue(nf.format(1000), '1,000', 'true');
assert.sameValue(nf.format(10000), '10,000', 'true');
nf = new Intl.NumberFormat('ja-JP', {useGrouping: false});
assert.sameValue(nf.format(100), '100', 'false');
assert.sameValue(nf.format(1000), '1000', 'false');
assert.sameValue(nf.format(10000), '10000', 'false');

View File

@ -1,29 +0,0 @@
// Copyright 2021 the V8 project authors. 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 useGrouping option to the NumberFormat constructor.
locale: [zh-TW]
---*/
var nf;
nf = new Intl.NumberFormat('zh-TW', {});
assert.sameValue(nf.format(100), '100', '(omitted)');
assert.sameValue(nf.format(1000), '1,000', '(omitted)');
assert.sameValue(nf.format(10000), '10,000', '(omitted)');
nf = new Intl.NumberFormat('zh-TW', {useGrouping: true});
assert.sameValue(nf.format(100), '100', 'true');
assert.sameValue(nf.format(1000), '1,000', 'true');
assert.sameValue(nf.format(10000), '10,000', 'true');
nf = new Intl.NumberFormat('zh-TW', {useGrouping: false});
assert.sameValue(nf.format(100), '100', 'false');
assert.sameValue(nf.format(1000), '1000', 'false');
assert.sameValue(nf.format(10000), '10000', 'false');