Skip to content

Commit e6d760c

Browse files
committed
Added tests ensuring yearOfWeek and weekOfYear are undefined when
using non-ISO calendar with `PlainDate`, `PlainDateTime`, and `ZonedDateTime`
1 parent d086cbc commit e6d760c

File tree

6 files changed

+159
-65
lines changed

6 files changed

+159
-65
lines changed

test/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,31 @@ description: >
99
features: [Temporal, Intl.Era-monthcode]
1010
---*/
1111

12-
assert.sameValue(
13-
new Temporal.PlainDate(2024, 1, 1, "gregory").weekOfYear,
14-
undefined,
15-
"Gregorian calendar does not provide week numbers"
16-
);
1712

18-
assert.sameValue(
19-
new Temporal.PlainDate(2024, 1, 1, "hebrew").weekOfYear,
20-
undefined,
21-
"Hebrew calendar does not provide week numbers"
22-
);
13+
const nonIsoCalendars = [
14+
"buddhist",
15+
"chinese",
16+
"coptic",
17+
"dangi",
18+
"ethioaa",
19+
"ethiopic",
20+
"gregory",
21+
"hebrew",
22+
"indian",
23+
"islamic-civil",
24+
"islamic-tbla",
25+
"islamic-umalqura",
26+
"islamicc",
27+
"japanese",
28+
"persian",
29+
"roc"
30+
];
31+
32+
33+
for (const calendar of nonIsoCalendars){
34+
assert.sameValue(
35+
new Temporal.PlainDate(2024, 1, 1, calendar).weekOfYear,
36+
undefined,
37+
`${calendar} does not provide week numbers`
38+
);
39+
}

test/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,31 @@ description: >
99
features: [Temporal, Intl.Era-monthcode]
1010
---*/
1111

12-
assert.sameValue(
13-
new Temporal.PlainDate(2024, 1, 1, "gregory").yearOfWeek,
14-
undefined,
15-
"Gregorian calendar does not provide week numbers"
16-
);
12+
const nonIsoCalendars = [
13+
"buddhist",
14+
"chinese",
15+
"coptic",
16+
"dangi",
17+
"ethioaa",
18+
"ethiopic",
19+
"gregory",
20+
"hebrew",
21+
"indian",
22+
"islamic-civil",
23+
"islamic-tbla",
24+
"islamic-umalqura",
25+
"islamicc",
26+
"japanese",
27+
"persian",
28+
"roc"
29+
];
30+
31+
32+
for (const calendar of nonIsoCalendars){
33+
assert.sameValue(
34+
new Temporal.PlainDate(2024, 1, 1, calendar).yearOfWeek,
35+
undefined,
36+
`${calendar} does not provide week numbers`
37+
);
38+
}
1739

18-
assert.sameValue(
19-
new Temporal.PlainDate(2024, 1, 1, "hebrew").yearOfWeek,
20-
undefined,
21-
"Hebrew calendar does not provide week numbers"
22-
);

test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,34 @@
44
/*---
55
esid: sec-temporal.plaindatetime.prototype.weekofyear
66
description: >
7-
Temporal.PlainDateTime.prototype.weekOfYear returns undefined for all
7+
Temporal.PlainDateTimeTime.prototype.weekOfYear returns undefined for all
88
non-ISO calendars without a well-defined week numbering system.
9-
features: [Temporal]
9+
features: [Temporal, Intl.Era-monthcode]
1010
---*/
1111

12-
assert.sameValue(
13-
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, "gregory").weekOfYear,
14-
undefined,
15-
"Gregorian calendar does not provide week numbers"
16-
);
12+
const nonIsoCalendars = [
13+
"buddhist",
14+
"chinese",
15+
"coptic",
16+
"dangi",
17+
"ethioaa",
18+
"ethiopic",
19+
"gregory",
20+
"hebrew",
21+
"indian",
22+
"islamic-civil",
23+
"islamic-tbla",
24+
"islamic-umalqura",
25+
"islamicc",
26+
"japanese",
27+
"persian",
28+
"roc"
29+
];
1730

18-
assert.sameValue(
19-
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, "hebrew").weekOfYear,
20-
undefined,
21-
"Hebrew calendar does not provide week numbers"
22-
);
31+
for (const calendar of nonIsoCalendars){
32+
assert.sameValue(
33+
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar).weekOfYear,
34+
undefined,
35+
`${calendar} does not provide week numbers`
36+
);
37+
}

