-
Notifications
You must be signed in to change notification settings - Fork 541
Intl era monthcode: PlainYearMonth tests, part 1 #4762
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
Merged
ptomato
merged 4 commits into
tc39:main
from
ptomato:intl-era-monthcode-plainyearmonth-part1
Dec 4, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e12647d
TemporalHelpers: Add feature for auto-computing PlainYearMonth ref day
ptomato b854033
Intl Era Monthcode: Adapt PlainDate.from tests to PlainYearMonth.from
ptomato 57d543d
Intl Era Monthcode: Adapt PlainDate.daysInMonth tests to PlainYearMon…
ptomato 695015b
Intl Era Monthcode: Adapt PlainDate.with tests to PlainYearMonth.with
ptomato File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // Copyright (C) 2025 Igalia, S.L. All rights reserved. | ||
| // This code is governed by the BSD license found in the LICENSE file. | ||
|
|
||
| /*--- | ||
| esid: sec-temporal.plainyearmonth.from | ||
| description: Basic functionality of resolving fields in hebrew calendar | ||
| features: [Temporal, Intl.Era-monthcode] | ||
| includes: [temporalHelpers.js] | ||
| ---*/ | ||
|
|
||
| const calendar = "hebrew"; | ||
| const options = { overflow: "reject" }; | ||
|
|
||
| const commonYear = 5783; | ||
|
|
||
| for (let month = 1; month < 13; month++) { | ||
| const monthCode = `M${String(month).padStart(2, '0')}`; | ||
|
|
||
| const startOfMonth = Temporal.PlainYearMonth.from({ year: commonYear, month, calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| startOfMonth, | ||
| commonYear, month, monthCode, | ||
| `${monthCode} in common year`, | ||
| "am", commonYear, null | ||
| ); | ||
| } |
32 changes: 32 additions & 0 deletions
32
test/intl402/Temporal/PlainYearMonth/from/calendarresolvefields-error-ordering-gregory.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Copyright (C) 2025 Igalia, S.L. All rights reserved. | ||
| // This code is governed by the BSD license found in the LICENSE file. | ||
|
|
||
| /*--- | ||
| esid: sec-temporal.plainyearmonth.from | ||
| description: CalendarResolveFields throws TypeError before RangeError (gregory calendar) | ||
| info: | | ||
| CalendarResolveFields validates field types before validating field ranges, | ||
| ensuring TypeError is thrown before RangeError when both conditions exist. | ||
| features: [Temporal, Intl.Era-monthcode] | ||
| ---*/ | ||
|
|
||
| // Missing year (and no era/eraYear) should throw TypeError even with month/monthCode conflict | ||
| assert.throws( | ||
| TypeError, | ||
| () => Temporal.PlainYearMonth.from({ calendar: "gregory", monthCode: "M05", month: 6 }), | ||
| "Missing year/era throws TypeError before month/monthCode conflict throws RangeError" | ||
| ); | ||
|
|
||
| // undefined year should throw TypeError even with month/monthCode conflict | ||
| assert.throws( | ||
| TypeError, | ||
| () => Temporal.PlainYearMonth.from({ calendar: "gregory", year: undefined, monthCode: "M05", month: 6 }), | ||
| "undefined year throws TypeError before month/monthCode conflict throws RangeError" | ||
| ); | ||
|
|
||
| // After type validation passes, range validation should throw RangeError | ||
| assert.throws( | ||
| RangeError, | ||
| () => Temporal.PlainYearMonth.from({ calendar: "gregory", year: 2020, monthCode: "M05", month: 6 }), | ||
| "month/monthCode conflict throws RangeError when all types are valid" | ||
| ); |
36 changes: 36 additions & 0 deletions
36
test/intl402/Temporal/PlainYearMonth/from/era-boundary-ethiopic.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (C) 2025 Igalia, S.L. All rights reserved. | ||
| // This code is governed by the BSD license found in the LICENSE file. | ||
|
|
||
| /*--- | ||
| esid: sec-temporal.plainyearmonth.from | ||
| description: Non-positive era years are remapped in ethiopic calendar | ||
| includes: [temporalHelpers.js] | ||
| features: [Temporal, Intl.Era-monthcode] | ||
| ---*/ | ||
|
|
||
| const calendar = "ethiopic"; | ||
| const options = { overflow: "reject" }; | ||
|
|
||
| const am0 = Temporal.PlainYearMonth.from({ era: "am", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| am0, | ||
| 0, 1, "M01", "AM 0 resolves to AA 5500", | ||
| "aa", 5500, null); | ||
|
|
||
| const am1n = Temporal.PlainYearMonth.from({ era: "am", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| am1n, | ||
| -1, 1, "M01", "AM -1 resolves to AA 5499", | ||
| "aa", 5499, null); | ||
|
|
||
| const aa0 = Temporal.PlainYearMonth.from({ era: "aa", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| aa0, | ||
| -5500, 1, "M01", "AA 0 is not remapped", | ||
| "aa", 0, null); | ||
|
|
||
| const aa1n = Temporal.PlainYearMonth.from({ era: "aa", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| aa1n, | ||
| -5501, 1, "M01", "AA -1 is not remapped", | ||
| "aa", -1, null); |
36 changes: 36 additions & 0 deletions
36
test/intl402/Temporal/PlainYearMonth/from/era-boundary-gregory.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (C) 2025 Igalia, S.L. All rights reserved. | ||
| // This code is governed by the BSD license found in the LICENSE file. | ||
|
|
||
| /*--- | ||
| esid: sec-temporal.plainyearmonth.from | ||
| description: Non-positive era years are remapped in gregory calendar | ||
| includes: [temporalHelpers.js] | ||
| features: [Temporal, Intl.Era-monthcode] | ||
| ---*/ | ||
|
|
||
| const calendar = "gregory"; | ||
| const options = { overflow: "reject" }; | ||
|
|
||
| const ce0 = Temporal.PlainYearMonth.from({ era: "ce", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| ce0, | ||
| 0, 1, "M01", "CE 0 resolves to BCE 1", | ||
| "bce", 1); | ||
|
|
||
| const ce1n = Temporal.PlainYearMonth.from({ era: "ce", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| ce1n, | ||
| -1, 1, "M01", "CE -1 resolves to BCE 2", | ||
| "bce", 2); | ||
|
|
||
| const bce0 = Temporal.PlainYearMonth.from({ era: "bce", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| bce0, | ||
| 1, 1, "M01", "BCE 0 resolves to CE 1", | ||
| "ce", 1); | ||
|
|
||
| const bce1n = Temporal.PlainYearMonth.from({ era: "bce", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| bce1n, | ||
| 2, 1, "M01", "BCE -1 resolves to CE 2", | ||
| "ce", 2); |
36 changes: 36 additions & 0 deletions
36
test/intl402/Temporal/PlainYearMonth/from/era-boundary-islamic-civil.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (C) 2025 Igalia, S.L. All rights reserved. | ||
| // This code is governed by the BSD license found in the LICENSE file. | ||
|
|
||
| /*--- | ||
| esid: sec-temporal.plainyearmonth.from | ||
| description: Non-positive era years are remapped in islamic-civil calendar | ||
| includes: [temporalHelpers.js] | ||
| features: [Temporal, Intl.Era-monthcode] | ||
| ---*/ | ||
|
|
||
| const calendar = "islamic-civil"; | ||
| const options = { overflow: "reject" }; | ||
|
|
||
| const ah0 = Temporal.PlainYearMonth.from({ era: "ah", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| ah0, | ||
| 0, 1, "M01", "AH 0 resolves to BH 1", | ||
| "bh", 1, null); | ||
|
|
||
| const ah1n = Temporal.PlainYearMonth.from({ era: "ah", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| ah1n, | ||
| -1, 1, "M01", "AH -1 resolves to BH 2", | ||
| "bh", 2, null); | ||
|
|
||
| const bh0 = Temporal.PlainYearMonth.from({ era: "bh", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| bh0, | ||
| 1, 1, "M01", "BH 0 resolves to AH 1", | ||
| "ah", 1, null); | ||
|
|
||
| const bh1n = Temporal.PlainYearMonth.from({ era: "bh", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| bh1n, | ||
| 2, 1, "M01", "BH -1 resolves to AH 2", | ||
| "ah", 2, null); |
36 changes: 36 additions & 0 deletions
36
test/intl402/Temporal/PlainYearMonth/from/era-boundary-islamic-tbla.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (C) 2025 Igalia, S.L. All rights reserved. | ||
| // This code is governed by the BSD license found in the LICENSE file. | ||
|
|
||
| /*--- | ||
| esid: sec-temporal.plainyearmonth.from | ||
| description: Non-positive era years are remapped in islamic-tbla calendar | ||
| includes: [temporalHelpers.js] | ||
| features: [Temporal, Intl.Era-monthcode] | ||
| ---*/ | ||
|
|
||
| const calendar = "islamic-tbla"; | ||
| const options = { overflow: "reject" }; | ||
|
|
||
| const ah0 = Temporal.PlainYearMonth.from({ era: "ah", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| ah0, | ||
| 0, 1, "M01", "AH 0 resolves to BH 1", | ||
| "bh", 1, null); | ||
|
|
||
| const ah1n = Temporal.PlainYearMonth.from({ era: "ah", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| ah1n, | ||
| -1, 1, "M01", "AH -1 resolves to BH 2", | ||
| "bh", 2, null); | ||
|
|
||
| const bh0 = Temporal.PlainYearMonth.from({ era: "bh", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| bh0, | ||
| 1, 1, "M01", "BH 0 resolves to AH 1", | ||
| "ah", 1, null); | ||
|
|
||
| const bh1n = Temporal.PlainYearMonth.from({ era: "bh", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| bh1n, | ||
| 2, 1, "M01", "BH -1 resolves to AH 2", | ||
| "ah", 2, null); |
36 changes: 36 additions & 0 deletions
36
test/intl402/Temporal/PlainYearMonth/from/era-boundary-islamic-umalqura.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| // Copyright (C) 2025 Igalia, S.L. All rights reserved. | ||
| // This code is governed by the BSD license found in the LICENSE file. | ||
|
|
||
| /*--- | ||
| esid: sec-temporal.plainyearmonth.from | ||
| description: Non-positive era years are remapped in islamic-umalqura calendar | ||
| includes: [temporalHelpers.js] | ||
| features: [Temporal, Intl.Era-monthcode] | ||
| ---*/ | ||
|
|
||
| const calendar = "islamic-umalqura"; | ||
| const options = { overflow: "reject" }; | ||
|
|
||
| const ah0 = Temporal.PlainYearMonth.from({ era: "ah", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| ah0, | ||
| 0, 1, "M01", "AH 0 resolves to BH 1", | ||
| "bh", 1, null); | ||
|
|
||
| const ah1n = Temporal.PlainYearMonth.from({ era: "ah", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| ah1n, | ||
| -1, 1, "M01", "AH -1 resolves to BH 2", | ||
| "bh", 2, null); | ||
|
|
||
| const bh0 = Temporal.PlainYearMonth.from({ era: "bh", eraYear: 0, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| bh0, | ||
| 1, 1, "M01", "BH 0 resolves to AH 1", | ||
| "ah", 1, null); | ||
|
|
||
| const bh1n = Temporal.PlainYearMonth.from({ era: "bh", eraYear: -1, monthCode: "M01", calendar }, options); | ||
| TemporalHelpers.assertPlainYearMonth( | ||
| bh1n, | ||
| 2, 1, "M01", "BH -1 resolves to AH 2", | ||
| "ah", 2, null); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.