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

Tests for audit of Temporal user code calls, part 2 #3897

Merged
merged 8 commits into from
Sep 13, 2023

Conversation

ptomato
Copy link
Contributor

@ptomato ptomato commented Aug 18, 2023

Continuing on from #3894, tc39/proposal-temporal#2519 is a very large pull request and I'm planning to land it in parts. This PR contains tests for the second part. Each commit here corresponds to the same-named commit in the proposal-temporal normative PR.

Recommend reviewing commit-by-commit. Note, in the commit titled "Temporal: Don't observably iterate array in built-in calendar's fields()" there are a large number of tests that are basically copy-pasted except for one, as noted in the commit message, so double-check that one when reviewing.

@ptomato ptomato requested a review from a team as a code owner August 18, 2023 23:15
@ptomato ptomato changed the title Tests for audit of Temporal user code calls, part 1 Tests for audit of Temporal user code calls, part 2 Aug 18, 2023
@ptomato ptomato force-pushed the user-code-calls-part-2 branch 3 times, most recently from cf23b46 to a26d564 Compare September 12, 2023 02:35
@cjtenny
Copy link
Contributor

cjtenny commented Sep 12, 2023

Looks great to me. Covers all the different entry points for each operation. Really thorough - discussed some feedback directly while working through the commits, and you fixed the spec bug I found in the no-op round operations before I got to comment it on the review :P only extant feedback:

For the tests in 'Don't observably iterate array in built-in calendar's fields()', do we have any tests already that cover that an otherwise unmodified Temporal.Calendar.from('iso8601') in the same use case will cause Array.prototype[Symbol.iterator] to be invoked?

@ptomato
Copy link
Contributor Author

ptomato commented Sep 13, 2023

For the tests in 'Don't observably iterate array in built-in calendar's fields()', do we have any tests already that cover that an otherwise unmodified Temporal.Calendar.from('iso8601') in the same use case will cause Array.prototype[Symbol.iterator] to be invoked?

I made various modifications to the reference polyfill and re-ran the tests, to check this. I think the answer is, we do not have any tests for this directly. (If you modify CalendarFields to skip the iteration when calendar has the correct internal slot and Get(calendar, "fields") is the same value as %Temporal.Calendar.prototype.fields%, then no tests fail.) However, we do have tests that will fail if an implementation makes the mistake that would generally be the cause of this situation, that is, treating an unmodified instance of a built-in calendar the same as a string calendar.

This shortcut path now exists in all round(), since(), and until()
operations.
In Instant, PlainDate, PlainDateTime, and PlainTime, the change isn't
observable, so no tests could be added. This adds test coverage for

- Duration.p.round()
- PlainYearMonth.p.since()
- PlainYearMonth.p.until()
- ZonedDateTime.p.round()
- ZonedDateTime.p.since()
- ZonedDateTime.p.until()

As well as a few cases where we are testing that certain calendar methods
get called during a round operation, but previously were doing so with
options that now become a no-op and no longer call those calendar methods.
In those cases, round to 2 ns, rather than 1 ns.
Adds new tests to order-of-operations.js in Duration.round and
Duration.total, to exercise the code path where previous to this normative
change, relativeTo would have been converted to PlainDate 3x and 2x,
respectively.
Note the monkeypatch of getPossibleInstantsFor in test/built-ins/Temporal/
TimeZone/prototype/getInstantFor/argument-builtin-calendar-no-array-
iteration.js.

Other than that, all the tests are basically identical.
@Ms2ger Ms2ger enabled auto-merge (rebase) September 13, 2023 08:54
@Ms2ger Ms2ger merged commit e98bfb3 into tc39:main Sep 13, 2023
8 of 9 checks passed
@ptomato ptomato deleted the user-code-calls-part-2 branch September 13, 2023 16:22
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.

3 participants