test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,32 @@ esid: sec-temporal.plaindatetime.prototype.yearofweek
66
description: >
77
Temporal.PlainDateTime.prototype.yearOfWeek returns undefined for all
88
non-ISO calendars without a well-defined week numbering system.
9-
features: [Temporal]
9+
features: [Temporal, Intl.Era-monthcode]
1010
---*/
1111

12-
assert.sameValue(
13-
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, "gregory").yearOfWeek,
14-
undefined,
15-
"Gregorian calendar does not provide week numbers"
16-
);
12+
const nonIsoCalendars = [
13+
"buddhist",
14+
"chinese",
15+
"coptic",
16+
"dangi",
17+
"ethioaa",
18+
"ethiopic",
19+
"gregory",
20+
"hebrew",
21+
"indian",
22+
"islamic-civil",
23+
"islamic-tbla",
24+
"islamic-umalqura",
25+
"islamicc",
26+
"japanese",
27+
"persian",
28+
"roc"
29+
];
1730

18-
assert.sameValue(
19-
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, "hebrew").yearOfWeek,
20-
undefined,
21-
"Hebrew calendar does not provide week numbers"
22-
);
31+
for (const calendar of nonIsoCalendars){
32+
assert.sameValue(
33+
new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar).yearOfWeek,
34+
undefined,
35+
`${calendar} does not provide week numbers`
36+
);
37+
}

test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,32 @@ esid: sec-temporal.zoneddatetime.prototype.weekofyear
66
description: >
77
Temporal.ZonedDateTime.prototype.weekOfYear returns undefined for all
88
non-ISO calendars without a well-defined week numbering system.
9-
features: [Temporal]
9+
features: [Temporal, Intl.Era-monthcode]
1010
---*/
1111

12-
assert.sameValue(
13-
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", "gregory").weekOfYear,
14-
undefined,
15-
"Gregorian calendar does not provide week numbers"
16-
);
12+
const nonIsoCalendars = [
13+
"buddhist",
14+
"chinese",
15+
"coptic",
16+
"dangi",
17+
"ethioaa",
18+
"ethiopic",
19+
"gregory",
20+
"hebrew",
21+
"indian",
22+
"islamic-civil",
23+
"islamic-tbla",
24+
"islamic-umalqura",
25+
"islamicc",
26+
"japanese",
27+
"persian",
28+
"roc"
29+
];
1730

18-
assert.sameValue(
19-
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", "hebrew").weekOfYear,
20-
undefined,
21-
"Hebrew calendar does not provide week numbers"
22-
);
31+
for (const calendar of nonIsoCalendars){
32+
assert.sameValue(
33+
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar).weekOfYear,
34+
undefined,
35+
`${calendar} does not provide week numbers`
36+
);
37+
}

test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,32 @@ esid: sec-temporal.zoneddatetime.prototype.yearofweek
66
description: >
77
Temporal.ZonedDateTime.prototype.yearOfWeek returns undefined for all
88
non-ISO calendars without a well-defined week numbering system.
9-
features: [Temporal]
9+
features: [Temporal, Intl.Era-monthcode]
1010
---*/
1111

12-
assert.sameValue(
13-
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", "gregory").yearOfWeek,
14-
undefined,
15-
"Gregorian calendar does not provide week numbers"
16-
);
12+
const nonIsoCalendars = [
13+
"buddhist",
14+
"chinese",
15+
"coptic",
16+
"dangi",
17+
"ethioaa",
18+
"ethiopic",
19+
"gregory",
20+
"hebrew",
21+
"indian",
22+
"islamic-civil",
23+
"islamic-tbla",
24+
"islamic-umalqura",
25+
"islamicc",
26+
"japanese",
27+
"persian",
28+
"roc"
29+
];
1730

18-
assert.sameValue(
19-
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", "hebrew").yearOfWeek,
20-
undefined,
21-
"Hebrew calendar does not provide week numbers"
22-
);
31+
for (const calendar of nonIsoCalendars){
32+
assert.sameValue(
33+
new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar).weekOfYear,
34+
undefined,
35+
`${calendar} does not provide week numbers`
36+
);
37+
}

0 commit comments

Comments
 (0)