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 coverage for parsing calendars from time strings

Add two sets of tests:
* One for calling withCalendar() with a bare time string (this should
succeed and default to 'iso8601')
* One for calling withCalendar() with a time string that has a calendar
annotation (this should use the calendar annotation from the string).

authored by

Tim Chevalier and committed by
Ms2ger
ab6166fb 08770b4f

+273
+57
vendor/git/test262/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-time-string.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.prototype.withcalendar 6 + description: A time string is valid input for Calendar; default is iso8601 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const tests = [ 11 + "15:23", 12 + "15:23:30", 13 + "15:23:30.123", 14 + "15:23:30.123456", 15 + "15:23:30.123456789", 16 + "1976-11-18T15:23:30.1", 17 + "1976-11-18T15:23:30.12", 18 + "1976-11-18T15:23:30.123", 19 + "1976-11-18T15:23:30.1234", 20 + "1976-11-18T15:23:30.12345", 21 + "1976-11-18T15:23:30.123456", 22 + "1976-11-18T15:23:30.1234567", 23 + "1976-11-18T15:23:30.12345678", 24 + "1976-11-18T15:23:30.123456789", 25 + "1976-11-18T15:23:30,12", 26 + "1976-11-18T15:23:30.12-02:00", 27 + "152330", 28 + "152330.1", 29 + "152330-08", 30 + "152330.1-08", 31 + "152330-0800", 32 + "152330.1-0800", 33 + "1976-11-18T152330.1+00:00", 34 + "19761118T15:23:30.1+00:00", 35 + "1976-11-18T15:23:30.1+0000", 36 + "1976-11-18T152330.1+0000", 37 + "19761118T15:23:30.1+0000", 38 + "19761118T152330.1+00:00", 39 + "19761118T152330.1+0000", 40 + "+001976-11-18T152330.1+00:00", 41 + "+0019761118T15:23:30.1+00:00", 42 + "+001976-11-18T15:23:30.1+0000", 43 + "+001976-11-18T152330.1+0000", 44 + "+0019761118T15:23:30.1+0000", 45 + "+0019761118T152330.1+00:00", 46 + "+0019761118T152330.1+0000", 47 + "15", 48 + "T15:23:30", 49 + "t152330", 50 + ]; 51 + 52 + const instance = Temporal.PlainDate.from({ year: 1976, month: 11, day: 18}); 53 + 54 + tests.forEach((arg) => { 55 + const result = instance.withCalendar(arg); 56 + assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); 57 + });
+57
vendor/git/test262/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-time-string.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.prototype.withcalendar 6 + description: A time string is valid input for Calendar; default is iso8601 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const tests = [ 11 + "15:23", 12 + "15:23:30", 13 + "15:23:30.123", 14 + "15:23:30.123456", 15 + "15:23:30.123456789", 16 + "1976-11-18T15:23:30.1", 17 + "1976-11-18T15:23:30.12", 18 + "1976-11-18T15:23:30.123", 19 + "1976-11-18T15:23:30.1234", 20 + "1976-11-18T15:23:30.12345", 21 + "1976-11-18T15:23:30.123456", 22 + "1976-11-18T15:23:30.1234567", 23 + "1976-11-18T15:23:30.12345678", 24 + "1976-11-18T15:23:30.123456789", 25 + "1976-11-18T15:23:30,12", 26 + "1976-11-18T15:23:30.12-02:00", 27 + "152330", 28 + "152330.1", 29 + "152330-08", 30 + "152330.1-08", 31 + "152330-0800", 32 + "152330.1-0800", 33 + "1976-11-18T152330.1+00:00", 34 + "19761118T15:23:30.1+00:00", 35 + "1976-11-18T15:23:30.1+0000", 36 + "1976-11-18T152330.1+0000", 37 + "19761118T15:23:30.1+0000", 38 + "19761118T152330.1+00:00", 39 + "19761118T152330.1+0000", 40 + "+001976-11-18T152330.1+00:00", 41 + "+0019761118T15:23:30.1+00:00", 42 + "+001976-11-18T15:23:30.1+0000", 43 + "+001976-11-18T152330.1+0000", 44 + "+0019761118T15:23:30.1+0000", 45 + "+0019761118T152330.1+00:00", 46 + "+0019761118T152330.1+0000", 47 + "15", 48 + "T15:23:30", 49 + "t152330", 50 + ]; 51 + 52 + const instance = Temporal.PlainDateTime.from({ year: 1976, month: 11, day: 18, hour: 12, minute: 34}); 53 + 54 + tests.forEach((arg) => { 55 + const result = instance.withCalendar(arg); 56 + assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); 57 + });
+57
vendor/git/test262/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-time-string.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.prototype.withcalendar 6 + description: A time string is valid input for Calendar; default is iso8601 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const tests = [ 11 + "15:23", 12 + "15:23:30", 13 + "15:23:30.123", 14 + "15:23:30.123456", 15 + "15:23:30.123456789", 16 + "1976-11-18T15:23:30.1", 17 + "1976-11-18T15:23:30.12", 18 + "1976-11-18T15:23:30.123", 19 + "1976-11-18T15:23:30.1234", 20 + "1976-11-18T15:23:30.12345", 21 + "1976-11-18T15:23:30.123456", 22 + "1976-11-18T15:23:30.1234567", 23 + "1976-11-18T15:23:30.12345678", 24 + "1976-11-18T15:23:30.123456789", 25 + "1976-11-18T15:23:30,12", 26 + "1976-11-18T15:23:30.12-02:00", 27 + "152330", 28 + "152330.1", 29 + "152330-08", 30 + "152330.1-08", 31 + "152330-0800", 32 + "152330.1-0800", 33 + "1976-11-18T152330.1+00:00", 34 + "19761118T15:23:30.1+00:00", 35 + "1976-11-18T15:23:30.1+0000", 36 + "1976-11-18T152330.1+0000", 37 + "19761118T15:23:30.1+0000", 38 + "19761118T152330.1+00:00", 39 + "19761118T152330.1+0000", 40 + "+001976-11-18T152330.1+00:00", 41 + "+0019761118T15:23:30.1+00:00", 42 + "+001976-11-18T15:23:30.1+0000", 43 + "+001976-11-18T152330.1+0000", 44 + "+0019761118T15:23:30.1+0000", 45 + "+0019761118T152330.1+00:00", 46 + "+0019761118T152330.1+0000", 47 + "15", 48 + "T15:23:30", 49 + "t152330", 50 + ]; 51 + 52 + const instance = Temporal.ZonedDateTime.from({ year: 1976, month: 11, day: 18, hour: 12, minute: 34, timeZone: "UTC"}); 53 + 54 + tests.forEach((arg) => { 55 + const result = instance.withCalendar(arg); 56 + assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); 57 + });
+34
vendor/git/test262/test/intl402/Temporal/PlainDate/prototype/withCalendar/calendar-time-string.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.prototype.withcalendar 6 + description: A time string is valid input for Calendar 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const instance = Temporal.PlainDate.from({ year: 1976, month: 11, day: 18}); 11 + 12 + const calendars = [ 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 + "japanese", 26 + "persian", 27 + "roc", 28 + ] 29 + 30 + calendars.forEach((cal) => { 31 + const str = `T11:30[u-ca=${cal}]`; 32 + const result = instance.withCalendar(str); 33 + assert.sameValue(result.calendarId, cal, `Calendar created from string "${str}"`); 34 + });
+34
vendor/git/test262/test/intl402/Temporal/PlainDateTime/prototype/withCalendar/calendar-time-string.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.prototype.withcalendar 6 + description: A time string is valid input for Calendar 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const instance = Temporal.PlainDateTime.from({ year: 1976, month: 11, day: 18, hour: 12, minute: 34}); 11 + 12 + const calendars = [ 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 + "japanese", 26 + "persian", 27 + "roc", 28 + ] 29 + 30 + calendars.forEach((cal) => { 31 + const str = `T11:30[u-ca=${cal}]`; 32 + const result = instance.withCalendar(str); 33 + assert.sameValue(result.calendarId, cal, `Calendar created from string "${str}"`); 34 + });
+34
vendor/git/test262/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/calendar-time-string.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.prototype.withcalendar 6 + description: A time string is valid input for Calendar 7 + features: [Temporal] 8 + ---*/ 9 + 10 + const instance = Temporal.ZonedDateTime.from({ year: 1976, month: 11, day: 18, hour: 12, minute: 34, timeZone: "UTC"}); 11 + 12 + const calendars = [ 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 + "japanese", 26 + "persian", 27 + "roc", 28 + ] 29 + 30 + calendars.forEach((cal) => { 31 + const str = `T11:30[u-ca=${cal}]`; 32 + const result = instance.withCalendar(str); 33 + assert.sameValue(result.calendarId, cal, `Calendar created from string "${str}"`); 34 + });