Skip to content

Commit d08b66a

Browse files
authored
Merge branch 'main' into import-defer-new-cases
2 parents c32db76 + 678c434 commit d08b66a

File tree

58 files changed

+1335
-30
lines changed

Some content is hidden

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

58 files changed

+1335
-30
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.duration.prototype.compare
6+
description: >
7+
A property bag missing optional properties is equivalent to a property bag
8+
with all the optional properties having their default values
9+
features: [Temporal]
10+
---*/
11+
12+
const oneProperty = {
13+
hours: 1,
14+
};
15+
const allProperties = {
16+
years: 0,
17+
months: 0,
18+
weeks: 0,
19+
days: 0,
20+
hours: 1,
21+
minutes: 0,
22+
seconds: 0,
23+
milliseconds: 0,
24+
microseconds: 0,
25+
nanoseconds: 0,
26+
};
27+
const resultWithout = Temporal.Duration.compare(oneProperty, oneProperty);
28+
const resultWith = Temporal.Duration.compare(allProperties, allProperties);
29+
assert.sameValue(resultWithout, resultWith, "results should be the same with and without optional properties");
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.duration.prototype.compare
6+
description: >
7+
A property bag missing optional properties is equivalent to a property bag
8+
with all the optional properties having their default values
9+
features: [Temporal]
10+
---*/
11+
12+
const duration1 = new Temporal.Duration(1);
13+
const duration2 = new Temporal.Duration(0, 1);
14+
15+
let relativeTo = {
16+
year: 2021,
17+
month: 10,
18+
day: 28,
19+
timeZone: "UTC",
20+
};
21+
const resultWithout = Temporal.Duration.compare(duration1, duration2, { relativeTo });
22+
relativeTo = {
23+
year: 2021,
24+
month: 10,
25+
day: 28,
26+
hour: 0,
27+
minute: 0,
28+
second: 0,
29+
millisecond: 0,
30+
microsecond: 0,
31+
nanosecond: 0,
32+
offset: "+00:00",
33+
timeZone: "UTC",
34+
calendar: "iso8601",
35+
};
36+
const resultWith = Temporal.Duration.compare(duration1, duration2, { relativeTo });
37+
assert.sameValue(resultWithout, resultWith, "results should be the same with and without optional properties");
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.duration.prototype.from
6+
description: >
7+
A property bag missing optional properties is equivalent to a property bag
8+
with all the optional properties having their default values
9+
includes: [temporalHelpers.js]
10+
features: [Temporal]
11+
---*/
12+
13+
const oneProperty = {
14+
hours: 1,
15+
};
16+
const allProperties = {
17+
years: 0,
18+
months: 0,
19+
weeks: 0,
20+
days: 0,
21+
hours: 1,
22+
minutes: 0,
23+
seconds: 0,
24+
milliseconds: 0,
25+
microseconds: 0,
26+
nanoseconds: 0,
27+
};
28+
const resultWithout = Temporal.Duration.from(oneProperty);
29+
const resultWith = Temporal.Duration.from(allProperties);
30+
TemporalHelpers.assertDurationsEqual(resultWithout, resultWith, "results should be the same with and without optional properties");
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.duration.prototype.add
6+
description: >
7+
A property bag missing optional properties is equivalent to a property bag
8+
with all the optional properties having their default values
9+
includes: [temporalHelpers.js]
10+
features: [Temporal]
11+
---*/
12+
13+
const instance = new Temporal.Duration();
14+
15+
const oneProperty = {
16+
hours: 1,
17+
};
18+
const allProperties = {
19+
years: 0,
20+
months: 0,
21+
weeks: 0,
22+
days: 0,
23+
hours: 1,
24+
minutes: 0,
25+
seconds: 0,
26+
milliseconds: 0,
27+
microseconds: 0,
28+
nanoseconds: 0,
29+
};
30+
const resultWithout = instance.add(oneProperty);
31+
const resultWith = instance.add(allProperties);
32+
TemporalHelpers.assertDurationsEqual(resultWithout, resultWith, "results should be the same with and without optional properties");

