-
Notifications
You must be signed in to change notification settings - Fork 468
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for ECMA402 PR 786 (#3875)
tc39/ecma402#786 This ECMA402 PR 786 reached TC39 consensus in the July 2023 meeting
- Loading branch information
1 parent
6f146e6
commit 92a9eca
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
test/intl402/NumberFormat/throws-for-maximumFractionDigits-over-limit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); |
22 changes: 22 additions & 0 deletions
22
test/intl402/NumberFormat/throws-for-maximumFractionDigits-under-limit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); |
22 changes: 22 additions & 0 deletions
22
test/intl402/NumberFormat/throws-for-minimumFractionDigits-over-limit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); |
22 changes: 22 additions & 0 deletions
22
test/intl402/NumberFormat/throws-for-minimumFractionDigits-under-limit.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); |