Skip to content

Temporal: Check observability of ordering of GetOptionsObject accesses#4989

Open
jessealama wants to merge 9 commits intotc39:mainfrom
jessealama:get-options-object-ordering
Open

Temporal: Check observability of ordering of GetOptionsObject accesses#4989
jessealama wants to merge 9 commits intotc39:mainfrom
jessealama:get-options-object-ordering

Conversation

@jessealama
Copy link
Contributor

This PR follows up #4987 with tests for observability of GetOptionsObject accesses. There, we tested just PlainYearMonth's .add and .subtract. Here, we follow the same pattern, exercising:

  • PlainDate: add, subtract, until, since, with, from
  • PlainDateTime: add, subtract, until, since, with, from
  • PlainYearMonth: until, since, with, from
  • PlainMonthDay: with, from
  • PlainTime: until, since, with, from
  • ZonedDateTime: add, subtract, until, since, with, from
  • Instant: until, since
  • Duration: compare

@jessealama jessealama requested a review from a team as a code owner March 11, 2026 11:10
@jessealama jessealama requested a review from ptomato March 11, 2026 11:18
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.

Looks good; note I didn't check for exhaustiveness, but I assume you did 😄

We should reduce the duplication before merging, though.

assert.compareArray(actual, expected, "order of operations");
actual.splice(0); // clear

const expectedOpsForPrimitiveOptions = [
Copy link
Contributor

Choose a reason for hiding this comment

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

There's an opportunity for increasing readability here, if you move this up a bit and then rewrite expected to be something like

const expected = expectedOpsForPrimitiveOptions.concat(["get options.relativeTo"]);

Otherwise we have these two long lists and it's difficult to tell at a glance that they are supposed to contain the same items.

This could apply to some of the other tests with long lists as well.

Comment on lines +88 to +95
// Non-integer values to ensure valueOf is called
const fields2 = TemporalHelpers.propertyBagObserver(actual, {
year: 1.7,
month: 1.7,
monthCode: "M01",
day: 1.7,
calendar: "iso8601",
}, "fields", ["calendar"]);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think(?) no need for fields2, you can just reuse fields. The array (actual) that it dumps into has been cleared.

This could apply to some of the other tests as well.

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.

2 participants