test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-wrong-type.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const instance = new Temporal.Duration(1, 0, 0, 0, 24);
1414
const wrongTypeTests = [
1515
[null, "null"],
1616
[true, "boolean"],
17-
[1, "number that doesn't convert to a valid ISO string"],
17+
[1, "number"],
1818
[1n, "bigint"],
1919
[19970327, "large number"],
2020
[-19970327, "negative number"],
@@ -32,6 +32,6 @@ for (const [calendar, description] of wrongTypeTests) {
3232
assert.throws(
3333
TypeError,
3434
() => instance.round({ largestUnit: "years", relativeTo }),
35-
`${description} does not convert to a valid ISO string`
35+
`${description} is not a valid calendar`
3636
);
3737
}

test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-invalid-offset-string.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ badOffsets.forEach((offset) => {
2424
assert.throws(
2525
typeof(offset) === 'string' ? RangeError : TypeError,
2626
() => instance.round({ largestUnit: "years", relativeTo }),
27-
`"${offset} is not a valid offset string`
27+
`"${offset}" is not a valid offset string`
2828
);
2929
});
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.duration.prototype.round
6+
description: >
7+
A property bag missing optional properties is equivalent to a property bag
8+
with all the optional properties having their default values
9+
includes: [temporalHelpers.js]
10+
features: [Temporal]
11+
---*/
12+
13+
const timeZone = "UTC";
14+
const instance = new Temporal.Duration(1, 0, 0, 0, 24);
15+
16+
let relativeTo = {
17+
year: 2021,
18+
month: 10,
19+
day: 28,
20+
timeZone,
21+
};
22+
const resultWithout = instance.round({ largestUnit: "years", relativeTo });
23+
relativeTo = {
24+
year: 2021,
25+
month: 10,
26+
day: 28,
27+
hour: 0,
28+
minute: 0,
29+
second: 0,
30+
millisecond: 0,
31+
microsecond: 0,
32+
nanosecond: 0,
33+
offset: "+00:00",
34+
timeZone,
35+
calendar: "iso8601",
36+
};
37+
const resultWith = instance.round({ largestUnit: "years", relativeTo });
38+
TemporalHelpers.assertDurationsEqual(resultWithout, resultWith, "results should be the same with and without optional properties");

test/built-ins/Temporal/Duration/prototype/round/relativeto-wrong-type.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const primitiveTests = [
1717
[null, 'null'],
1818
[true, 'boolean'],
1919
['', 'empty string'],
20-
[1, "number that doesn't convert to a valid ISO string"],
20+
[1, 'number'],
2121
[1n, 'bigint']
2222
];
2323

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.duration.prototype.subtract
6+
description: >
7+
A property bag missing optional properties is equivalent to a property bag
8+
with all the optional properties having their default values
9+
includes: [temporalHelpers.js]
10+
features: [Temporal]
11+
---*/
12+
13+
const instance = new Temporal.Duration();
14+
15+
const oneProperty = {
16+
hours: 1,
17+
};
18+
const allProperties = {
19+
years: 0,
20+
months: 0,
21+
weeks: 0,
22+
days: 0,
23+
hours: 1,
24+
minutes: 0,
25+
seconds: 0,
26+
milliseconds: 0,
27+
microseconds: 0,
28+
nanoseconds: 0,
29+
};
30+
const resultWithout = instance.subtract(oneProperty);
31+
const resultWith = instance.subtract(allProperties);
32+
TemporalHelpers.assertDurationsEqual(resultWithout, resultWith, "results should be the same with and without optional properties");
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Copyright (C) 2025 Igalia, S.L. All rights reserved.
2+
// This code is governed by the BSD license found in the LICENSE file.
3+
4+
/*---
5+
esid: sec-temporal.duration.prototype.tojson
6+
description: Pairs of units with one large and one small
7+
features: [Temporal]
8+
---*/
9+
10+
assert.sameValue(
11+
new Temporal.Duration(1, 0, 0, 0, 0, 0, 0, 0, 0, 1).toJSON(),
12+
"P1YT0.000000001S",
13+
"years with nanoseconds"
14+
);
15+
16+
assert.sameValue(
17+
new Temporal.Duration(0, 1, 0, 0, 0, 0, 0, 0, 1).toJSON(),
18+
"P1MT0.000001S",
19+
"months with microseconds"
20+
);
21+
22+
assert.sameValue(
23+
new Temporal.Duration(0, 0, 1, 0, 0, 0, 0, 1).toJSON(),
24+
"P1WT0.001S",
25+
"weeks with milliseconds"
26+
);
27+
28+
assert.sameValue(
29+
new Temporal.Duration(0, 0, 0, 1, 0, 0, 1).toJSON(),
30+
"P1DT1S",
31+
"days with seconds"
32+
);
33+
34+
assert.sameValue(
35+
new Temporal.Duration(0, 0, 0, 0, 1, 1).toJSON(),
36+
"PT1H1M",
37+
"hours with minutes"
38+
);

0 commit comments

Comments
 (0)