Skip to content

Commit a6f387d

Browse files
authored
[Temporal] Add function as acceptable undefined options object (#4990)
* [Temporal] Add function as acceptable undefined options object
1 parent e974f93 commit a6f387d

85 files changed

Lines changed: 248 additions & 12 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

test/built-ins/Temporal/Duration/prototype/toString/options-undefined.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ assert.sameValue(explicit, "P1Y2M3W4DT5H6M7.98765S", "default precision is auto,
1414

1515
const implicit = duration.toString();
1616
assert.sameValue(implicit, "P1Y2M3W4DT5H6M7.98765S", "default precision is auto, and rounding is trunc");
17+
18+
const lambda = duration.toString(() => {});
19+
assert.sameValue(lambda, "P1Y2M3W4DT5H6M7.98765S", "default precision is auto, and rounding is trunc");

test/built-ins/Temporal/Instant/prototype/since/largestunit-undefined.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ const explicit = later.since(earlier, { largestUnit: undefined });
1515
TemporalHelpers.assertDuration(explicit, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default largestUnit is second");
1616
const implicit = later.since(earlier, {});
1717
TemporalHelpers.assertDuration(implicit, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default largestUnit is second");
18+
const lambda = later.since(earlier, () => {});
19+
TemporalHelpers.assertDuration(lambda, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default largestUnit is second");

test/built-ins/Temporal/Instant/prototype/since/options-undefined.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,13 @@ assert.sameValue(implicit.hours, 0, "default largest unit is seconds");
2929
assert.sameValue(implicit.minutes, 0, "default largest unit is seconds");
3030
assert.sameValue(implicit.seconds, 2678400, "default largest unit is seconds");
3131
assert.sameValue(implicit.nanoseconds, 1, "default smallest unit is nanoseconds and no rounding");
32+
33+
const lambda = later.since(earlier, () => {});
34+
assert.sameValue(lambda.years, 0, "default largest unit is seconds");
35+
assert.sameValue(lambda.months, 0, "default largest unit is seconds");
36+
assert.sameValue(lambda.weeks, 0, "default largest unit is seconds");
37+
assert.sameValue(lambda.days, 0, "default largest unit is seconds");
38+
assert.sameValue(lambda.hours, 0, "default largest unit is seconds");
39+
assert.sameValue(lambda.minutes, 0, "default largest unit is seconds");
40+
assert.sameValue(lambda.seconds, 2678400, "default largest unit is seconds");
41+
assert.sameValue(lambda.nanoseconds, 1, "default smallest unit is nanoseconds and no rounding");

test/built-ins/Temporal/Instant/prototype/since/roundingincrement-undefined.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ TemporalHelpers.assertDuration(explicit, 0, 0, 0, 0, 0, 0, 90061, 1, 1, 1, "defa
2323

2424
const implicit = later.since(earlier, {});
2525
TemporalHelpers.assertDuration(implicit, 0, 0, 0, 0, 0, 0, 90061, 1, 1, 1, "default roundingIncrement is 1");
26+
27+
const lambda = later.since(earlier, () => {});
28+
TemporalHelpers.assertDuration(lambda, 0, 0, 0, 0, 0, 0, 90061, 1, 1, 1, "default roundingIncrement is 1");

test/built-ins/Temporal/Instant/prototype/since/smallestunit-undefined.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ const explicit = later.since(earlier, { smallestUnit: undefined });
1515
TemporalHelpers.assertDuration(explicit, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default smallestUnit is nanosecond");
1616
const implicit = later.since(earlier, {});
1717
TemporalHelpers.assertDuration(implicit, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default smallestUnit is nanosecond");
18+
const lambda = later.since(earlier, () => {});
19+
TemporalHelpers.assertDuration(lambda, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default smallestUnit is nanosecond");

test/built-ins/Temporal/Instant/prototype/toString/options-undefined.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,9 @@ assert.sameValue(
2020
"1975-02-02T14:25:36.12345Z",
2121
"default time zone is none, precision is auto, and rounding is trunc"
2222
);
23+
24+
assert.sameValue(
25+
instant.toString(() => {}),
26+
"1975-02-02T14:25:36.12345Z",
27+
"default time zone is none, precision is auto, and rounding is trunc"
28+
);

test/built-ins/Temporal/Instant/prototype/until/largestunit-undefined.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ const explicit = earlier.until(later, { largestUnit: undefined });
1515
TemporalHelpers.assertDuration(explicit, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default largestUnit is second");
1616
const implicit = earlier.until(later, {});
1717
TemporalHelpers.assertDuration(implicit, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default largestUnit is second");
18+
const lambda = earlier.until(later, () => {});
19+
TemporalHelpers.assertDuration(lambda, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default largestUnit is second");

test/built-ins/Temporal/Instant/prototype/until/options-undefined.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,13 @@ assert.sameValue(implicit.hours, 0, "default largest unit is seconds");
2929
assert.sameValue(implicit.minutes, 0, "default largest unit is seconds");
3030
assert.sameValue(implicit.seconds, 2678400, "default largest unit is seconds");
3131
assert.sameValue(implicit.nanoseconds, 1, "default smallest unit is nanoseconds and no rounding");
32+
33+
const lambda = earlier.until(later, () => {});
34+
assert.sameValue(lambda.years, 0, "default largest unit is seconds");
35+
assert.sameValue(lambda.months, 0, "default largest unit is seconds");
36+
assert.sameValue(lambda.weeks, 0, "default largest unit is seconds");
37+
assert.sameValue(lambda.days, 0, "default largest unit is seconds");
38+
assert.sameValue(lambda.hours, 0, "default largest unit is seconds");
39+
assert.sameValue(lambda.minutes, 0, "default largest unit is seconds");
40+
assert.sameValue(lambda.seconds, 2678400, "default largest unit is seconds");
41+
assert.sameValue(lambda.nanoseconds, 1, "default smallest unit is nanoseconds and no rounding");

test/built-ins/Temporal/Instant/prototype/until/roundingincrement-undefined.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,6 @@ TemporalHelpers.assertDuration(explicit, 0, 0, 0, 0, 0, 0, 90061, 1, 1, 1, "defa
2323

2424
const implicit = earlier.until(later, {});
2525
TemporalHelpers.assertDuration(implicit, 0, 0, 0, 0, 0, 0, 90061, 1, 1, 1, "default roundingIncrement is 1");
26+
27+
const lambda = earlier.until(later, () => {});
28+
TemporalHelpers.assertDuration(lambda, 0, 0, 0, 0, 0, 0, 90061, 1, 1, 1, "default roundingIncrement is 1");

test/built-ins/Temporal/Instant/prototype/until/smallestunit-undefined.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,5 @@ const explicit = earlier.until(later, { smallestUnit: undefined });
1515
TemporalHelpers.assertDuration(explicit, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default smallestUnit is nanosecond");
1616
const implicit = earlier.until(later, {});
1717
TemporalHelpers.assertDuration(implicit, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default smallestUnit is nanosecond");
18+
const lambda = earlier.until(later, () => {});
19+
TemporalHelpers.assertDuration(lambda, 0, 0, 0, 0, 0, 0, 90061, 987, 654, 321, "default smallestUnit is nanosecond");

0 commit comments

Comments
 (0)