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

Normative: Validate results of Calendar operations #2265

Merged
merged 8 commits into from
Oct 5, 2022

Conversation

anba
Copy link
Contributor

@anba anba commented Jun 9, 2022

The validation was already mentioned in the preamble of each operation, but it wasn't actually performed.

@codecov
Copy link

codecov bot commented Jun 9, 2022

Codecov Report

Merging #2265 (31de2c7) into main (b25fee9) will decrease coverage by 0.25%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2265      +/-   ##
==========================================
- Coverage   95.03%   94.78%   -0.26%     
==========================================
  Files          20       20              
  Lines       10881    10890       +9     
  Branches     1934     1925       -9     
==========================================
- Hits        10341    10322      -19     
- Misses        504      532      +28     
  Partials       36       36              
Impacted Files Coverage Δ
polyfill/lib/ecmascript.mjs 98.63% <100.00%> (+0.32%) ⬆️
polyfill/lib/zoneddatetime.mjs 99.81% <100.00%> (+<0.01%) ⬆️
polyfill/lib/calendar.mjs 81.40% <0.00%> (-2.14%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

spec/calendar.html Outdated Show resolved Hide resolved
@Ms2ger Ms2ger changed the title Validate results of Calendar operations Normative: Validate results of Calendar operations Jun 14, 2022
@anba anba mentioned this pull request Jun 17, 2022
Copy link
Collaborator

@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! This can go on the list to present at the next plenary. I'll mark it as draft so it is not merged accidentally before then.

Would you mind splitting the second commit (removing the checks for undefined) into a separate editorial pull request?

spec/calendar.html Outdated Show resolved Hide resolved
@anba
Copy link
Contributor Author

anba commented Jun 27, 2022

Would you mind splitting the second commit (removing the checks for undefined) into a separate editorial pull request?

Moved into #2332.

@ptomato ptomato added spec-text Specification text involved normative Would be a normative change to the proposal labels Jul 4, 2022
ptomato added a commit to ptomato/test262 that referenced this pull request Oct 4, 2022
The existing tests would fail after making the normative change from
tc39/proposal-temporal#2265 because they rely on the getter directly
returning whatever value the calendar method returned. This is no longer
the case, because the value returned by the calendar is validated, so
adjust the assertions in these tests.

Also, no longer any need to return a value from the calendar method that
needs to be converted; we'll add separate tests for that.

Expand these tests to cover all of the PlainDate, PlainDateTime,
PlainMonthDay, PlainYearMonth, and ZonedDateTime property getters that
delegate to the calendar methods.
ptomato added a commit to ptomato/test262 that referenced this pull request Oct 4, 2022
This adds tests for the normative change in tc39/proposal-temporal#2265,
which adds validation steps to certain abstract operations that call
Temporal.Calendar methods.

These had some duplication with some existing tests named
calendar-returns-infinity.js. Remove these, because the new tests are more
complete in testing what values are accepted.
@ptomato ptomato force-pushed the validate-calendar-functions branch from 389dc78 to b6945af Compare October 4, 2022 23:37
@ptomato ptomato marked this pull request as ready for review October 4, 2022 23:37
@ptomato
Copy link
Collaborator

ptomato commented Oct 4, 2022

This reached consensus in July 2022. I've rebased it and addressed my comment about 𝔽(), and added an implementation of the normative change to the reference code. Tests are in tc39/test262#3681, we'll need to update test262 once that's merged, since this invalidates some existing test262 tests.

Ms2ger pushed a commit to tc39/test262 that referenced this pull request Oct 5, 2022
The existing tests would fail after making the normative change from
tc39/proposal-temporal#2265 because they rely on the getter directly
returning whatever value the calendar method returned. This is no longer
the case, because the value returned by the calendar is validated, so
adjust the assertions in these tests.

Also, no longer any need to return a value from the calendar method that
needs to be converted; we'll add separate tests for that.

Expand these tests to cover all of the PlainDate, PlainDateTime,
PlainMonthDay, PlainYearMonth, and ZonedDateTime property getters that
delegate to the calendar methods.
Ms2ger pushed a commit to tc39/test262 that referenced this pull request Oct 5, 2022
This adds tests for the normative change in tc39/proposal-temporal#2265,
which adds validation steps to certain abstract operations that call
Temporal.Calendar methods.

These had some duplication with some existing tests named
calendar-returns-infinity.js. Remove these, because the new tests are more
complete in testing what values are accepted.
anba and others added 7 commits October 5, 2022 07:48
The operation preamble already stated "[...] and validates the result.",
but not actual validation took place.
`CalendarDaysInMonth` already calls `ToPositveInteger`.
The normative change in this PR changed the return types of these
operations from "ECMAScript language value" to "integer", which means we
need to convert them back to ECMAScript floats when exposing them to JS.
This adds structured headers to the abstract operations that call the
calendar methods that back the Plain types' property getters. May as well
do it while I was correcting the return types anyways.
This implements the changes from "Normative: Add missing validation to
remaining Calendar operations", which adds a validation step to the
abstract operations that call certain Temporal.Calendar methods.
These checks are all redundant due to ES.ToPositiveInteger() being called
elsewhere in the same path.
@ptomato ptomato force-pushed the validate-calendar-functions branch from b6945af to 697e7bb Compare October 5, 2022 14:50
@ptomato ptomato force-pushed the validate-calendar-functions branch from 697e7bb to 31de2c7 Compare October 5, 2022 14:54
@ptomato ptomato merged commit ab3fea9 into tc39:main Oct 5, 2022
@anba anba deleted the validate-calendar-functions branch August 4, 2023 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
normative Would be a normative change to the proposal spec-text Specification text involved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants