Skip to content

Add tests to Intl.DateTimeFormat and Intl.RelativeTimeFormat for various numbering systems#4276

Merged
ptomato merged 2 commits intotc39:mainfrom
ben-allen:pr-919-datetimeformat-relativetimeformat-numbering-system
Oct 30, 2024
Merged

Add tests to Intl.DateTimeFormat and Intl.RelativeTimeFormat for various numbering systems#4276
ptomato merged 2 commits intotc39:mainfrom
ben-allen:pr-919-datetimeformat-relativetimeformat-numbering-system

Conversation

@ben-allen
Copy link
Contributor

Previously there was a spec bug: the Intl.NumberFormats created within Intl.DateTimeFormat.prototype.format and Intl.RelativeTimeFormat constructor were not passed the numbering system to be used.

See tc39/ecma402#919
Fix #4260

@ben-allen ben-allen requested a review from a team as a code owner October 22, 2024 06:00
@ben-allen ben-allen force-pushed the pr-919-datetimeformat-relativetimeformat-numbering-system branch from 3e9b0ea to 1fb5f92 Compare October 29, 2024 18:36
@ben-allen
Copy link
Contributor Author

Updated tests to be slightly less "golden string" -- instead of checking for exact match between formatted string and expected string, now expected is a substring without whitespace, and test is for whether formatted string includes the expected substring.

Copy link
Contributor

@ptomato ptomato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Your effort in using fewer "golden strings" is appreciated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this, but I think you need to include en-US-u-nu-arab and the others in this list as well.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

Comment on lines 15 to 27
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unlike the previous test, you might actually be able to make this one even less "golden", with something like

const expected = new Intl.NumberFormat(locale).format(seconds);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated!

@ptomato ptomato force-pushed the pr-919-datetimeformat-relativetimeformat-numbering-system branch from d9a4950 to 0ade7e3 Compare October 30, 2024 21:58
@ptomato ptomato merged commit 455cfa5 into tc39:main Oct 30, 2024
@iamstolis
Copy link
Contributor

I find it problematic/incorrect that the expectedTwoDigit result of en-US-u-nu-hanidec ends with AM. Not only this is inconsistent with other expected results (that do not contain this suffix despite the actual format contains it most likely) but the space before AM in the expected string is U+0020 Space while ICU/CLDR suggests U+202F Narrow No-Break Space. While the suggestion of U+202F is a bit controversial and some engines decided not to follow it (see, for example, these lines in V8), this test should not prefer the engines that do so.

@ptomato
Copy link
Contributor

ptomato commented Jan 14, 2025

@iamstolis Could you open a new issue for that? The comment is likely to get lost on a merged PR.

It's an ongoing effort to remove "golden output" like " AM" from the test262 corpus. See #3786.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Need to add test for ECMA402 PR919

3 participants