My working unpac space for OCaml projects in development
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[Temporal] Add tests for invalid eras

Add tests for `from` methods checking that invalid eras are rejected with
calendars that have eras, and are ignored with calendars that don't have eras.

authored by

Tim Chevalier and committed by
Ms2ger
3fc3fb74 1555390e

+126
+42
vendor/git/test262/test/intl402/Temporal/PlainDate/from/calendar-invalid-era.js
··· 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.plaindate.from 6 + description: RangeError thrown if era is invalid for this calendar 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const calendarsWithEras = [ 11 + "buddhist", 12 + "coptic", 13 + "ethioaa", 14 + "ethiopic", 15 + "gregory", 16 + "hebrew", 17 + "indian", 18 + "islamic-civil", 19 + "islamic-tbla", 20 + "islamic-umalqura", 21 + "japanese", 22 + "persian", 23 + "roc", 24 + ]; 25 + 26 + const calendarsWithoutEras = [ 27 + "chinese", 28 + "dangi", 29 + ]; 30 + 31 + calendarsWithEras.forEach((calendar) => { 32 + // "xyz" is not a valid era in any supported calendar 33 + assert.throws(RangeError, 34 + () => Temporal.PlainDate.from({ year: 2025, month: 1, day: 1, era: "xyz", eraYear: 2025, calendar }), 35 + `xyz is not a valid era in calendar ${calendar}`); 36 + }); 37 + 38 + calendarsWithoutEras.forEach((calendar) => { 39 + // era is ignored 40 + const result = Temporal.PlainDate.from({ year: 2025, month: 1, day: 1, era: "xyz", eraYear: 2025, calendar }); 41 + assert.sameValue(result instanceof Temporal.PlainDate, true, `era should be ignored for calendar ${calendar}`); 42 + });
+42
vendor/git/test262/test/intl402/Temporal/PlainDateTime/from/calendar-invalid-era.js
··· 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.plaindatetime.from 6 + description: RangeError thrown if era is invalid for this calendar 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const calendarsWithEras = [ 11 + "buddhist", 12 + "coptic", 13 + "ethioaa", 14 + "ethiopic", 15 + "gregory", 16 + "hebrew", 17 + "indian", 18 + "islamic-civil", 19 + "islamic-tbla", 20 + "islamic-umalqura", 21 + "japanese", 22 + "persian", 23 + "roc", 24 + ]; 25 + 26 + const calendarsWithoutEras = [ 27 + "chinese", 28 + "dangi", 29 + ]; 30 + 31 + calendarsWithEras.forEach((calendar) => { 32 + // "xyz" is not a valid era in any supported calendar 33 + assert.throws(RangeError, 34 + () => Temporal.PlainDateTime.from({ year: 2025, month: 1, day: 1, hour: 12, minute: 34, era: "xyz", eraYear: 2025, calendar }), 35 + `xyz is not a valid era in calendar ${calendar}`); 36 + }); 37 + 38 + calendarsWithoutEras.forEach((calendar) => { 39 + // era is ignored 40 + const result = Temporal.PlainDateTime.from({ year: 2025, month: 1, day: 1, hour: 12, minute: 34, era: "xyz", eraYear: 2025, calendar }); 41 + assert.sameValue(result instanceof Temporal.PlainDateTime, true, `era should be ignored for calendar ${calendar}`); 42 + });
+42
vendor/git/test262/test/intl402/Temporal/ZonedDateTime/from/calendar-invalid-era.js
··· 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.zoneddatetime.from 6 + description: RangeError thrown if era is invalid for this calendar 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const calendarsWithEras = [ 11 + "buddhist", 12 + "coptic", 13 + "ethioaa", 14 + "ethiopic", 15 + "gregory", 16 + "hebrew", 17 + "indian", 18 + "islamic-civil", 19 + "islamic-tbla", 20 + "islamic-umalqura", 21 + "japanese", 22 + "persian", 23 + "roc", 24 + ]; 25 + 26 + const calendarsWithoutEras = [ 27 + "chinese", 28 + "dangi", 29 + ]; 30 + 31 + calendarsWithEras.forEach((calendar) => { 32 + // "xyz" is not a valid era in any supported calendar 33 + assert.throws(RangeError, 34 + () => Temporal.ZonedDateTime.from({ year: 2025, month: 1, day: 1, hour: 12, minute: 34, timeZone: "UTC", era: "xyz", eraYear: 2025, calendar }), 35 + `xyz is not a valid era in calendar ${calendar}`); 36 + }); 37 + 38 + calendarsWithoutEras.forEach((calendar) => { 39 + // era is ignored 40 + const result = Temporal.ZonedDateTime.from({ year: 2025, month: 1, day: 1, hour: 12, minute: 34, timeZone: "UTC", era: "xyz", eraYear: 2025, calendar }); 41 + assert.sameValue(result instanceof Temporal.ZonedDateTime, true, `era should be ignored for calendar ${calendar}`); 42 + });