Add regression tests for locale default hour cycle (Fixes #594)#7652
Add regression tests for locale default hour cycle (Fixes #594)#7652afrdbaig7 wants to merge 2 commits intounicode-org:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive regression tests for issue #594, ensuring that datetime formatting correctly falls back to locale-specific default hour cycles based on CLDR region data when no explicit -u-hc- preference is provided.
Changes:
- Added datagen test to validate that
preferred_hour_cycle()correctly infers hour cycles from CLDR data - Added runtime test to verify that datetime formatting uses the correct default hour cycle for various locales
- Included tests for explicit
-u-hc-overrides and midnight edge cases
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| provider/source/src/datetime/semantic_skeletons/tests.rs | Adds test_preferred_hour_cycle_by_locale() to validate datagen pipeline correctly infers locale-specific hour cycles from CLDR patterns |
| components/datetime/tests/simple_test.rs | Adds test_locale_default_hour_cycle() to verify runtime formatting behavior with default and explicit hour cycle preferences |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| for (locale_str, expected_hour_cycle) in cases { | ||
| let locale: Locale = locale_str.parse().unwrap(); | ||
| let prefs = DateTimeFormatterPreferences::from(&locale); | ||
| let formatter = FixedCalendarDateTimeFormatter::<icu_calendar::Gregorian, _>::try_new( |
There was a problem hiding this comment.
Consider importing Gregorian from icu_calendar at the top of the file and using the shorter Gregorian instead of the fully qualified icu_calendar::Gregorian. This would be consistent with other test files like resolved_components.rs that import and use Gregorian directly.
sffc
left a comment
There was a problem hiding this comment.
I think we have tests for this already, but adding additional tests specifically for the components::Bag behavior as integration tests is harmless and directly fixes the issue.
Thanks for the review |
|
Please fix the merge conflict |
…#594) Add tests to ensure datetime formatting correctly falls back to the locale's default hour cycle based on CLDR region data when no explicit -u-hc- preference is provided. Runtime tests (simple_test.rs): - Verify default behavior: - en → h12 - fr, ja, en-GB → h23 - Ensure explicit -u-hc- overrides take priority - Cover midnight edge case formatting Datagen test (semantic_skeletons/tests.rs): - Verify preferred_hour_cycle() returns expected CoarseHourCycle: - en → H11H12 - fr, ja, en-ZA → H23 These tests help prevent regressions and make the locale-driven hour cycle behavior explicit and well-covered.
4d3bd27 to
3621767
Compare
Fixes #594
This PR adds regression tests to make sure datetime formatting falls back
to the correct default hour cycle based on CLDR region data when no
explicit -u-hc- preference is provided.
I added both runtime and datagen tests so that the behavior is covered
at formatting time as well as at the data level.
Runtime tests (simple_test.rs):
Datagen test (semantic_skeletons/tests.rs):
CoarseHourCycle:
Note: The runtime tests require
feature = "experimental"forcomponents::Bagaccess.These tests should help prevent regressions and make the expected
locale-based hour cycle behavior more clearly covered.