Skip to content

Conversation

Manishearth
Copy link
Member

Fixes #7083

@Manishearth Manishearth requested a review from sffc as a code owner October 14, 2025 18:58
Comment on lines 628 to 631
let reject = DateFromFieldsOptions {
overflow: Some(Overflow::Reject),
..Default::default()
};
Copy link
Member

Choose a reason for hiding this comment

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

Nit: It would be best to check this with all the modes:

  • Overflow Reject, Missing Fields Reject
  • Overflow Reject, Missing Fields Ecma
  • Overflow Constrain, Missing Fields Reject
  • Overflow Constrain, Missing Fields Ecma

It's a uniquely complex function with a lot of code paths and I want them to all be covered.

Comment on lines 659 to 660
extended_year: Some(i32::MAX),
ordinal_month: Some(100),
Copy link
Member

Choose a reason for hiding this comment

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

Nit, here and elsewhere: set only one of the fields to be out of bounds at a time, again to make sure we are covering all of the cases

@Manishearth
Copy link
Member Author

I moved it to a separate file (because it's getting big), and I think I tested most cases.

Copy link
Member

@sffc sffc left a comment

Choose a reason for hiding this comment

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

Better, thanks. Two more suggestions


mod continuity_test;
mod extrema;
mod not_enough_fields;
Copy link
Member

Choose a reason for hiding this comment

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

Nit: crate/src/tests is a weird thing specifically in icu_calendar for tests that need to access pub(crate) items. Most tests should go into crate/tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I made this choice because the test gets much more ugly because of non_exhaustive.

@Manishearth Manishearth requested a review from sffc October 14, 2025 20:08
@Manishearth Manishearth merged commit ef40c67 into unicode-org:main Oct 15, 2025
30 checks passed
@Manishearth Manishearth deleted the not-enough-fields branch October 15, 2025 13:44
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.

Add more tests around TypeError vs RangeError in Date::try_from_fields

2 participants