-
Notifications
You must be signed in to change notification settings - Fork 481
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
Test normative changes in ECMA-402 #715 #3679
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// Copyright 2019 Google Inc. All rights reserved. | ||
// Copyright (C) 2022 Igalia S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
|
@@ -7,7 +8,8 @@ description: > | |
Checks error cases for the options argument to the DateTimeFormat constructor. | ||
info: | | ||
InitializeDateTimeFormat ( dateTimeFormat, locales, options ) | ||
23. Let _opt_.[[FractionalSecondDigits]] be ? GetNumberOption(_options_, `"fractionalSecondDigits"`, 0, 3, 0). | ||
1. Let _value_ be ? GetNumberOption(_options_, *"fractionalSecondDigits"*, 0, 9, *undefined*). | ||
1. If _value_ is one of *"0"*, *"4"*, *"5"*, *"6"*, *"7"*, *"8"*, *"9"*, set _value_ to *undefined*. | ||
|
||
... | ||
features: [Intl.DateTimeFormat-fractionalSecondDigits] | ||
|
@@ -21,11 +23,8 @@ const invalidOptions = [ | |
"full", | ||
"numeric", | ||
-1, | ||
4, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would recommend replacing the removed lines with new values that are still invalid. E.g. |
||
"4", | ||
"-1", | ||
-0.00001, | ||
3.000001, | ||
-0.00001 | ||
]; | ||
for (const fractionalSecondDigits of invalidOptions) { | ||
assert.throws(RangeError, function() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// Copyright 2020 Google Inc, Igalia S.L. All rights reserved. | ||
// Copyright (C) 2022 Igalia S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
|
@@ -27,36 +28,32 @@ const d1 = new Date(2019, 7, 10, 1, 2, 3, 234); | |
const d2 = new Date(2019, 7, 10, 1, 2, 3, 567); | ||
const d3 = new Date(2019, 7, 10, 1, 2, 13, 987); | ||
|
||
assert.throws(RangeError, () => { | ||
new Intl.DateTimeFormat( | ||
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 0}); | ||
}, "fractionalSecondDigits 0 should throw RangeError for out of range"); | ||
Comment on lines
-30
to
-33
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd recommend keeping these out-of-range tests but changing the values from 0 and 4, to -1 and 10. |
||
[undefined, 0, 4, 5, 6, 7, 8, 9, "0", "4", "5", "6", "7", "8", "9"].forEach((fractionalSecondDigits)=>{ | ||
|
||
assert.throws(RangeError, () => { | ||
new Intl.DateTimeFormat( | ||
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 4}); | ||
}, "fractionalSecondDigits 4 should throw RangeError for out of range"); | ||
let dtf = new Intl.DateTimeFormat( | ||
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits }); | ||
|
||
let dtf = new Intl.DateTimeFormat( | ||
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: undefined}); | ||
compare(dtf.formatRangeToParts(d1, d2), [ | ||
{ type: "minute", value: "02", source: "shared" }, | ||
{ type: "literal", value: ":", source: "shared" }, | ||
{ type: "second", value: "03", source: "shared" } | ||
]); | ||
|
||
compare(dtf.formatRangeToParts(d1, d2), [ | ||
{ type: "minute", value: "02", source: "shared" }, | ||
{ type: "literal", value: ":", source: "shared" }, | ||
{ type: "second", value: "03", source: "shared" } | ||
]); | ||
compare(dtf.formatRangeToParts(d1, d3), [ | ||
{ type: "minute", value: "02", source: "startRange" }, | ||
{ type: "literal", value: ":", source: "startRange" }, | ||
{ type: "second", value: "03", source: "startRange" }, | ||
{ type: "literal", value: " \u2013 ", source: "shared" }, | ||
{ type: "minute", value: "02", source: "endRange" }, | ||
{ type: "literal", value: ":", source: "endRange" }, | ||
{ type: "second", value: "13", source: "endRange" } | ||
]); | ||
|
||
compare(dtf.formatRangeToParts(d1, d3), [ | ||
{ type: "minute", value: "02", source: "startRange" }, | ||
{ type: "literal", value: ":", source: "startRange" }, | ||
{ type: "second", value: "03", source: "startRange" }, | ||
{ type: "literal", value: " \u2013 ", source: "shared" }, | ||
{ type: "minute", value: "02", source: "endRange" }, | ||
{ type: "literal", value: ":", source: "endRange" }, | ||
{ type: "second", value: "13", source: "endRange" } | ||
]); | ||
}); | ||
|
||
dtf = new Intl.DateTimeFormat( | ||
|
||
|
||
let dtf = new Intl.DateTimeFormat( | ||
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 1}); | ||
|
||
compare(dtf.formatRangeToParts(d1, d2), [ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// Copyright 2019 Google Inc. All rights reserved. | ||
// Copyright (C) 2022 Igalia S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
|
@@ -31,15 +32,6 @@ function assertParts(parts, minute, second, fractionalSecond, message) { | |
} | ||
} | ||
|
||
assert.throws(RangeError, () => { | ||
new Intl.DateTimeFormat( | ||
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 0}); | ||
}, "fractionalSecondDigits 0 should throw RangeError for out of range"); | ||
|
||
assert.throws(RangeError, () => { | ||
new Intl.DateTimeFormat( | ||
'en', { minute: "numeric", second: "numeric", fractionalSecondDigits: 4}); | ||
}, "fractionalSecondDigits 4 should throw RangeError for out of range"); | ||
Comment on lines
-34
to
-42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, I'd recommend testing -1 and 10. |
||
|
||
let dtf = new Intl.DateTimeFormat( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should this one test the same values that you're looping over in the other test files? (undefined, 0, "0", etc) |
||
'en', { minute: "numeric", second: "numeric"}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(See my comment in the ECMA-402 PR about this line of the spec text)