Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for ECMA402 PR 786 #3875

Merged
merged 2 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-initializenumberformat
description: >
Tests that the options maximumFractionDigits limit to the range 0 - 100.
info: |
InitializeNumberFormat ( numberFormat, locales, options )

25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined).

DefaultNumberOption ( value, minimum, maximum, fallback )

3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception.
---*/

let wontThrow = new Intl.NumberFormat(undefined, {maximumFractionDigits: 100});

assert.throws(RangeError, function () {
return new Intl.NumberFormat(undefined, {maximumFractionDigits: 101});
}, "Throws RangeError when maximumFractionDigits is more than 100.");
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-initializenumberformat
description: >
Tests that the options maximumFractionDigits limit to the range 0 - 100.
info: |
InitializeNumberFormat ( numberFormat, locales, options )
25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined).
DefaultNumberOption ( value, minimum, maximum, fallback )
3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception.
---*/

let wontThrow = new Intl.NumberFormat(undefined, {maximumFractionDigits: 0});

assert.throws(RangeError, function () {
return new Intl.NumberFormat(undefined, {maximumFractionDigits: -1});
}, "Throws RangeError when maximumFractionDigits is less than 0.");
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-initializenumberformat
description: >
Tests that the options minimumFractionDigits limit to the range 0 - 100.
info: |
InitializeNumberFormat ( numberFormat, locales, options )
25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined).
DefaultNumberOption ( value, minimum, maximum, fallback )
3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception.
---*/

let wontThrow = new Intl.NumberFormat(undefined, {minimumFractionDigits: 100});

assert.throws(RangeError, function () {
return new Intl.NumberFormat(undefined, {minimumFractionDigits: 101});
}, "Throws RangeError when minimumFractionDigits is more than 100.");
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright 2023 Google Inc. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-initializenumberformat
description: >
Tests that the options minimumFractionDigits limit to the range 0 - 100.
info: |
InitializeNumberFormat ( numberFormat, locales, options )
25.a.ii. Set mxfd to ? DefaultNumberOption(mxfd, 0, 100, undefined).
DefaultNumberOption ( value, minimum, maximum, fallback )
3. If value is NaN or less than minimum or greater than maximum, throw a RangeError exception.
---*/

let wontThrow = new Intl.NumberFormat(undefined, {minimumFractionDigits: 0});

assert.throws(RangeError, function () {
return new Intl.NumberFormat(undefined, {minimumFractionDigits: -1});
}, "Throws RangeError when minimumFractionDigits is less than 0.");