mirror of
https://github.com/tc39/test262.git
synced 2025-07-31 01:44:54 +02:00
Add tests for "Intl NumberFormat v3" proposal
This patch is intended to cover only one aspect of the proposal for ECMA402: the "rounding mode" feature.
This commit is contained in:
parent
37e2c66420
commit
057c8acec7
@ -178,6 +178,10 @@ coalesce-expression
|
|||||||
# https://github.com/tc39-transfer/proposal-intl-displaynames
|
# https://github.com/tc39-transfer/proposal-intl-displaynames
|
||||||
Intl.DisplayNames
|
Intl.DisplayNames
|
||||||
|
|
||||||
|
# Intl.NumberFormat V3
|
||||||
|
# https://github.com/tc39/proposal-intl-numberformat-v3
|
||||||
|
Intl.NumberFormat-v3
|
||||||
|
|
||||||
# Promise.any
|
# Promise.any
|
||||||
# https://github.com/tc39/proposal-promise-any
|
# https://github.com/tc39/proposal-promise-any
|
||||||
Promise.any
|
Promise.any
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2021 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
/*---
|
||||||
|
esid: sec-initializenumberformat
|
||||||
|
description: >
|
||||||
|
Exception from accessing the "roundingMode" option for the NumberFormat
|
||||||
|
constructor should be propagated to the caller
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Intl.NumberFormat('en', {
|
||||||
|
get roundingMode() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
32
test/intl402/NumberFormat/prototype/format/format-rounding-mode-ceil.js
vendored
Normal file
32
test/intl402/NumberFormat/prototype/format/format-rounding-mode-ceil.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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: >
|
||||||
|
When roundingMode is "ceil", rounding tends toward positive infinity
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var locales = [
|
||||||
|
new Intl.NumberFormat().resolvedOptions().locale, 'ar', 'de', 'th', 'ja'
|
||||||
|
];
|
||||||
|
var numberingSystems = ['arab', 'latn', 'thai', 'hanidec'];
|
||||||
|
|
||||||
|
testNumberFormat(
|
||||||
|
locales,
|
||||||
|
numberingSystems,
|
||||||
|
{useGrouping: false, roundingMode: 'ceil', maximumSignificantDigits: 2},
|
||||||
|
{
|
||||||
|
'1.101': '1.2',
|
||||||
|
'1.15': '1.2',
|
||||||
|
'1.1999': '1.2',
|
||||||
|
'1.25': '1.3',
|
||||||
|
'0': '0',
|
||||||
|
'-0': '-0',
|
||||||
|
'-1.101': '-1.1',
|
||||||
|
'-1.15': '-1.1',
|
||||||
|
'-1.1999': '-1.1',
|
||||||
|
'-1.25': '-1.2'
|
||||||
|
}
|
||||||
|
);
|
32
test/intl402/NumberFormat/prototype/format/format-rounding-mode-expand.js
vendored
Normal file
32
test/intl402/NumberFormat/prototype/format/format-rounding-mode-expand.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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: >
|
||||||
|
When roundingMode is "expand", rounding tends away from zero
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var locales = [
|
||||||
|
new Intl.NumberFormat().resolvedOptions().locale, 'ar', 'de', 'th', 'ja'
|
||||||
|
];
|
||||||
|
var numberingSystems = ['arab', 'latn', 'thai', 'hanidec'];
|
||||||
|
|
||||||
|
testNumberFormat(
|
||||||
|
locales,
|
||||||
|
numberingSystems,
|
||||||
|
{useGrouping: false, roundingMode: 'expand', maximumSignificantDigits: 2},
|
||||||
|
{
|
||||||
|
'1.101': '1.2',
|
||||||
|
'1.15': '1.2',
|
||||||
|
'1.1999': '1.2',
|
||||||
|
'1.25': '1.3',
|
||||||
|
'0': '0',
|
||||||
|
'-0': '-0',
|
||||||
|
'-1.101': '-1.2',
|
||||||
|
'-1.15': '-1.2',
|
||||||
|
'-1.1999': '-1.2',
|
||||||
|
'-1.25': '-1.3'
|
||||||
|
}
|
||||||
|
);
|
32
test/intl402/NumberFormat/prototype/format/format-rounding-mode-floor.js
vendored
Normal file
32
test/intl402/NumberFormat/prototype/format/format-rounding-mode-floor.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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: >
|
||||||
|
When roundingMode is "floor", rounding tends toward negative infinity
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var locales = [
|
||||||
|
new Intl.NumberFormat().resolvedOptions().locale, 'ar', 'de', 'th', 'ja'
|
||||||
|
];
|
||||||
|
var numberingSystems = ['arab', 'latn', 'thai', 'hanidec'];
|
||||||
|
|
||||||
|
testNumberFormat(
|
||||||
|
locales,
|
||||||
|
numberingSystems,
|
||||||
|
{useGrouping: false, roundingMode: 'floor', maximumSignificantDigits: 2},
|
||||||
|
{
|
||||||
|
'1.101': '1.1',
|
||||||
|
'1.15': '1.1',
|
||||||
|
'1.1999': '1.1',
|
||||||
|
'1.25': '1.2',
|
||||||
|
'0': '0',
|
||||||
|
'-0': '-0',
|
||||||
|
'-1.101': '-1.2',
|
||||||
|
'-1.15': '-1.2',
|
||||||
|
'-1.1999': '-1.2',
|
||||||
|
'-1.25': '-1.3'
|
||||||
|
}
|
||||||
|
);
|
33
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-ceil.js
vendored
Normal file
33
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-ceil.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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: >
|
||||||
|
When roundingMode is "halfExpand", rounding tends toward the closest value
|
||||||
|
with ties tending toward positive infinity
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var locales = [
|
||||||
|
new Intl.NumberFormat().resolvedOptions().locale, 'ar', 'de', 'th', 'ja'
|
||||||
|
];
|
||||||
|
var numberingSystems = ['arab', 'latn', 'thai', 'hanidec'];
|
||||||
|
|
||||||
|
testNumberFormat(
|
||||||
|
locales,
|
||||||
|
numberingSystems,
|
||||||
|
{useGrouping: false, roundingMode: 'halfCeil', maximumSignificantDigits: 2},
|
||||||
|
{
|
||||||
|
'1.101': '1.1',
|
||||||
|
'1.15': '1.2',
|
||||||
|
'1.1999': '1.2',
|
||||||
|
'1.25': '1.3',
|
||||||
|
'0': '0',
|
||||||
|
'-0': '-0',
|
||||||
|
'-1.101': '-1.1',
|
||||||
|
'-1.15': '-1.1',
|
||||||
|
'-1.1999': '-1.2',
|
||||||
|
'-1.25': '-1.2'
|
||||||
|
}
|
||||||
|
);
|
34
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-even.js
vendored
Normal file
34
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-even.js
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
// 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: >
|
||||||
|
When roundingMode is "halfEven", rounding tends toward the closest value
|
||||||
|
with ties tending toward the value with even cardinality
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var locales = [
|
||||||
|
new Intl.NumberFormat().resolvedOptions().locale, 'ar', 'de', 'th', 'ja'
|
||||||
|
];
|
||||||
|
var numberingSystems = ['arab', 'latn', 'thai', 'hanidec'];
|
||||||
|
|
||||||
|
testNumberFormat(
|
||||||
|
locales,
|
||||||
|
numberingSystems,
|
||||||
|
{useGrouping: false, roundingMode: 'halfEven', maximumSignificantDigits: 2},
|
||||||
|
{
|
||||||
|
'1.101': '1.1',
|
||||||
|
'1.15': '1.2',
|
||||||
|
'1.1999': '1.2',
|
||||||
|
'1.25': '1.2',
|
||||||
|
'0': '0',
|
||||||
|
'-0': '-0',
|
||||||
|
'-1.101': '-1.1',
|
||||||
|
'-1.15': '-1.2',
|
||||||
|
'-1.1999': '-1.2',
|
||||||
|
'-1.25': '-1.2'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
33
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-expand.js
vendored
Normal file
33
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-expand.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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: >
|
||||||
|
When roundingMode is "halfExpand", rounding tends toward the closest value
|
||||||
|
with ties tending away from zero
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var locales = [
|
||||||
|
new Intl.NumberFormat().resolvedOptions().locale, 'ar', 'de', 'th', 'ja'
|
||||||
|
];
|
||||||
|
var numberingSystems = ['arab', 'latn', 'thai', 'hanidec'];
|
||||||
|
|
||||||
|
testNumberFormat(
|
||||||
|
locales,
|
||||||
|
numberingSystems,
|
||||||
|
{useGrouping: false, roundingMode: 'halfExpand', maximumSignificantDigits: 2},
|
||||||
|
{
|
||||||
|
'1.101': '1.1',
|
||||||
|
'1.15': '1.2',
|
||||||
|
'1.1999': '1.2',
|
||||||
|
'1.25': '1.3',
|
||||||
|
'0': '0',
|
||||||
|
'-0': '-0',
|
||||||
|
'-1.101': '-1.1',
|
||||||
|
'-1.15': '-1.2',
|
||||||
|
'-1.1999': '-1.2',
|
||||||
|
'-1.25': '-1.3'
|
||||||
|
}
|
||||||
|
);
|
33
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-floor.js
vendored
Normal file
33
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-floor.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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: >
|
||||||
|
When roundingMode is "halfFloor", rounding tends toward the closest value
|
||||||
|
with ties tending toward negative infinity
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var locales = [
|
||||||
|
new Intl.NumberFormat().resolvedOptions().locale, 'ar', 'de', 'th', 'ja'
|
||||||
|
];
|
||||||
|
var numberingSystems = ['arab', 'latn', 'thai', 'hanidec'];
|
||||||
|
|
||||||
|
testNumberFormat(
|
||||||
|
locales,
|
||||||
|
numberingSystems,
|
||||||
|
{useGrouping: false, roundingMode: 'halfFloor', maximumSignificantDigits: 2},
|
||||||
|
{
|
||||||
|
'1.101': '1.1',
|
||||||
|
'1.15': '1.1',
|
||||||
|
'1.1999': '1.2',
|
||||||
|
'1.25': '1.2',
|
||||||
|
'0': '0',
|
||||||
|
'-0': '-0',
|
||||||
|
'-1.101': '-1.1',
|
||||||
|
'-1.15': '-1.2',
|
||||||
|
'-1.1999': '-1.2',
|
||||||
|
'-1.25': '-1.3'
|
||||||
|
}
|
||||||
|
);
|
33
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-trunc.js
vendored
Normal file
33
test/intl402/NumberFormat/prototype/format/format-rounding-mode-half-trunc.js
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
// 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: >
|
||||||
|
When roundingMode is "halfTrunc", rounding tends toward the closest value
|
||||||
|
with ties tending toward zero
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var locales = [
|
||||||
|
new Intl.NumberFormat().resolvedOptions().locale, 'ar', 'de', 'th', 'ja'
|
||||||
|
];
|
||||||
|
var numberingSystems = ['arab', 'latn', 'thai', 'hanidec'];
|
||||||
|
|
||||||
|
testNumberFormat(
|
||||||
|
locales,
|
||||||
|
numberingSystems,
|
||||||
|
{useGrouping: false, roundingMode: 'halfTrunc', maximumSignificantDigits: 2},
|
||||||
|
{
|
||||||
|
'1.101': '1.1',
|
||||||
|
'1.15': '1.1',
|
||||||
|
'1.1999': '1.2',
|
||||||
|
'1.25': '1.2',
|
||||||
|
'0': '0',
|
||||||
|
'-0': '-0',
|
||||||
|
'-1.101': '-1.1',
|
||||||
|
'-1.15': '-1.1',
|
||||||
|
'-1.1999': '-1.2',
|
||||||
|
'-1.25': '-1.2'
|
||||||
|
}
|
||||||
|
);
|
32
test/intl402/NumberFormat/prototype/format/format-rounding-mode-trunc.js
vendored
Normal file
32
test/intl402/NumberFormat/prototype/format/format-rounding-mode-trunc.js
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
// 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: >
|
||||||
|
When roundingMode is "trunc", rounding tends toward zero
|
||||||
|
features: [Intl.NumberFormat-v3]
|
||||||
|
includes: [testIntl.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var locales = [
|
||||||
|
new Intl.NumberFormat().resolvedOptions().locale, 'ar', 'de', 'th', 'ja'
|
||||||
|
];
|
||||||
|
var numberingSystems = ['arab', 'latn', 'thai', 'hanidec'];
|
||||||
|
|
||||||
|
testNumberFormat(
|
||||||
|
locales,
|
||||||
|
numberingSystems,
|
||||||
|
{useGrouping: false, roundingMode: 'trunc', maximumSignificantDigits: 2},
|
||||||
|
{
|
||||||
|
'1.101': '1.1',
|
||||||
|
'1.15': '1.1',
|
||||||
|
'1.1999': '1.1',
|
||||||
|
'1.25': '1.2',
|
||||||
|
'0': '0',
|
||||||
|
'-0': '-0',
|
||||||
|
'-1.101': '-1.1',
|
||||||
|
'-1.15': '-1.1',
|
||||||
|
'-1.1999': '-1.1',
|
||||||
|
'-1.25': '-1.2'
|
||||||
|
}
|
||||||
|
);
|
Loading…
x
Reference in New Issue
Block a user