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

verify that non-integral values throw #3898

Closed
wants to merge 2 commits into from
Closed
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
23 changes: 23 additions & 0 deletions test/intl402/DurationFormat/prototype/format/throws-on-nan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2023 Igalia S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.DurationFormat.prototype.format
description: Check that format throws on non-integral values
info: |
1.1.2 ToIntegerWithoutRounding ( argument )
1. Let number be ? ToNumber(argument).
2. If IsIntegralNumber(number) is false, throw a RangeError exception.
3. Return ℝ(number).
features: [Intl.DurationFormat]
---*/

var invalidValues = [NaN, Infinity, -Infinity];

var format = new Intl.DateTimeFormat();

invalidValues.forEach(function (value) {
assert.throws(RangeError, function() {
var result = format.format(value);
}, "Invalid value " + value + " was not rejected.");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2023 Igalia S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-Intl.DurationFormat.prototype.format
description: Check that format throws on non-integral values
info: |
1.1.2 ToIntegerWithoutRounding ( argument )
1. Let number be ? ToNumber(argument).
2. If IsIntegralNumber(number) is false, throw a RangeError exception.
3. Return ℝ(number).
features: [Intl.DurationFormat]
---*/

var invalidValues = [NaN, Infinity, -Infinity, 0.137, 1.37, -398.2];

var format = new Intl.DateTimeFormat();

invalidValues.forEach(function (value) {
assert.throws(RangeError, function() {
var result = format.format(value);
}, "Invalid value " + value + " was not rejected.");
});