diff --git a/harness/temporalHelpers.js b/harness/temporalHelpers.js index 4fe2ca12585..d7860f3573c 100644 --- a/harness/temporalHelpers.js +++ b/harness/temporalHelpers.js @@ -178,8 +178,8 @@ var TemporalHelpers = { assert(actual instanceof Temporal.PlainDateTime, `${prefix}instanceof`); assert(actual.equals(expected), `${prefix}equals method`); assert.sameValue( - actual.getISOFields().calendar, - expected.getISOFields().calendar, + actual.calendarId, + expected.calendarId, `${prefix}calendar same value:` ); }, @@ -197,7 +197,8 @@ var TemporalHelpers = { assert(monthDay instanceof Temporal.PlainMonthDay, `${prefix}instanceof`); assert.sameValue(monthDay.monthCode, monthCode, `${prefix}monthCode result:`); assert.sameValue(monthDay.day, day, `${prefix}day result:`); - assert.sameValue(monthDay.getISOFields().isoYear, referenceISOYear, `${prefix}referenceISOYear result:`); + const isoYear = Number(monthDay.toString({ calendarName: "always" }).split("-")[0]); + assert.sameValue(isoYear, referenceISOYear, `${prefix}referenceISOYear result:`); }, /* @@ -246,7 +247,8 @@ var TemporalHelpers = { assert.sameValue(yearMonth.year, year, `${prefix}year result:`); assert.sameValue(yearMonth.month, month, `${prefix}month result:`); assert.sameValue(yearMonth.monthCode, monthCode, `${prefix}monthCode result:`); - assert.sameValue(yearMonth.getISOFields().isoDay, referenceISODay, `${prefix}referenceISODay result:`); + const isoDay = Number(yearMonth.toString({ calendarName: "always" }).slice(1).split('-')[2].slice(0, 2)); + assert.sameValue(isoDay, referenceISODay, `${prefix}referenceISODay result:`); }, /* @@ -263,8 +265,8 @@ var TemporalHelpers = { assert(actual.equals(expected), `${prefix}equals method`); assert.sameValue(actual.timeZone, expected.timeZone, `${prefix}time zone same value:`); assert.sameValue( - actual.getISOFields().calendar, - expected.getISOFields().calendar, + actual.calendarId, + expected.calendarId, `${prefix}calendar same value:` ); }, @@ -272,8 +274,7 @@ var TemporalHelpers = { /* * assertUnreachable(description): * - * Helper for asserting that code is not executed. This is useful for - * assertions that methods of user calendars and time zones are not called. + * Helper for asserting that code is not executed. */ assertUnreachable(description) { let message = "This code should not be executed"; @@ -283,48 +284,6 @@ var TemporalHelpers = { throw new Test262Error(message); }, - /* - * checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls): - * - * When an options object with a largestUnit property is synthesized inside - * Temporal and passed to user code such as calendar.dateUntil(), the value of - * the largestUnit property should be in the singular form, even if the input - * was given in the plural form. - * (This doesn't apply when the options object is passed through verbatim.) - * - * func(calendar, largestUnit, index) is the operation under test. It's called - * with an instance of a calendar that keeps track of which largestUnit is - * passed to dateUntil(), each key of expectedLargestUnitCalls in turn, and - * the key's numerical index in case the function needs to generate test data - * based on the index. At the end, the actual values passed to dateUntil() are - * compared with the array values of expectedLargestUnitCalls. - */ - checkCalendarDateUntilLargestUnitSingular(func, expectedLargestUnitCalls) { - const actual = []; - - class DateUntilOptionsCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateUntil(earlier, later, options) { - actual.push(options.largestUnit); - return super.dateUntil(earlier, later, options); - } - - toString() { - return "date-until-options"; - } - } - - const calendar = new DateUntilOptionsCalendar(); - Object.entries(expectedLargestUnitCalls).forEach(([largestUnit, expected], index) => { - func(calendar, largestUnit, index); - assert.compareArray(actual, expected, `largestUnit passed to calendar.dateUntil() for largestUnit ${largestUnit}`); - actual.splice(0); // empty it for the next check - }); - }, - /* * checkPlainDateTimeConversionFastPath(func): * @@ -332,17 +291,15 @@ var TemporalHelpers = { * Temporal.PlainDateTime instance, convert to the desired type by reading the * PlainDateTime's internal slots, rather than calling any getters. * - * func(datetime, calendar) is the actual operation to test, that must + * func(datetime) is the actual operation to test, that must * internally call the abstract operation ToTemporalDate or ToTemporalTime. - * It is passed a Temporal.PlainDateTime instance, as well as the instance's - * calendar object (so that it doesn't have to call the calendar getter itself - * if it wants to make any assertions about the calendar.) + * It is passed a Temporal.PlainDateTime instance. */ checkPlainDateTimeConversionFastPath(func, message = "checkPlainDateTimeConversionFastPath") { const actual = []; const expected = []; - const calendar = new Temporal.Calendar("iso8601"); + const calendar = "iso8601"; const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDateTime.prototype); ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((property) => { @@ -370,7 +327,7 @@ var TemporalHelpers = { }, }); - func(datetime, calendar); + func(datetime); assert.compareArray(actual, expected, `${message}: property getters not called`); }, @@ -811,119 +768,17 @@ var TemporalHelpers = { resultAssertions(result); }, - /* - * Check that any iterable returned from a custom time zone's - * getPossibleInstantsFor() method is exhausted. - * The custom time zone object is passed in to func(). - * expected is an array of strings representing the expected calls to the - * getPossibleInstantsFor() method. The PlainDateTimes that it is called with, - * are compared (using their toString() results) with the array. - */ - checkTimeZonePossibleInstantsIterable(func, expected) { - // A custom time zone that returns an iterable instead of an array from its - // getPossibleInstantsFor() method, and for testing purposes skips - // 00:00-01:00 UTC on January 1, 2030, and repeats 00:00-01:00 UTC+1 on - // January 3, 2030. Otherwise identical to the UTC time zone. - class TimeZonePossibleInstantsIterable extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.getPossibleInstantsForCallCount = 0; - this.getPossibleInstantsForCalledWith = []; - this.getPossibleInstantsForReturns = []; - this.iteratorExhausted = []; - } - - toString() { - return "Custom/Iterable"; - } - - getOffsetNanosecondsFor(instant) { - if (Temporal.Instant.compare(instant, "2030-01-01T00:00Z") >= 0 && - Temporal.Instant.compare(instant, "2030-01-03T01:00Z") < 0) { - return 3600_000_000_000; - } else { - return 0; - } - } - - getPossibleInstantsFor(dateTime) { - this.getPossibleInstantsForCallCount++; - this.getPossibleInstantsForCalledWith.push(dateTime); - - // Fake DST transition - let retval = super.getPossibleInstantsFor(dateTime); - if (dateTime.toPlainDate().equals("2030-01-01") && dateTime.hour === 0) { - retval = []; - } else if (dateTime.toPlainDate().equals("2030-01-03") && dateTime.hour === 0) { - retval.push(retval[0].subtract({ hours: 1 })); - } else if (dateTime.year === 2030 && dateTime.month === 1 && dateTime.day >= 1 && dateTime.day <= 2) { - retval[0] = retval[0].subtract({ hours: 1 }); - } - - this.getPossibleInstantsForReturns.push(retval); - this.iteratorExhausted.push(false); - return { - callIndex: this.getPossibleInstantsForCallCount - 1, - timeZone: this, - *[Symbol.iterator]() { - yield* this.timeZone.getPossibleInstantsForReturns[this.callIndex]; - this.timeZone.iteratorExhausted[this.callIndex] = true; - }, - }; - } - } - - const timeZone = new TimeZonePossibleInstantsIterable(); - func(timeZone); - - assert.sameValue(timeZone.getPossibleInstantsForCallCount, expected.length, "getPossibleInstantsFor() method called correct number of times"); - - for (let index = 0; index < expected.length; index++) { - assert.sameValue(timeZone.getPossibleInstantsForCalledWith[index].toString(), expected[index], "getPossibleInstantsFor() called with expected PlainDateTime"); - assert(timeZone.iteratorExhausted[index], "iterated through the whole iterable"); - } - }, - /* * Check that any calendar-carrying Temporal object has its [[Calendar]] * internal slot read by ToTemporalCalendar, and does not fetch the calendar * by calling getters. - * The custom calendar object is passed in to func() so that it can do its - * own additional assertions involving the calendar if necessary. (Sometimes - * there is nothing to assert as the calendar isn't stored anywhere that can - * be asserted about.) */ checkToTemporalCalendarFastPath(func) { - class CalendarFastPathCheck extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateFromFields(...args) { - return super.dateFromFields(...args).withCalendar(this); - } - - monthDayFromFields(...args) { - const { isoYear, isoMonth, isoDay } = super.monthDayFromFields(...args).getISOFields(); - return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); - } - - yearMonthFromFields(...args) { - const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields(...args).getISOFields(); - return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); - } - - toString() { - return "fast-path-check"; - } - } - const calendar = new CalendarFastPathCheck(); - - const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); - const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); - const plainMonthDay = new Temporal.PlainMonthDay(5, 2, calendar); - const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, calendar); - const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); + const plainDate = new Temporal.PlainDate(2000, 5, 2, "iso8601"); + const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); + const plainMonthDay = new Temporal.PlainMonthDay(5, 2, "iso8601"); + const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, "iso8601"); + const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); [plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((temporalObject) => { const actual = []; @@ -936,7 +791,7 @@ var TemporalHelpers = { }, }); - func(temporalObject, calendar); + func(temporalObject); assert.compareArray(actual, expected, "calendar getter not called"); }); }, @@ -964,8 +819,7 @@ var TemporalHelpers = { const actual = []; const expected = []; - const calendar = new Temporal.Calendar("iso8601"); - const date = new Temporal.PlainDate(2000, 5, 2, calendar); + const date = new Temporal.PlainDate(2000, 5, 2, "iso8601"); const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.PlainDate.prototype); ["year", "month", "monthCode", "day"].forEach((property) => { Object.defineProperty(date, property, { @@ -987,469 +841,14 @@ var TemporalHelpers = { Object.defineProperty(date, "calendar", { get() { actual.push("get calendar"); - return calendar; + return "iso8601"; }, }); - func(date, calendar); + func(date); assert.compareArray(actual, expected, "property getters not called"); }, - /* - * A custom calendar used in prototype pollution checks. Verifies that the - * fromFields methods are always called with a null-prototype fields object. - */ - calendarCheckFieldsPrototypePollution() { - class CalendarCheckFieldsPrototypePollution extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.dateFromFieldsCallCount = 0; - this.yearMonthFromFieldsCallCount = 0; - this.monthDayFromFieldsCallCount = 0; - } - - // toString must remain "iso8601", so that some methods don't throw due to - // incompatible calendars - - dateFromFields(fields, options = {}) { - this.dateFromFieldsCallCount++; - assert.sameValue(Object.getPrototypeOf(fields), null, "dateFromFields should be called with null-prototype fields object"); - return super.dateFromFields(fields, options); - } - - yearMonthFromFields(fields, options = {}) { - this.yearMonthFromFieldsCallCount++; - assert.sameValue(Object.getPrototypeOf(fields), null, "yearMonthFromFields should be called with null-prototype fields object"); - return super.yearMonthFromFields(fields, options); - } - - monthDayFromFields(fields, options = {}) { - this.monthDayFromFieldsCallCount++; - assert.sameValue(Object.getPrototypeOf(fields), null, "monthDayFromFields should be called with null-prototype fields object"); - return super.monthDayFromFields(fields, options); - } - } - - return new CalendarCheckFieldsPrototypePollution(); - }, - - /* - * A custom calendar used in prototype pollution checks. Verifies that the - * mergeFields() method is always called with null-prototype fields objects. - */ - calendarCheckMergeFieldsPrototypePollution() { - class CalendarCheckMergeFieldsPrototypePollution extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.mergeFieldsCallCount = 0; - } - - toString() { - return "merge-fields-null-proto"; - } - - mergeFields(fields, additionalFields) { - this.mergeFieldsCallCount++; - assert.sameValue(Object.getPrototypeOf(fields), null, "mergeFields should be called with null-prototype fields object (first argument)"); - assert.sameValue(Object.getPrototypeOf(additionalFields), null, "mergeFields should be called with null-prototype fields object (second argument)"); - return super.mergeFields(fields, additionalFields); - } - } - - return new CalendarCheckMergeFieldsPrototypePollution(); - }, - - /* - * A custom calendar used in prototype pollution checks. Verifies that methods - * are always called with a null-prototype options object. - */ - calendarCheckOptionsPrototypePollution() { - class CalendarCheckOptionsPrototypePollution extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.yearMonthFromFieldsCallCount = 0; - this.dateUntilCallCount = 0; - } - - toString() { - return "options-null-proto"; - } - - yearMonthFromFields(fields, options) { - this.yearMonthFromFieldsCallCount++; - assert.sameValue(Object.getPrototypeOf(options), null, "yearMonthFromFields should be called with null-prototype options"); - return super.yearMonthFromFields(fields, options); - } - - dateUntil(one, two, options) { - this.dateUntilCallCount++; - assert.sameValue(Object.getPrototypeOf(options), null, "dateUntil should be called with null-prototype options"); - return super.dateUntil(one, two, options); - } - } - - return new CalendarCheckOptionsPrototypePollution(); - }, - - /* - * A custom calendar that asserts its dateAdd() method is called with the - * options parameter having the value undefined. - */ - calendarDateAddUndefinedOptions() { - class CalendarDateAddUndefinedOptions extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.dateAddCallCount = 0; - } - - toString() { - return "dateadd-undef-options"; - } - - dateAdd(date, duration, options) { - this.dateAddCallCount++; - assert.sameValue(options, undefined, "dateAdd shouldn't be called with options"); - return super.dateAdd(date, duration, options); - } - } - return new CalendarDateAddUndefinedOptions(); - }, - - /* - * A custom calendar that asserts its dateAdd() method is called with a - * PlainDate instance. Optionally, it also asserts that the PlainDate instance - * is the specific object `this.specificPlainDate`, if it is set by the - * calling code. - */ - calendarDateAddPlainDateInstance() { - class CalendarDateAddPlainDateInstance extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.dateAddCallCount = 0; - this.specificPlainDate = undefined; - } - - toString() { - return "dateadd-plain-date-instance"; - } - - dateFromFields(...args) { - return super.dateFromFields(...args).withCalendar(this); - } - - dateAdd(date, duration, options) { - this.dateAddCallCount++; - assert(date instanceof Temporal.PlainDate, "dateAdd() should be called with a PlainDate instance"); - if (this.dateAddCallCount === 1 && this.specificPlainDate) { - assert.sameValue(date, this.specificPlainDate, `dateAdd() should be called first with the specific PlainDate instance ${this.specificPlainDate}`); - } - return super.dateAdd(date, duration, options).withCalendar(this); - } - } - return new CalendarDateAddPlainDateInstance(); - }, - - /* - * A custom calendar that returns an iterable instead of an array from its - * fields() method, otherwise identical to the ISO calendar. - */ - calendarFieldsIterable() { - class CalendarFieldsIterable extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.fieldsCallCount = 0; - this.fieldsCalledWith = []; - this.iteratorExhausted = []; - } - - toString() { - return "fields-iterable"; - } - - fields(fieldNames) { - this.fieldsCallCount++; - this.fieldsCalledWith.push(fieldNames.slice()); - this.iteratorExhausted.push(false); - return { - callIndex: this.fieldsCallCount - 1, - calendar: this, - *[Symbol.iterator]() { - yield* this.calendar.fieldsCalledWith[this.callIndex]; - this.calendar.iteratorExhausted[this.callIndex] = true; - }, - }; - } - } - return new CalendarFieldsIterable(); - }, - - /* - * A custom calendar that asserts its ...FromFields() methods are called with - * the options parameter having the value undefined. - */ - calendarFromFieldsUndefinedOptions() { - class CalendarFromFieldsUndefinedOptions extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.dateFromFieldsCallCount = 0; - this.monthDayFromFieldsCallCount = 0; - this.yearMonthFromFieldsCallCount = 0; - } - - toString() { - return "from-fields-undef-options"; - } - - dateFromFields(fields, options) { - this.dateFromFieldsCallCount++; - assert.sameValue(options, undefined, "dateFromFields shouldn't be called with options"); - return super.dateFromFields(fields, options); - } - - yearMonthFromFields(fields, options) { - this.yearMonthFromFieldsCallCount++; - assert.sameValue(options, undefined, "yearMonthFromFields shouldn't be called with options"); - return super.yearMonthFromFields(fields, options); - } - - monthDayFromFields(fields, options) { - this.monthDayFromFieldsCallCount++; - assert.sameValue(options, undefined, "monthDayFromFields shouldn't be called with options"); - return super.monthDayFromFields(fields, options); - } - } - return new CalendarFromFieldsUndefinedOptions(); - }, - - /* - * A custom calendar that modifies the fields object passed in to - * dateFromFields, sabotaging its time properties. - */ - calendarMakeInfinityTime() { - class CalendarMakeInfinityTime extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateFromFields(fields, options) { - const retval = super.dateFromFields(fields, options); - fields.hour = Infinity; - fields.minute = Infinity; - fields.second = Infinity; - fields.millisecond = Infinity; - fields.microsecond = Infinity; - fields.nanosecond = Infinity; - return retval; - } - } - return new CalendarMakeInfinityTime(); - }, - - /* - * A custom calendar that defines getters on the fields object passed into - * dateFromFields that throw, sabotaging its time properties. - */ - calendarMakeInvalidGettersTime() { - class CalendarMakeInvalidGettersTime extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateFromFields(fields, options) { - const retval = super.dateFromFields(fields, options); - const throwingDescriptor = { - get() { - throw new Test262Error("reading a sabotaged time field"); - }, - }; - Object.defineProperties(fields, { - hour: throwingDescriptor, - minute: throwingDescriptor, - second: throwingDescriptor, - millisecond: throwingDescriptor, - microsecond: throwingDescriptor, - nanosecond: throwingDescriptor, - }); - return retval; - } - } - return new CalendarMakeInvalidGettersTime(); - }, - - /* - * A custom calendar whose mergeFields() method returns a proxy object with - * all of its Get and HasProperty operations observable, as well as adding a - * "shouldNotBeCopied": true property. - */ - calendarMergeFieldsGetters() { - class CalendarMergeFieldsGetters extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.mergeFieldsReturnOperations = []; - } - - toString() { - return "merge-fields-getters"; - } - - dateFromFields(fields, options) { - assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); - return super.dateFromFields(fields, options); - } - - yearMonthFromFields(fields, options) { - assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); - return super.yearMonthFromFields(fields, options); - } - - monthDayFromFields(fields, options) { - assert.sameValue(fields.shouldNotBeCopied, undefined, "extra fields should not be copied"); - return super.monthDayFromFields(fields, options); - } - - mergeFields(fields, additionalFields) { - const retval = super.mergeFields(fields, additionalFields); - retval._calendar = this; - retval.shouldNotBeCopied = true; - return new Proxy(retval, { - get(target, key) { - target._calendar.mergeFieldsReturnOperations.push(`get ${key}`); - const result = target[key]; - if (result === undefined) { - return undefined; - } - return TemporalHelpers.toPrimitiveObserver(target._calendar.mergeFieldsReturnOperations, result, key); - }, - has(target, key) { - target._calendar.mergeFieldsReturnOperations.push(`has ${key}`); - return key in target; - }, - }); - } - } - return new CalendarMergeFieldsGetters(); - }, - - /* - * A custom calendar whose mergeFields() method returns a primitive value, - * given by @primitive, and which records the number of calls made to its - * dateFromFields(), yearMonthFromFields(), and monthDayFromFields() methods. - */ - calendarMergeFieldsReturnsPrimitive(primitive) { - class CalendarMergeFieldsPrimitive extends Temporal.Calendar { - constructor(mergeFieldsReturnValue) { - super("iso8601"); - this._mergeFieldsReturnValue = mergeFieldsReturnValue; - this.dateFromFieldsCallCount = 0; - this.monthDayFromFieldsCallCount = 0; - this.yearMonthFromFieldsCallCount = 0; - } - - toString() { - return "merge-fields-primitive"; - } - - dateFromFields(fields, options) { - this.dateFromFieldsCallCount++; - return super.dateFromFields(fields, options); - } - - yearMonthFromFields(fields, options) { - this.yearMonthFromFieldsCallCount++; - return super.yearMonthFromFields(fields, options); - } - - monthDayFromFields(fields, options) { - this.monthDayFromFieldsCallCount++; - return super.monthDayFromFields(fields, options); - } - - mergeFields() { - return this._mergeFieldsReturnValue; - } - } - return new CalendarMergeFieldsPrimitive(primitive); - }, - - /* - * A custom calendar whose fields() method returns the same value as the - * iso8601 calendar, with the addition of extraFields provided as parameter. - */ - calendarWithExtraFields(fields) { - class CalendarWithExtraFields extends Temporal.Calendar { - constructor(extraFields) { - super("iso8601"); - this._extraFields = extraFields; - } - - fields(fieldNames) { - return super.fields(fieldNames).concat(this._extraFields); - } - } - - return new CalendarWithExtraFields(fields); - }, - - /* - * crossDateLineTimeZone(): - * - * This returns an instance of a custom time zone class that implements one - * single transition where the time zone moves from one side of the - * International Date Line to the other, for the purpose of testing time zone - * calculations without depending on system time zone data. - * - * The transition occurs at epoch second 1325239200 and goes from offset - * -10:00 to +14:00. In other words, the time zone skips the whole calendar - * day of 2011-12-30. This is the same as the real-life transition in the - * Pacific/Apia time zone. - */ - crossDateLineTimeZone() { - const { compare } = Temporal.PlainDate; - const skippedDay = new Temporal.PlainDate(2011, 12, 30); - const transitionEpoch = 1325239200_000_000_000n; - const beforeOffset = new Temporal.TimeZone("-10:00"); - const afterOffset = new Temporal.TimeZone("+14:00"); - - class CrossDateLineTimeZone extends Temporal.TimeZone { - constructor() { - super("+14:00"); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < transitionEpoch) { - return beforeOffset.getOffsetNanosecondsFor(instant); - } - return afterOffset.getOffsetNanosecondsFor(instant); - } - - getPossibleInstantsFor(datetime) { - const comparison = compare(datetime.toPlainDate(), skippedDay); - if (comparison === 0) { - return []; - } - if (comparison < 0) { - return [beforeOffset.getInstantFor(datetime)]; - } - return [afterOffset.getInstantFor(datetime)]; - } - - getPreviousTransition(instant) { - if (instant.epochNanoseconds > transitionEpoch) return new Temporal.Instant(transitionEpoch); - return null; - } - - getNextTransition(instant) { - if (instant.epochNanoseconds < transitionEpoch) return new Temporal.Instant(transitionEpoch); - return null; - } - - toString() { - return "Custom/Date_Line"; - } - } - return new CrossDateLineTimeZone(); - }, - /* * observeProperty(calls, object, propertyName, value): * @@ -1514,265 +913,6 @@ var TemporalHelpers = { }; }, - /* - * calendarObserver: - * A custom calendar that behaves exactly like the ISO 8601 calendar but - * tracks calls to any of its methods, and Get/Has operations on its - * properties, by appending messages to an array. This is for the purpose of - * testing order of operations that are observable from user code. - * objectName is used in the log. - */ - calendarObserver(calls, objectName, methodOverrides = {}) { - function removeExtraHasPropertyChecks(objectName, calls) { - // Inserting the tracking calendar into the return values of methods - // that we chain up into the ISO calendar for, causes extra HasProperty - // checks, which we observe. This removes them so that we don't leak - // implementation details of the helper into the test code. - assert.sameValue(calls.pop(), `has ${objectName}.yearOfWeek`); - assert.sameValue(calls.pop(), `has ${objectName}.yearMonthFromFields`); - assert.sameValue(calls.pop(), `has ${objectName}.year`); - assert.sameValue(calls.pop(), `has ${objectName}.weekOfYear`); - assert.sameValue(calls.pop(), `has ${objectName}.monthsInYear`); - assert.sameValue(calls.pop(), `has ${objectName}.monthDayFromFields`); - assert.sameValue(calls.pop(), `has ${objectName}.monthCode`); - assert.sameValue(calls.pop(), `has ${objectName}.month`); - assert.sameValue(calls.pop(), `has ${objectName}.mergeFields`); - assert.sameValue(calls.pop(), `has ${objectName}.inLeapYear`); - assert.sameValue(calls.pop(), `has ${objectName}.id`); - assert.sameValue(calls.pop(), `has ${objectName}.fields`); - assert.sameValue(calls.pop(), `has ${objectName}.daysInYear`); - assert.sameValue(calls.pop(), `has ${objectName}.daysInWeek`); - assert.sameValue(calls.pop(), `has ${objectName}.daysInMonth`); - assert.sameValue(calls.pop(), `has ${objectName}.dayOfYear`); - assert.sameValue(calls.pop(), `has ${objectName}.dayOfWeek`); - assert.sameValue(calls.pop(), `has ${objectName}.day`); - assert.sameValue(calls.pop(), `has ${objectName}.dateUntil`); - assert.sameValue(calls.pop(), `has ${objectName}.dateFromFields`); - assert.sameValue(calls.pop(), `has ${objectName}.dateAdd`); - } - - const iso8601 = new Temporal.Calendar("iso8601"); - const trackingMethods = { - dateFromFields(...args) { - calls.push(`call ${objectName}.dateFromFields`); - if ('dateFromFields' in methodOverrides) { - const value = methodOverrides.dateFromFields; - return typeof value === "function" ? value(...args) : value; - } - const originalResult = iso8601.dateFromFields(...args); - // Replace the calendar in the result with the call-tracking calendar - const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); - const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); - removeExtraHasPropertyChecks(objectName, calls); - return result; - }, - yearMonthFromFields(...args) { - calls.push(`call ${objectName}.yearMonthFromFields`); - if ('yearMonthFromFields' in methodOverrides) { - const value = methodOverrides.yearMonthFromFields; - return typeof value === "function" ? value(...args) : value; - } - const originalResult = iso8601.yearMonthFromFields(...args); - // Replace the calendar in the result with the call-tracking calendar - const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); - const result = new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); - removeExtraHasPropertyChecks(objectName, calls); - return result; - }, - monthDayFromFields(...args) { - calls.push(`call ${objectName}.monthDayFromFields`); - if ('monthDayFromFields' in methodOverrides) { - const value = methodOverrides.monthDayFromFields; - return typeof value === "function" ? value(...args) : value; - } - const originalResult = iso8601.monthDayFromFields(...args); - // Replace the calendar in the result with the call-tracking calendar - const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); - const result = new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); - removeExtraHasPropertyChecks(objectName, calls); - return result; - }, - dateAdd(...args) { - calls.push(`call ${objectName}.dateAdd`); - if ('dateAdd' in methodOverrides) { - const value = methodOverrides.dateAdd; - return typeof value === "function" ? value(...args) : value; - } - const originalResult = iso8601.dateAdd(...args); - const {isoYear, isoMonth, isoDay} = originalResult.getISOFields(); - const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this); - removeExtraHasPropertyChecks(objectName, calls); - return result; - }, - id: "iso8601", - }; - // Automatically generate the other methods that don't need any custom code - [ - "dateUntil", - "day", - "dayOfWeek", - "dayOfYear", - "daysInMonth", - "daysInWeek", - "daysInYear", - "era", - "eraYear", - "fields", - "inLeapYear", - "mergeFields", - "month", - "monthCode", - "monthsInYear", - "toString", - "weekOfYear", - "year", - "yearOfWeek", - ].forEach((methodName) => { - trackingMethods[methodName] = function (...args) { - calls.push(`call ${formatPropertyName(methodName, objectName)}`); - if (methodName in methodOverrides) { - const value = methodOverrides[methodName]; - return typeof value === "function" ? value(...args) : value; - } - return iso8601[methodName](...args); - }; - }); - return new Proxy(trackingMethods, { - get(target, key, receiver) { - const result = Reflect.get(target, key, receiver); - calls.push(`get ${formatPropertyName(key, objectName)}`); - return result; - }, - has(target, key) { - calls.push(`has ${formatPropertyName(key, objectName)}`); - return Reflect.has(target, key); - }, - }); - }, - - /* - * A custom calendar that does not allow any of its methods to be called, for - * the purpose of asserting that a particular operation does not call into - * user code. - */ - calendarThrowEverything() { - class CalendarThrowEverything extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - toString() { - TemporalHelpers.assertUnreachable("toString should not be called"); - } - dateFromFields() { - TemporalHelpers.assertUnreachable("dateFromFields should not be called"); - } - yearMonthFromFields() { - TemporalHelpers.assertUnreachable("yearMonthFromFields should not be called"); - } - monthDayFromFields() { - TemporalHelpers.assertUnreachable("monthDayFromFields should not be called"); - } - dateAdd() { - TemporalHelpers.assertUnreachable("dateAdd should not be called"); - } - dateUntil() { - TemporalHelpers.assertUnreachable("dateUntil should not be called"); - } - era() { - TemporalHelpers.assertUnreachable("era should not be called"); - } - eraYear() { - TemporalHelpers.assertUnreachable("eraYear should not be called"); - } - year() { - TemporalHelpers.assertUnreachable("year should not be called"); - } - month() { - TemporalHelpers.assertUnreachable("month should not be called"); - } - monthCode() { - TemporalHelpers.assertUnreachable("monthCode should not be called"); - } - day() { - TemporalHelpers.assertUnreachable("day should not be called"); - } - fields() { - TemporalHelpers.assertUnreachable("fields should not be called"); - } - mergeFields() { - TemporalHelpers.assertUnreachable("mergeFields should not be called"); - } - } - - return new CalendarThrowEverything(); - }, - - /* - * oneShiftTimeZone(shiftInstant, shiftNanoseconds): - * - * In the case of a spring-forward time zone offset transition (skipped time), - * and disambiguation === 'earlier', BuiltinTimeZoneGetInstantFor subtracts a - * negative number of nanoseconds from a PlainDateTime, which should balance - * with the microseconds field. - * - * This returns an instance of a custom time zone class which skips a length - * of time equal to shiftNanoseconds (a number), at the Temporal.Instant - * shiftInstant. Before shiftInstant, it's identical to UTC, and after - * shiftInstant it's a constant-offset time zone. - * - * It provides a getPossibleInstantsForCalledWith member which is an array - * with the result of calling toString() on any PlainDateTimes passed to - * getPossibleInstantsFor(). - */ - oneShiftTimeZone(shiftInstant, shiftNanoseconds) { - class OneShiftTimeZone extends Temporal.TimeZone { - constructor(shiftInstant, shiftNanoseconds) { - super("+00:00"); - this._shiftInstant = shiftInstant; - this._epoch1 = shiftInstant.epochNanoseconds; - this._epoch2 = this._epoch1 + BigInt(shiftNanoseconds); - this._shiftNanoseconds = shiftNanoseconds; - this._shift = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, this._shiftNanoseconds); - this.getPossibleInstantsForCalledWith = []; - } - - _isBeforeShift(instant) { - return instant.epochNanoseconds < this._epoch1; - } - - getOffsetNanosecondsFor(instant) { - return this._isBeforeShift(instant) ? 0 : this._shiftNanoseconds; - } - - getPossibleInstantsFor(plainDateTime) { - this.getPossibleInstantsForCalledWith.push(plainDateTime.toString({ calendarName: "never" })); - const [instant] = super.getPossibleInstantsFor(plainDateTime); - if (this._shiftNanoseconds > 0) { - if (this._isBeforeShift(instant)) return [instant]; - if (instant.epochNanoseconds < this._epoch2) return []; - return [instant.subtract(this._shift)]; - } - if (instant.epochNanoseconds < this._epoch2) return [instant]; - const shifted = instant.subtract(this._shift); - if (this._isBeforeShift(instant)) return [instant, shifted]; - return [shifted]; - } - - getNextTransition(instant) { - return this._isBeforeShift(instant) ? this._shiftInstant : null; - } - - getPreviousTransition(instant) { - return this._isBeforeShift(instant) ? null : this._shiftInstant; - } - - toString() { - return "Custom/One_Shift"; - } - } - return new OneShiftTimeZone(shiftInstant, shiftNanoseconds); - }, - /* * propertyBagObserver(): * Returns an object that behaves like the given propertyBag but tracks Get @@ -1783,8 +923,11 @@ var TemporalHelpers = { * and valueOf methods in the same array. This is for the purpose of testing * order of operations that are observable from user code. objectName is used * in the log. + * If skipToPrimitive is given, it must be an array of property keys. Those + * properties will not have a TemporalHelpers.toPrimitiveObserver returned, + * and instead just be returned directly. */ - propertyBagObserver(calls, propertyBag, objectName) { + propertyBagObserver(calls, propertyBag, objectName, skipToPrimitive) { return new Proxy(propertyBag, { ownKeys(target) { calls.push(`ownKeys ${objectName}`); @@ -1803,153 +946,10 @@ var TemporalHelpers = { if ((result !== null && typeof result === "object") || typeof result === "function") { return result; } - return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`); - }, - has(target, key) { - calls.push(`has ${formatPropertyName(key, objectName)}`); - return Reflect.has(target, key); - }, - }); - }, - - /* - * specificOffsetTimeZone(): - * - * This returns an instance of a custom time zone class, which returns a - * specific custom value from its getOffsetNanosecondsFrom() method. This is - * for the purpose of testing the validation of what this method returns. - * - * It also returns an empty array from getPossibleInstantsFor(), so as to - * trigger calls to getOffsetNanosecondsFor() when used from the - * BuiltinTimeZoneGetInstantFor operation. - */ - specificOffsetTimeZone(offsetValue) { - class SpecificOffsetTimeZone extends Temporal.TimeZone { - constructor(offsetValue) { - super("UTC"); - this._offsetValue = offsetValue; - } - - getOffsetNanosecondsFor() { - return this._offsetValue; - } - - getPossibleInstantsFor(dt) { - if (typeof this._offsetValue !== 'number' || Math.abs(this._offsetValue) >= 86400e9 || isNaN(this._offsetValue)) return []; - const zdt = dt.toZonedDateTime("UTC").add({ nanoseconds: -this._offsetValue }); - return [zdt.toInstant()]; - } - - get id() { - return this.getOffsetStringFor(new Temporal.Instant(0n)); - } - } - return new SpecificOffsetTimeZone(offsetValue); - }, - - /* - * springForwardFallBackTimeZone(): - * - * This returns an instance of a custom time zone class that implements one - * single spring-forward/fall-back transition, for the purpose of testing the - * disambiguation option, without depending on system time zone data. - * - * The spring-forward occurs at epoch second 954669600 (2000-04-02T02:00 - * local) and goes from offset -08:00 to -07:00. - * - * The fall-back occurs at epoch second 972810000 (2000-10-29T02:00 local) and - * goes from offset -07:00 to -08:00. - */ - springForwardFallBackTimeZone() { - const { compare } = Temporal.PlainDateTime; - const springForwardLocal = new Temporal.PlainDateTime(2000, 4, 2, 2); - const springForwardEpoch = 954669600_000_000_000n; - const fallBackLocal = new Temporal.PlainDateTime(2000, 10, 29, 1); - const fallBackEpoch = 972810000_000_000_000n; - const winterOffset = new Temporal.TimeZone('-08:00'); - const summerOffset = new Temporal.TimeZone('-07:00'); - - class SpringForwardFallBackTimeZone extends Temporal.TimeZone { - constructor() { - super("-08:00"); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < springForwardEpoch || - instant.epochNanoseconds >= fallBackEpoch) { - return winterOffset.getOffsetNanosecondsFor(instant); - } - return summerOffset.getOffsetNanosecondsFor(instant); - } - - getPossibleInstantsFor(datetime) { - if (compare(datetime, springForwardLocal) >= 0 && compare(datetime, springForwardLocal.add({ hours: 1 })) < 0) { - return []; - } - if (compare(datetime, fallBackLocal) >= 0 && compare(datetime, fallBackLocal.add({ hours: 1 })) < 0) { - return [summerOffset.getInstantFor(datetime), winterOffset.getInstantFor(datetime)]; - } - if (compare(datetime, springForwardLocal) < 0 || compare(datetime, fallBackLocal) >= 0) { - return [winterOffset.getInstantFor(datetime)]; - } - return [summerOffset.getInstantFor(datetime)]; - } - - getPreviousTransition(instant) { - if (instant.epochNanoseconds > fallBackEpoch) return new Temporal.Instant(fallBackEpoch); - if (instant.epochNanoseconds > springForwardEpoch) return new Temporal.Instant(springForwardEpoch); - return null; - } - - getNextTransition(instant) { - if (instant.epochNanoseconds < springForwardEpoch) return new Temporal.Instant(springForwardEpoch); - if (instant.epochNanoseconds < fallBackEpoch) return new Temporal.Instant(fallBackEpoch); - return null; - } - - get id() { - return "Custom/Spring_Fall"; - } - - toString() { - return "Custom/Spring_Fall"; - } - } - return new SpringForwardFallBackTimeZone(); - }, - - /* - * timeZoneObserver: - * A custom calendar that behaves exactly like the UTC time zone but tracks - * calls to any of its methods, and Get/Has operations on its properties, by - * appending messages to an array. This is for the purpose of testing order of - * operations that are observable from user code. objectName is used in the - * log. methodOverrides is an optional object containing properties with the - * same name as Temporal.TimeZone methods. If the property value is a function - * it will be called with the proper arguments instead of the UTC method. - * Otherwise, the property value will be returned directly. - */ - timeZoneObserver(calls, objectName, methodOverrides = {}) { - const utc = new Temporal.TimeZone("UTC"); - const trackingMethods = { - id: "UTC", - }; - // Automatically generate the methods - ["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => { - trackingMethods[methodName] = function (...args) { - calls.push(`call ${formatPropertyName(methodName, objectName)}`); - if (methodName in methodOverrides) { - const value = methodOverrides[methodName]; - return typeof value === "function" ? value(...args) : value; + if (skipToPrimitive && skipToPrimitive.indexOf(key) >= 0) { + return result; } - return utc[methodName](...args); - }; - }); - return new Proxy(trackingMethods, { - get(target, key, receiver) { - const result = Reflect.get(target, key, receiver); - calls.push(`get ${formatPropertyName(key, objectName)}`); - return result; + return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`); }, has(target, key) { calls.push(`has ${formatPropertyName(key, objectName)}`); @@ -1958,30 +958,6 @@ var TemporalHelpers = { }); }, - /* - * A custom time zone that does not allow any of its methods to be called, for - * the purpose of asserting that a particular operation does not call into - * user code. - */ - timeZoneThrowEverything() { - class TimeZoneThrowEverything extends Temporal.TimeZone { - constructor() { - super("UTC"); - } - getOffsetNanosecondsFor() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be called"); - } - getPossibleInstantsFor() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be called"); - } - toString() { - TemporalHelpers.assertUnreachable("toString should not be called"); - } - } - - return new TimeZoneThrowEverything(); - }, - /* * Returns an object that will append logs of any Gets or Calls of its valueOf * or toString properties to the array calls. Both valueOf and toString will diff --git a/test/built-ins/Temporal/Calendar/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/argument-wrong-type.js deleted file mode 100644 index f4fc7c41792..00000000000 --- a/test/built-ins/Temporal/Calendar/argument-wrong-type.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar -description: RangeError thrown when constructor invoked with the wrong type -features: [Temporal] ----*/ - -const tests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], - [Symbol(), "symbol"], - [{}, "object not implementing any protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.ZonedDateTime.from("2020-01-01T00:00Z[UTC]"), "ZonedDateTime instance"], -]; - -for (const [arg, description] of tests) { - assert.throws( - typeof (arg) === "string" ? RangeError : TypeError, - () => new Temporal.Calendar(arg), - `${description} is not accepted by this constructor` - ); -} diff --git a/test/built-ins/Temporal/Calendar/builtin.js b/test/built-ins/Temporal/Calendar/builtin.js deleted file mode 100644 index f77ec2bfd5e..00000000000 --- a/test/built-ins/Temporal/Calendar/builtin.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar -description: Tests that Temporal.Calendar meets the requirements for built-in objects -info: | - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar), - Function.prototype, "prototype"); - -assert.sameValue(typeof Temporal.Calendar.prototype, - "object", "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/constructor.js b/test/built-ins/Temporal/Calendar/constructor.js deleted file mode 100644 index 5221ae4b855..00000000000 --- a/test/built-ins/Temporal/Calendar/constructor.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar -description: Temporal.Calendar constructor cannot be called as a function -info: | - 1. If NewTarget is undefined, throw a TypeError exception. -features: [Temporal] ----*/ - -assert.throws(TypeError, () => Temporal.Calendar("iso8601")); diff --git a/test/built-ins/Temporal/Calendar/from/builtin.js b/test/built-ins/Temporal/Calendar/from/builtin.js deleted file mode 100644 index 4345b708d68..00000000000 --- a/test/built-ins/Temporal/Calendar/from/builtin.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Tests that Temporal.Calendar.from meets the requirements for built-in objects -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.from), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.from), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.from), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.from.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/from/calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/from/calendar-case-insensitive.js deleted file mode 100644 index 83b454e62b1..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-case-insensitive.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Calendar names are case-insensitive -features: [Temporal] ----*/ - -const arg = "iSo8601"; - -const result = Temporal.Calendar.from(arg); -assert.sameValue(result.id, "iso8601", "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/from/calendar-iso-string.js b/test/built-ins/Temporal/Calendar/from/calendar-iso-string.js deleted file mode 100644 index b7793d7875f..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-iso-string.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -for (const arg of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const result = Temporal.Calendar.from(arg); - assert.sameValue(result.id, "iso8601", `Calendar created from string "${arg}"`); -} diff --git a/test/built-ins/Temporal/Calendar/from/calendar-number.js b/test/built-ins/Temporal/Calendar/from/calendar-number.js deleted file mode 100644 index aefa45255a2..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-number.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: A number is not allowed to be a calendar -features: [Temporal] ----*/ - -const numbers = [ - 1, - -19761118, - 19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => Temporal.Calendar.from(arg), - "A number is not a valid ISO string for Calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/from/calendar-object.js b/test/built-ins/Temporal/Calendar/from/calendar-object.js deleted file mode 100644 index c63e94ebc2b..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-object.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: > - Converting an object implementing the Calendar protocol to Temporal.Calendar - gives the same object -features: [Temporal] ----*/ - -const custom = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "custom-calendar", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert.sameValue(Temporal.Calendar.from(custom), custom); diff --git a/test/built-ins/Temporal/Calendar/from/calendar-string-builtin.js b/test/built-ins/Temporal/Calendar/from/calendar-string-builtin.js deleted file mode 100644 index f830c814fd9..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-string-builtin.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Calendar.from should support iso8601. -features: [Temporal] ----*/ - -const tests = [ - "iso8601", - "1994-11-05T08:15:30-05:00", -]; - -for (const item of tests) { - const calendar = Temporal.Calendar.from(item); - assert(calendar instanceof Temporal.Calendar); - assert.sameValue(calendar.id, "iso8601"); -} diff --git a/test/built-ins/Temporal/Calendar/from/calendar-string-leap-second.js b/test/built-ins/Temporal/Calendar/from/calendar-string-leap-second.js deleted file mode 100644 index 4164b0c8abf..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-string-leap-second.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Leap second is a valid ISO string for Calendar -features: [Temporal] ----*/ - -const arg = "2016-12-31T23:59:60"; -const result = Temporal.Calendar.from(arg); -assert.sameValue( - result.id, - "iso8601", - "leap second is a valid ISO string for Calendar" -); diff --git a/test/built-ins/Temporal/Calendar/from/calendar-string-not-builtin.js b/test/built-ins/Temporal/Calendar/from/calendar-string-not-builtin.js deleted file mode 100644 index c8f7a601d7c..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-string-not-builtin.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: from() throws if the argument is not a built-in calendar name. -features: [Temporal] ----*/ - -const tests = [ - "local", - "iso-8601", - "[u-ca=iso8601]", - "invalid-calendar", -]; - -for (const item of tests) { - assert.throws(RangeError, () => Temporal.Calendar.from(item)); -} diff --git a/test/built-ins/Temporal/Calendar/from/calendar-string.js b/test/built-ins/Temporal/Calendar/from/calendar-string.js deleted file mode 100644 index fbc7d5fe675..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-string.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const arg = "iso8601"; - -const result = Temporal.Calendar.from(arg); -assert.sameValue(result.id, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/Calendar/from/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/from/calendar-temporal-object.js deleted file mode 100644 index 10c09d3c486..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-temporal-object.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const result = Temporal.Calendar.from(arg); - assert.sameValue(result.id, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/Calendar/from/calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/from/calendar-wrong-type.js deleted file mode 100644 index b2d24a7831d..00000000000 --- a/test/built-ins/Temporal/Calendar/from/calendar-wrong-type.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar -features: [BigInt, Symbol, Temporal] ----*/ - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => Temporal.Calendar.from(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => Temporal.Calendar.from(arg), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/from/length.js b/test/built-ins/Temporal/Calendar/from/length.js deleted file mode 100644 index 154ba81099a..00000000000 --- a/test/built-ins/Temporal/Calendar/from/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Temporal.Calendar.from.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.from, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/from/name.js b/test/built-ins/Temporal/Calendar/from/name.js deleted file mode 100644 index 16c0f551697..00000000000 --- a/test/built-ins/Temporal/Calendar/from/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Temporal.Calendar.from.name is "from" -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.from, "name", { - value: "from", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/from/not-a-constructor.js b/test/built-ins/Temporal/Calendar/from/not-a-constructor.js deleted file mode 100644 index 01266cddc8d..00000000000 --- a/test/built-ins/Temporal/Calendar/from/not-a-constructor.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Temporal.Calendar.from does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.from(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.from), false, - "isConstructor(Temporal.Calendar.from)"); diff --git a/test/built-ins/Temporal/Calendar/from/prop-desc.js b/test/built-ins/Temporal/Calendar/from/prop-desc.js deleted file mode 100644 index 53ae121c6ca..00000000000 --- a/test/built-ins/Temporal/Calendar/from/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: The "from" property of Temporal.Calendar -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.from, - "function", - "`typeof Calendar.from` is `function`" -); - -verifyProperty(Temporal.Calendar, "from", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/from/subclassing-ignored.js b/test/built-ins/Temporal/Calendar/from/subclassing-ignored.js deleted file mode 100644 index 738afa1fd29..00000000000 --- a/test/built-ins/Temporal/Calendar/from/subclassing-ignored.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: The receiver is never called when calling from() -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkSubclassingIgnoredStatic( - Temporal.Calendar, - "from", - ["iso8601"], - (result) => { - assert.sameValue(result.id, "iso8601", "id property of result"); - assert.sameValue(result.toString(), "iso8601", "toString() of result"); - }, -); diff --git a/test/built-ins/Temporal/Calendar/length.js b/test/built-ins/Temporal/Calendar/length.js deleted file mode 100644 index 0c3c834213e..00000000000 --- a/test/built-ins/Temporal/Calendar/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar -description: Temporal.Calendar.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/missing-arguments.js b/test/built-ins/Temporal/Calendar/missing-arguments.js deleted file mode 100644 index a35ab3f8d1a..00000000000 --- a/test/built-ins/Temporal/Calendar/missing-arguments.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar -description: RangeError thrown when constructor invoked with no argument -features: [Temporal] ----*/ - -assert.throws(TypeError, () => new Temporal.Calendar()); -assert.throws(TypeError, () => new Temporal.Calendar(undefined)); diff --git a/test/built-ins/Temporal/Calendar/name.js b/test/built-ins/Temporal/Calendar/name.js deleted file mode 100644 index 9ea1492e0d2..00000000000 --- a/test/built-ins/Temporal/Calendar/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar -description: Temporal.Calendar.name is "Calendar" -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar, "name", { - value: "Calendar", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prop-desc.js b/test/built-ins/Temporal/Calendar/prop-desc.js deleted file mode 100644 index fbb298626a5..00000000000 --- a/test/built-ins/Temporal/Calendar/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar -description: The "Calendar" property of Temporal -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar, - "function", - "`typeof Calendar` is `function`" -); - -verifyProperty(Temporal, "Calendar", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/constructor.js b/test/built-ins/Temporal/Calendar/prototype/constructor.js deleted file mode 100644 index 78996f296cd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/constructor.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.constructor -description: Test for Temporal.Calendar.prototype.constructor. -info: The initial value of Temporal.Calendar.prototype.constructor is %Temporal.Calendar%. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype, "constructor", { - value: Temporal.Calendar, - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-days.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-days.js deleted file mode 100644 index 2577b67362a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-days.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd add duration with days and calculate correctly.. -info: | - 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let p10d = new Temporal.Duration(0,0,0,10); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-07-16", p10d), 2021, 7, "M07", 26, - "add 10 days and result into the same month"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-07-26", p10d), 2021, 8, "M08", 5, - "add 10 days and result into next month"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-12-26", p10d), 2022, 1, "M01", 5, - "add 10 days and result into next year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-26", p10d), 2020, 3, "M03", 7, - "add 10 days from a leap year in Feb and result into March"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-26", p10d), 2021, 3, "M03", 8, - "add 10 days from a non leap year in Feb and result into March"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-19", p10d), 2020, 2, "M02", 29, - "add 10 days from a leap year in Feb 19 and result into Feb 29"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-19", p10d), 2021, 3, "M03", 1, - "add 10 days from a non leap year in Feb 19 and result into March 1"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-months-weeks.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-months-weeks.js deleted file mode 100644 index 6f54afa2755..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-months-weeks.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd add duration with months and weeks and calculate correctly. -info: | - 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let p2m3w = new Temporal.Duration(0,2,3); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-29", p2m3w), 2020, 5, "M05", 20, - "add two months 3 weeks from Feb 29 of a leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-28", p2m3w), 2020, 5, "M05", 19, - "add two months 3 weeks from Feb 28 of a leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-28", p2m3w), 2021, 5, "M05", 19, - "add two months 3 weeks from Feb 28 of a non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-12-28", p2m3w), 2021, 3, "M03", 21, - "add two months 3 weeks from end of year to non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2019-12-28", p2m3w), 2020, 3, "M03", 20, - "add two months 3 weeks from end of year to leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2019-10-28", p2m3w), 2020, 1, "M01", 18, - "add two months 3 weeks and cause roll into a new year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2019-10-31", p2m3w), 2020, 1, "M01", 21, - "add two months 3 weeks and cause roll into a new year"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-months.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-months.js deleted file mode 100644 index 8c765d64564..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-months.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd add duration with months and calculate correctly -info: | - 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let p5m = new Temporal.Duration(0, 5); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-07-16", p5m), 2021, 12, "M12", 16, - "add five months and result in the same year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-08-16", p5m), 2022, 1, "M01", 16, - "add five months and result in the next year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-10-31", p5m), 2022, 3, "M03", 31, - "add five months and result in the next year in end of month"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2019-10-01", p5m), 2020, 3, "M03", 1, - "add five months and result in the next year in end of month on leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-09-30", p5m), 2022, 2, "M02", 28, - "add five months and result in the nexdt year and constrain to Feb 28"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2019-09-30", p5m), 2020, 2, "M02", 29, - "add five months and result in the nexdt year and constrain to Feb 29 on leap year"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-weeks-days.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-weeks-days.js deleted file mode 100644 index 1af689ec741..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-weeks-days.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd add duration with weeks and days and calculate correctly. -info: | - 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let p2w3d = new Temporal.Duration(0,0,2,3); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-29", p2w3d), 2020, 3, "M03", 17, - "add 2 weeks and 3 days (17 days) from Feb 29 in a leap year and cause rolling into March"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-28", p2w3d), 2021, 3, "M03", 17, - "add 2 weeks and 3 days (17 days) from Feb and cause rolling into March in a non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-28", p2w3d), 2020, 3, "M03", 16, - "add 2 weeks and 3 days (17 days) from Feb and cause rolling into March in a leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-12-28", p2w3d), 2021, 1, "M01", 14, - "add 2 weeks and 3 days (17 days) and cause rolling into a new year"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-weeks.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-weeks.js deleted file mode 100644 index 797778e098a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-weeks.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd add duration with weeks and calculate correctly. -info: | - 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let p1w = new Temporal.Duration(0,0,1); -let p6w = new Temporal.Duration(0,0,6); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-19", p1w), 2021, 2, "M02", 26, - "add one week in Feb"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-27", p1w), 2021, 3, "M03", 6, - "add one week in Feb and result in March"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-27", p1w), 2020, 3, "M03", 5, - "add one week in Feb and result in March in a leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-12-24", p1w), 2021, 12, "M12", 31, - "add one week and result in the last day of a year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-12-25", p1w), 2022, 1, "M01", 1, - "add one week and result in the first day of next year"); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-01-27", p1w), 2021, 2, "M02", 3, - "add one week and result in next month from a month with 31 days"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-06-27", p1w), 2021, 7, "M07", 4, - "add one week and result in next month from a month with 30 days"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-07-27", p1w), 2021, 8, "M08", 3, - "add one week and result in next month from a month with 31 days"); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-19", p6w), 2021, 4, "M04", 2, - "add six weeks and result in next month from Feb in a non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-19", p6w), 2020, 4, "M04", 1, - "add six weeks and result in next month from Feb in a leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-12-24", p6w), 2022, 2, "M02", 4, - "add six weeks and result in the next year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-01-27", p6w), 2021, 3, "M03", 10, - "add six weeks and result in the same year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-01-27", p6w), 2020, 3, "M03", 9, - "add six weeks and result in the same year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-06-27", p6w), 2021, 8, "M08", 8, - "add six weeks and result in the same year crossing month of 30 and 31 days"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-07-27", p6w), 2021, 9, "M09", 7, - "add six weeks and result in the same year crossing month of 31 and 31 days"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years-months-days.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years-months-days.js deleted file mode 100644 index a8c2e5cb38b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years-months-days.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd add duration with years, months and days and calculate correctly. -info: | - 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let p1y2m4d = new Temporal.Duration(1,2,0,4); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-07-16", p1y2m4d), 2022, 9, "M09", 20, - "add one year two months and 4 days"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-27", p1y2m4d), 2022, 5, "M05", 1, - "add one year two months and 4 days and roll into new month from a month of 30 days"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-01-28", p1y2m4d), 2022, 4, "M04", 1, - "add one year two months and 4 days and roll into new month from a month of 31 days"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-26", p1y2m4d), 2022, 4, "M04", 30, - "add one year two months and 4 days which roll from March to April in a non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2023-02-26", p1y2m4d), 2024, 4, "M04", 30, - "add one year two months and 4 days which roll from March to April in a leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-12-30", p1y2m4d), 2023, 3, "M03", 4, - "add one year two months and 4 days which roll month into new year and roll day into March in non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2022-12-30", p1y2m4d), 2024, 3, "M03", 4, - "add one year two months and 4 days which roll month into new year and roll day into March in leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2022-12-29", p1y2m4d), 2024, 3, "M03", 4, - "add one year two months and 4 days which roll month into new year and roll day into March in leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-07-30", p1y2m4d), 2022, 10, "M10", 4, - "add one year two months and 4 days which roll into a new month from a month with 30 days"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-06-30", p1y2m4d), 2022, 9, "M09", 3, - "add one year two months and 4 days which roll into a new month from a month with 31 days"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years-months.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years-months.js deleted file mode 100644 index e7b44995503..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years-months.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd add duration with years and months and calculate correctly. -info: | - 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let p1y2m = new Temporal.Duration(1,2); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-07-16", p1y2m), 2022, 9, "M09", 16, - "add one year and 2 months"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-11-30", p1y2m), 2023, 1, "M01", 30, - "add one year and 2 months roll into a new year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-12-31", p1y2m), 2023, 2, "M02", 28, - "add one year and 2 months roll into a new year and constrain in Feb 28 of a non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2022-12-31", p1y2m), 2024, 2, "M02", 29, - "add one year and 2 months roll into a new year and constrain in Feb 29 of a leap year"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years-weeks.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years-weeks.js deleted file mode 100644 index 5152a1c3c2e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years-weeks.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd add duration with years and weeks and calculate correctly. -info: | - 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let p1y2w = new Temporal.Duration(1,0,2); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-28", p1y2w), 2021, 3, "M03", 14, - "add 1 year and 2 weeks to Feb 28 and cause roll into March in a non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-29", p1y2w), 2021, 3, "M03", 14, - "add 1 year and 2 weeks to Feb 29 and cause roll into March in a non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2019-02-28", p1y2w), 2020, 3, "M03", 13, - "add 1 year and 2 weeks to Feb 28 and cause roll into March in a leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-02-28", p1y2w), 2022, 3, "M03", 14, - "add 1 year and 2 weeks to Feb 28 and cause roll into March in a non leap year"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-12-28", p1y2w), 2022, 1, "M01", 11, - "add 1 year and 2 weeks and cause roll into a new year"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years.js deleted file mode 100644 index c9c44246dad..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/add-years.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd add duration with years only calculate correctly. -info: | - 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let p1y = new Temporal.Duration(1); -let p4y = new Temporal.Duration(4); - -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-29", p1y), 2021, 2, "M02", 28, - "add one year on Feb 29"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2020-02-29", p4y), 2024, 2, "M02", 29, - "add four years on Feb 29"); -TemporalHelpers.assertPlainDate( - cal.dateAdd("2021-07-16", p1y), 2022, 7, "M07", 16, - "add one year on other date"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 5cd7c345005..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.dateAdd(arg, new Temporal.Duration()); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index f2db284eaf3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.dateAdd(arg, new Temporal.Duration()); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 40aa916bd87..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration())); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duplicate-calendar-fields.js deleted file mode 100644 index c22b5c53c99..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration())); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duration-max.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duration-max.js deleted file mode 100644 index 06424afb30b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duration-max.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Maximum allowed duration -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const maxCases = [ - ["P273790Y8M12DT23H59M59.999999999S", "string with max years"], - [{ years: 273790, months: 8, days: 12, nanoseconds: 86399999999999 }, "property bag with max years"], - ["P3285488M12DT23H59M59.999999999S", "string with max months"], - [{ months: 3285488, days: 12, nanoseconds: 86399999999999 }, "property bag with max months"], - ["P14285714W2DT23H59M59.999999999S", "string with max weeks"], - [{ weeks: 14285714, days: 2, nanoseconds: 86399999999999 }, "property bag with max weeks"], - ["P100000000DT23H59M59.999999999S", "string with max days"], - [{ days: 100000000, nanoseconds: 86399999999999 }, "property bag with max days"], - ["PT2400000023H59M59.999999999S", "string with max hours"], - [{ hours: 2400000023, nanoseconds: 3599999999999 }, "property bag with max hours"], - ["PT144000001439M59.999999999S", "string with max minutes"], - [{ minutes: 144000001439, nanoseconds: 59999999999 }, "property bag with max minutes"], - ["PT8640000086399.999999999S", "string with max seconds"], - [{ seconds: 8640000086399, nanoseconds: 999999999 }, "property bag with max seconds"], -]; - -for (const [arg, descr] of maxCases) { - const result = instance.dateAdd(new Temporal.PlainDate(1970, 1, 1), arg); - TemporalHelpers.assertPlainDate(result, 275760, 9, "M09", 13, `operation succeeds with ${descr}`); -} - -const minCases = [ - ["-P273790Y8M12DT23H59M59.999999999S", "string with min years"], - [{ years: -273790, months: -8, days: -12, nanoseconds: -86399999999999 }, "property bag with min years"], - ["-P3285488M12DT23H59M59.999999999S", "string with min months"], - [{ months: -3285488, days: -12, nanoseconds: -86399999999999 }, "property bag with min months"], - ["-P14285714W3DT23H59M59.999999999S", "string with min weeks"], - [{ weeks: -14285714, days: -3, nanoseconds: -86399999999999 }, "property bag with min weeks"], - ["-P100000001DT23H59M59.999999999S", "string with min days"], - [{ days: -100000001, nanoseconds: -86399999999999 }, "property bag with min days"], - ["-PT2400000047H59M59.999999999S", "string with min hours"], - [{ hours: -2400000047, nanoseconds: -3599999999999 }, "property bag with min hours"], - ["-PT144000002879M59.999999999S", "string with min minutes"], - [{ minutes: -144000002879, nanoseconds: -59999999999 }, "property bag with min minutes"], - ["-PT8640000172799.999999999S", "string with min seconds"], - [{ seconds: -8640000172799, nanoseconds: -999999999 }, "property bag with min seconds"], -]; - -for (const [arg, descr] of minCases) { - const result = instance.dateAdd(new Temporal.PlainDate(1970, 1, 1), arg); - TemporalHelpers.assertPlainDate(result, -271821, 4, "M04", 19, `operation succeeds with ${descr}`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duration-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duration-out-of-range.js deleted file mode 100644 index 28fcdf1cb98..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duration-out-of-range.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Duration-like argument that is out of range -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const cases = [ - // 2^32 = 4294967296 - ["P4294967296Y", "string with years > max"], - [{ years: 4294967296 }, "property bag with years > max"], - ["-P4294967296Y", "string with years < min"], - [{ years: -4294967296 }, "property bag with years < min"], - ["P4294967296M", "string with months > max"], - [{ months: 4294967296 }, "property bag with months > max"], - ["-P4294967296M", "string with months < min"], - [{ months: -4294967296 }, "property bag with months < min"], - ["P4294967296W", "string with weeks > max"], - [{ weeks: 4294967296 }, "property bag with weeks > max"], - ["-P4294967296W", "string with weeks < min"], - [{ weeks: -4294967296 }, "property bag with weeks < min"], - - // ceil(max safe integer / 86400) = 104249991375 - ["P104249991375D", "string with days > max"], - [{ days: 104249991375 }, "property bag with days > max"], - ["P104249991374DT24H", "string where hours balance into days > max"], - [{ days: 104249991374, hours: 24 }, "property bag where hours balance into days > max"], - ["-P104249991375D", "string with days < min"], - [{ days: -104249991375 }, "property bag with days < min"], - ["-P104249991374DT24H", "string where hours balance into days < min"], - [{ days: -104249991374, hours: -24 }, "property bag where hours balance into days < min"], - - // ceil(max safe integer / 3600) = 2501999792984 - ["PT2501999792984H", "string with hours > max"], - [{ hours: 2501999792984 }, "property bag with hours > max"], - ["PT2501999792983H60M", "string where minutes balance into hours > max"], - [{ hours: 2501999792983, minutes: 60 }, "property bag where minutes balance into hours > max"], - ["-PT2501999792984H", "string with hours < min"], - [{ hours: -2501999792984 }, "property bag with hours < min"], - ["-PT2501999792983H60M", "string where minutes balance into hours < min"], - [{ hours: -2501999792983, minutes: -60 }, "property bag where minutes balance into hours < min"], - - // ceil(max safe integer / 60) = 150119987579017 - ["PT150119987579017M", "string with minutes > max"], - [{ minutes: 150119987579017 }, "property bag with minutes > max"], - ["PT150119987579016M60S", "string where seconds balance into minutes > max"], - [{ minutes: 150119987579016, seconds: 60 }, "property bag where seconds balance into minutes > max"], - ["-PT150119987579017M", "string with minutes < min"], - [{ minutes: -150119987579017 }, "property bag with minutes < min"], - ["-PT150119987579016M60S", "string where seconds balance into minutes < min"], - [{ minutes: -150119987579016, seconds: -60 }, "property bag where seconds balance into minutes < min"], - - // 2^53 = 9007199254740992 - ["PT9007199254740992S", "string with seconds > max"], - [{ seconds: 9007199254740992 }, "property bag with seconds > max"], - [{ seconds: 9007199254740991, milliseconds: 1000 }, "property bag where milliseconds balance into seconds > max"], - [{ seconds: 9007199254740991, microseconds: 1000000 }, "property bag where microseconds balance into seconds > max"], - [{ seconds: 9007199254740991, nanoseconds: 1000000000 }, "property bag where nanoseconds balance into seconds > max"], - ["-PT9007199254740992S", "string with seconds < min"], - [{ seconds: -9007199254740992 }, "property bag with seconds < min"], - [{ seconds: -9007199254740991, milliseconds: -1000 }, "property bag where milliseconds balance into seconds < min"], - [{ seconds: -9007199254740991, microseconds: -1000000 }, "property bag where microseconds balance into seconds < min"], - [{ seconds: -9007199254740991, nanoseconds: -1000000000 }, "property bag where nanoseconds balance into seconds < min"], -]; - -for (const [arg, descr] of cases) { - assert.throws(RangeError, () => instance.dateAdd(new Temporal.PlainDate(1970, 1, 1), arg), `${descr} is out of range`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duration-years-and-months-number-max-value.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duration-years-and-months-number-max-value.js deleted file mode 100644 index b055cc10c74..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-duration-years-and-months-number-max-value.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - Call BalanceISOYearMonth with 2³² - 1 and -(2³² - 1) for years/months. -info: | - Temporal.Calendar.prototype.dateAdd ( date, duration [ , options ] ) - - ... - 9. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], - duration.[[Years]], duration.[[Months]], duration.[[Weeks]], balanceResult.[[Days]], - overflow). - 10. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). - - AddISODate ( year, month, day, years, months, weeks, days, overflow ) - - ... - 3. Let intermediate be ! BalanceISOYearMonth(year + years, month + months). - ... - -features: [Temporal] ----*/ - -var cal = new Temporal.Calendar("iso8601"); -var date = new Temporal.PlainDate(1970, 1, 1); - -const max = 4294967295; // 2³² - 1 - -var maxValue = new Temporal.Duration(max, max); -var minValue = new Temporal.Duration(-max, -max); - -assert.throws(RangeError, () => cal.dateAdd(date, maxValue), "years/months is +Number.MAX_VALUE"); -assert.throws(RangeError, () => cal.dateAdd(date, minValue), "years/months is -Number.MAX_VALUE"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-leap-second.js deleted file mode 100644 index c1bf52aa358..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-leap-second.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Leap second is a valid ISO string for PlainDate -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.dateAdd(arg, new Temporal.Duration()); -TemporalHelpers.assertPlainDate( - result1, - 2016, 12, "M12", 31, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.dateAdd(arg, new Temporal.Duration()); -TemporalHelpers.assertPlainDate( - result2, - 2016, 12, "M12", 31, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-number.js deleted file mode 100644 index 02f745942db..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-plaindatetime.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-plaindatetime.js deleted file mode 100644 index 9683842c380..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-plaindatetime.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots -info: | - sec-temporal.calendar.prototype.dateadd step 4: - 4. Set _date_ to ? ToTemporalDate(_date_). - sec-temporal-totemporaldate step 2.b: - b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then - i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { - const calendar = new Temporal.Calendar("iso8601"); - const duration = new Temporal.Duration(0, 1); - const result = calendar.dateAdd(datetime, duration); - TemporalHelpers.assertPlainDate(result, 2000, 6, "M06", 2); - assert.sameValue(result.hour, undefined, "instance of PlainDate returned, not PlainDateTime"); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 4f84deeef4b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: The calendar name is case-insensitive -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.dateAdd(arg, new Temporal.Duration()); -TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index f69e45bfac8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: An ISO 8601 string can be converted to a calendar ID in Calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.dateAdd(arg, new Temporal.Duration()); - TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 1813e3082f3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Leap second is a valid ISO string for a calendar in a property bag -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.dateAdd(arg, new Temporal.Duration()); -TemporalHelpers.assertPlainDate( - result, - 1976, 11, "M11", 18, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-number.js deleted file mode 100644 index 3f027c64fd2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-string.js deleted file mode 100644 index 16947d3c8eb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: A calendar ID is valid input for Calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.dateAdd(arg, new Temporal.Duration()); -TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index be4a7935ab8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 300b7d26161..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-proto-in-calendar-fields.js deleted file mode 100644 index 8e8063c04d6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration())); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 718b83c6bd9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation.js deleted file mode 100644 index f1410a3bec4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-calendar-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dateAdd(arg, new Temporal.Duration()); - - TemporalHelpers.assertPlainDate( - result, - 2000, 5, "M05", 2, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-critical-unknown-annotation.js deleted file mode 100644 index f165c8f2ee1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-date-with-utc-offset.js deleted file mode 100644 index d1783d50ca7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: UTC offset not valid with format that does not include a time -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.dateAdd(arg, new Temporal.Duration()); - - TemporalHelpers.assertPlainDate( - result, - 2000, 5, "M05", 2, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-invalid.js deleted file mode 100644 index 44c78a9ee58..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-calendar.js deleted file mode 100644 index a379e8440b4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-time-zone.js deleted file mode 100644 index c7983c88031..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-separators.js deleted file mode 100644 index 909b4ac1fef..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-separators.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Time separator in string argument can vary -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dateAdd(arg, new Temporal.Duration()); - - TemporalHelpers.assertPlainDate( - result, - 2000, 5, "M05", 2, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-zone-annotation.js deleted file mode 100644 index 32e92eb78d5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dateAdd(arg, new Temporal.Duration()); - - TemporalHelpers.assertPlainDate( - result, - 2000, 5, "M05", 2, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-unknown-annotation.js deleted file mode 100644 index d285863cbd5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-unknown-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Various forms of unknown annotation -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dateAdd(arg, new Temporal.Duration()); - - TemporalHelpers.assertPlainDate( - result, - 2000, 5, "M05", 2, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-with-utc-designator.js deleted file mode 100644 index 3d8fdc484a1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-wrong-type.js deleted file mode 100644 index a5730ee91d6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-convert.js deleted file mode 100644 index 66640fe3bf7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.dateAdd(arg, new Temporal.Duration())); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-slots.js deleted file mode 100644 index 81afe45a6c7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.dateAdd(arg, new Temporal.Duration()); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index afa8fda9746..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.dateAdd(datetime, duration)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index fcaa825ac3d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.dateAdd(datetime, duration), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index fd3af5d5518..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.dateAdd(datetime, duration)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index aa2c986058e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.dateAdd(datetime, duration)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/balance-smaller-units.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/balance-smaller-units.js deleted file mode 100644 index c2898cfac4e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/balance-smaller-units.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Durations with units smaller than days are balanced before adding -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const date = new Temporal.PlainDate(2000, 5, 2, calendar); -const duration = new Temporal.Duration(0, 0, 0, 1, 24, 1440, 86400, 86400_000, 86400_000_000, 86400_000_000_000); - -const result = calendar.dateAdd(date, duration); -TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 9, "units smaller than days are balanced"); - -const resultString = calendar.dateAdd(date, "P1DT24H1440M86400S"); -TemporalHelpers.assertPlainDate(resultString, 2000, 5, "M05", 6, "units smaller than days are balanced"); - -const resultPropBag = calendar.dateAdd(date, { days: 1, hours: 24, minutes: 1440, seconds: 86400, milliseconds: 86400_000, microseconds: 86400_000_000, nanoseconds: 86400_000_000_000 }); -TemporalHelpers.assertPlainDate(resultPropBag, 2000, 5, "M05", 9, "units smaller than days are balanced"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/basic.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/basic.js deleted file mode 100644 index c1f8ad510c0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/basic.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Basic tests for dateAdd(). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const date = Temporal.PlainDate.from("1994-11-06"); -const positiveDuration = Temporal.Duration.from({ months: 1, weeks: 1 }); -const negativeDuration = Temporal.Duration.from({ months: -1, weeks: -1 }); - -TemporalHelpers.assertPlainDate( - iso.dateAdd(Temporal.PlainDateTime.from("1994-11-06T08:15:30"), positiveDuration, {}), - 1994, 12, "M12", 13, "date: PlainDateTime"); - -TemporalHelpers.assertPlainDate( - iso.dateAdd({ year: 1994, month: 11, day: 6 }, positiveDuration, {}), - 1994, 12, "M12", 13, "date: property bag"); - -TemporalHelpers.assertPlainDate( - iso.dateAdd("1994-11-06", positiveDuration, {}), - 1994, 12, "M12", 13, "date: string"); - -assert.throws(TypeError, () => iso.dateAdd({ month: 11 }, positiveDuration, {}), "date: missing property"); - -TemporalHelpers.assertPlainDate( - iso.dateAdd(date, { months: 1, weeks: 1 }, {}), - 1994, 12, "M12", 13, "duration: property bag"); - -TemporalHelpers.assertPlainDate( - iso.dateAdd(date, "P1M1W", {}), - 1994, 12, "M12", 13, "duration: string"); - -assert.throws(TypeError, () => iso.dateAdd(date, { month: 1 }, {}), "duration: missing property"); - -TemporalHelpers.assertPlainDate( - iso.dateAdd(Temporal.PlainDateTime.from("1994-11-06T08:15:30"), negativeDuration, {}), - 1994, 9, "M09", 29, "date: PlainDateTime, negative duration"); - -TemporalHelpers.assertPlainDate( - iso.dateAdd({ year: 1994, month: 11, day: 6 }, negativeDuration, {}), - 1994, 9, "M09", 29, "date: property bag, negative duration"); - -TemporalHelpers.assertPlainDate( - iso.dateAdd("1994-11-06", negativeDuration, {}), - 1994, 9, "M09", 29, "date: string, negative duration"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/branding.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/branding.js deleted file mode 100644 index 86a9fb592fd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const dateAdd = Temporal.Calendar.prototype.dateAdd; - -assert.sameValue(typeof dateAdd, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1), new Temporal.Duration(1)]; - -assert.throws(TypeError, () => dateAdd.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => dateAdd.apply(null, args), "null"); -assert.throws(TypeError, () => dateAdd.apply(true, args), "true"); -assert.throws(TypeError, () => dateAdd.apply("", args), "empty string"); -assert.throws(TypeError, () => dateAdd.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => dateAdd.apply(1, args), "1"); -assert.throws(TypeError, () => dateAdd.apply({}, args), "plain object"); -assert.throws(TypeError, () => dateAdd.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => dateAdd.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/builtin.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/builtin.js deleted file mode 100644 index 0d8d3d99603..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - Tests that Temporal.Calendar.prototype.dateAdd - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.dateAdd), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.dateAdd), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.dateAdd), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.dateAdd.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index b76329860a7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.dateAdd({ year: 2000, month: 5, day: 2, calendar }, new Temporal.Duration(1)); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/calendar-fields-iterable.js deleted file mode 100644 index da8453aea57..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.dateadd step 4: - 4. Set _date_ to ? ToTemporalDate(_date_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const duration = new Temporal.Duration(0, 1); -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.dateAdd({ year: 2000, month: 5, day: 2, calendar: calendar2 }, duration); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/calendar-temporal-object.js deleted file mode 100644 index a230867c3df..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/calendar-temporal-object.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.dateadd step 4: - 4. Set _date_ to ? ToTemporalDate(_date_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - const duration = new Temporal.Duration(0, 1); - calendar.dateAdd({ year: 2000, month: 5, day: 2, calendar: temporalObject }, duration); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/date-infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/date-infinity-throws-rangeerror.js deleted file mode 100644 index 4ad162032aa..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/date-infinity-throws-rangeerror.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.dateadd -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const duration = new Temporal.Duration(1); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - ["constrain", "reject"].forEach((overflow) => { - assert.throws(RangeError, () => instance.dateAdd({ ...base, [prop]: inf }, duration, { overflow }), `${prop} property cannot be ${inf} (overflow ${overflow}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.dateAdd({ ...base, [prop]: obj }, duration, { overflow })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/duration-argument-string-negative-fractional-units.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/duration-argument-string-negative-fractional-units.js deleted file mode 100644 index 7fb804b0a6b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/duration-argument-string-negative-fractional-units.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Strings with fractional duration units are treated with the correct sign -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); - -const resultHours = calendar.dateAdd(instance, "-PT24.567890123H"); -TemporalHelpers.assertPlainDate(resultHours, 2000, 5, "M05", 1, "negative fractional hours"); - -const resultMinutes = calendar.dateAdd(instance, "-PT1440.567890123M"); -TemporalHelpers.assertPlainDate(resultMinutes, 2000, 5, "M05", 1, "negative fractional minutes"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/length.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/length.js deleted file mode 100644 index acc31761c77..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd.length is 2 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dateAdd, "length", { - value: 2, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/name.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/name.js deleted file mode 100644 index e4d966254ec..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd.name is "dateAdd". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dateAdd, "name", { - value: "dateAdd", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/not-a-constructor.js deleted file mode 100644 index eb71ff8c00d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: > - Temporal.Calendar.prototype.dateAdd does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.dateAdd(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.dateAdd), false, - "isConstructor(Temporal.Calendar.prototype.dateAdd)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-object.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-object.js deleted file mode 100644 index 3d18ef4cbcb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-object.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Empty or a function object may be used as options -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const result1 = instance.dateAdd(new Temporal.PlainDate(1976, 11, 18), new Temporal.Duration(1), {}); -TemporalHelpers.assertPlainDate( - result1, 1977, 11, "M11", 18, - "options may be an empty plain object" -); - -const result2 = instance.dateAdd(new Temporal.PlainDate(1976, 11, 18), new Temporal.Duration(1), () => {}); -TemporalHelpers.assertPlainDate( - result2, 1977, 11, "M11", 18, - "options may be a function object" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-wrong-type.js deleted file mode 100644 index 8f135256c93..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/options-wrong-type.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: TypeError thrown when options argument is a primitive -features: [BigInt, Symbol, Temporal] ----*/ - -const badOptions = [ - null, - true, - "some string", - Symbol(), - 1, - 2n, -]; - -const instance = new Temporal.Calendar("iso8601"); -for (const value of badOptions) { - assert.throws(TypeError, () => instance.dateAdd(new Temporal.PlainDate(1976, 11, 18), new Temporal.Duration(1), value), - `TypeError on wrong options type ${typeof value}`); -}; diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/order-of-operations.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/order-of-operations.js deleted file mode 100644 index 327e6b87416..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/order-of-operations.js +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Properties on an object passed to dateAdd() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - // ToTemporalDate → GetTemporalCalendarSlotValueWithISODefault - "get date.calendar", - "has date.calendar.dateAdd", - "has date.calendar.dateFromFields", - "has date.calendar.dateUntil", - "has date.calendar.day", - "has date.calendar.dayOfWeek", - "has date.calendar.dayOfYear", - "has date.calendar.daysInMonth", - "has date.calendar.daysInWeek", - "has date.calendar.daysInYear", - "has date.calendar.fields", - "has date.calendar.id", - "has date.calendar.inLeapYear", - "has date.calendar.mergeFields", - "has date.calendar.month", - "has date.calendar.monthCode", - "has date.calendar.monthDayFromFields", - "has date.calendar.monthsInYear", - "has date.calendar.weekOfYear", - "has date.calendar.year", - "has date.calendar.yearMonthFromFields", - "has date.calendar.yearOfWeek", - // lookup - "get date.calendar.dateFromFields", - "get date.calendar.fields", - // ToTemporalDate → CalendarFields - "call date.calendar.fields", - // ToTemporalDate → PrepareTemporalFields - "get date.day", - "get date.day.valueOf", - "call date.day.valueOf", - "get date.month", - "get date.month.valueOf", - "call date.month.valueOf", - "get date.monthCode", - "get date.monthCode.toString", - "call date.monthCode.toString", - "get date.year", - "get date.year.valueOf", - "call date.year.valueOf", - // ToTemporalDate → CalendarDateFromFields - "call date.calendar.dateFromFields", - // ToTemporalDuration - "get duration.days", - "get duration.days.valueOf", - "call duration.days.valueOf", - "get duration.hours", - "get duration.hours.valueOf", - "call duration.hours.valueOf", - "get duration.microseconds", - "get duration.microseconds.valueOf", - "call duration.microseconds.valueOf", - "get duration.milliseconds", - "get duration.milliseconds.valueOf", - "call duration.milliseconds.valueOf", - "get duration.minutes", - "get duration.minutes.valueOf", - "call duration.minutes.valueOf", - "get duration.months", - "get duration.months.valueOf", - "call duration.months.valueOf", - "get duration.nanoseconds", - "get duration.nanoseconds.valueOf", - "call duration.nanoseconds.valueOf", - "get duration.seconds", - "get duration.seconds.valueOf", - "call duration.seconds.valueOf", - "get duration.weeks", - "get duration.weeks.valueOf", - "call duration.weeks.valueOf", - "get duration.years", - "get duration.years.valueOf", - "call duration.years.valueOf", - // ToTemporalOverflow - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; -const actual = []; - -const instance = new Temporal.Calendar("iso8601"); - -const date = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 5, - monthCode: "M05", - day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "date.calendar"), -}, "date"); - -const duration = TemporalHelpers.propertyBagObserver(actual, { - years: 1, - months: 2, - weeks: 3, - days: 4, - hours: 5, - minutes: 6, - seconds: 7, - milliseconds: 8, - microseconds: 9, - nanoseconds: 10, -}, "duration"); - -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); - -instance.dateAdd(date, duration, options); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-invalid-string.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-invalid-string.js deleted file mode 100644 index df173c933f7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-invalid-string.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: RangeError thrown when overflow option not one of the allowed string values -info: | - sec-getoption step 10: - 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal.calendar.prototype.dateadd step 7: - 7. Let _overflow_ be ? ToTemporalOverflow(_options_). -features: [Temporal, arrow-function] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const date = new Temporal.PlainDate(2000, 5, 2, calendar); -const duration = new Temporal.Duration(3, 3, 0, 3); -const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"]; -for (const overflow of badOverflows) { - assert.throws( - RangeError, - () => calendar.dateAdd(date, duration, { overflow }), - `invalid overflow ("${overflow}")` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-undefined.js deleted file mode 100644 index 453093bc579..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-undefined.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Fallback value for overflow option -info: | - sec-getoption step 3: - 3. If _value_ is *undefined*, return _fallback_. - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal.calendar.prototype.dateadd step 7: - 7. Let _overflow_ be ? ToTemporalOverflow(_options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const date = new Temporal.PlainDate(2000, 5, 31, calendar); -const duration = new Temporal.Duration(3, 1); - -const explicit = calendar.dateAdd(date, duration, { overflow: undefined }); -TemporalHelpers.assertPlainDate(explicit, 2003, 6, "M06", 30, "default overflow is constrain"); -const implicit = calendar.dateAdd(date, duration, {}); -TemporalHelpers.assertPlainDate(implicit, 2003, 6, "M06", 30, "default overflow is constrain"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-wrong-type.js deleted file mode 100644 index 945a720f253..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/overflow-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Type conversions for overflow option -info: | - sec-getoption step 9.a: - a. Set _value_ to ? ToString(_value_). - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal.calendar.prototype.dateadd step 7: - 7. Let _overflow_ be ? ToTemporalOverflow(_options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const date = new Temporal.PlainDate(2000, 5, 2, calendar); -const duration = new Temporal.Duration(3, 3, 0, 3); -TemporalHelpers.checkStringOptionWrongType("overflow", "constrain", - (overflow) => calendar.dateAdd(date, duration, { overflow }), - (result, descr) => TemporalHelpers.assertPlainDate(result, 2003, 8, "M08", 5, descr), -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/prop-desc.js deleted file mode 100644 index 6ae28e706aa..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: The "dateAdd" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.dateAdd, - "function", - "`typeof Calendar.prototype.dateAdd` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "dateAdd", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDate.js deleted file mode 100644 index f48f6bba5a4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDate.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd should throw from ToTemporalDate. -info: | - ... - 4. Set date to ? ToTemporalDate(date). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, - () => cal.dateAdd("invalid date string", new Temporal.Duration(1)), - 'cal.dateAdd("invalid date string", new Temporal.Duration(1)) throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDuration.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDuration.js deleted file mode 100644 index 82402427aec..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-range-error-from-ToTemporalDuration.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd should throw from ToTemporalDuration. -info: | - ... - 5. Set duration to ? ToTemporalDuration(duration). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, - () => cal.dateAdd("2020-02-03", "invalid duration string"), - 'cal.dateAdd("2020-02-03", "invalid duration string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-type-error-from-GetOptionsObject.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-type-error-from-GetOptionsObject.js deleted file mode 100644 index ced9209a488..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/throw-type-error-from-GetOptionsObject.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Temporal.Calendar.prototype.dateAdd should throw from GetOptionsObject. -info: | - ... - 6. Set options to ? GetOptionsObject(options). -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar('iso8601'); -let invalidOptionsList = [null, 'invalid option', 234, 23n, Symbol('foo'), true, false, Infinity]; - -invalidOptionsList.forEach(function(invalidOptions) { - assert.throws( - TypeError, - () => cal.dateAdd('2020-02-03', 'P1Y', invalidOptions), - 'cal.dateAdd("2020-02-03", "P1Y", invalidOptions) throws a TypeError exception' - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js deleted file mode 100644 index 8e1513b841c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateAdd/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateadd -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateAdd(arg, new Temporal.Duration()), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/branding.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/branding.js deleted file mode 100644 index c9aba85a099..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const dateFromFields = Temporal.Calendar.prototype.dateFromFields; - -assert.sameValue(typeof dateFromFields, "function"); - -const args = [{ year: 2000, month: 1, day: 1 }]; - -assert.throws(TypeError, () => dateFromFields.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => dateFromFields.apply(null, args), "null"); -assert.throws(TypeError, () => dateFromFields.apply(true, args), "true"); -assert.throws(TypeError, () => dateFromFields.apply("", args), "empty string"); -assert.throws(TypeError, () => dateFromFields.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => dateFromFields.apply(1, args), "1"); -assert.throws(TypeError, () => dateFromFields.apply({}, args), "plain object"); -assert.throws(TypeError, () => dateFromFields.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => dateFromFields.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/builtin.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/builtin.js deleted file mode 100644 index 11d9635a51d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: > - Tests that Temporal.Calendar.prototype.dateFromFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.dateFromFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.dateFromFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.dateFromFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.dateFromFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/fields-not-object.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/fields-not-object.js deleted file mode 100644 index 68224ebe2c6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/fields-not-object.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Throw a TypeError if the fields is not an object -info: | - 4. If Type(_fields_) is not Object, throw a *TypeError* exception. -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -const tests = [undefined, null, true, false, "string", Symbol("sym"), Infinity, NaN, Math.PI, 42n]; -const iso = Temporal.Calendar.from("iso8601"); -for (const fields of tests) { - assert.throws( - TypeError, - () => iso.dateFromFields(fields, {}) - `dateFromFields(${typeof fields}) throws a TypeError exception` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/infinity-throws-rangeerror.js deleted file mode 100644 index 7083f473996..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/infinity-throws-rangeerror.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.datefromfields -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - ["constrain", "reject"].forEach((overflow) => { - assert.throws(RangeError, () => instance.dateFromFields({ ...base, [prop]: inf }, { overflow }), `${prop} property cannot be ${inf} (overflow ${overflow}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.dateFromFields({ ...base, [prop]: obj }, { overflow })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/length.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/length.js deleted file mode 100644 index c03bcfc7315..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dateFromFields, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/missing-properties.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/missing-properties.js deleted file mode 100644 index e1694ccf107..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/missing-properties.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Errors due to missing properties on fields object are thrown in the correct order -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const missingDay = { - get year() { - TemporalHelpers.assertUnreachable("day should be checked first"); - }, - get month() { - TemporalHelpers.assertUnreachable("day should be checked first"); - }, - get monthCode() { - TemporalHelpers.assertUnreachable("day should be checked first"); - }, -}; -assert.throws(TypeError, () => instance.dateFromFields(missingDay), "day should be checked before year and month"); - -let getMonth = false; -let getMonthCode = false; -const missingYearAndMonth = { - day: 1, - get month() { - getMonth = true; - }, - get monthCode() { - getMonthCode = true; - }, -}; -assert.throws(TypeError, () => instance.dateFromFields(missingYearAndMonth), "year should be checked after fetching but before resolving the month"); -assert(getMonth, "year is fetched after month"); -assert(getMonthCode, "year is fetched after monthCode"); - -const missingMonth = { - day: 1, - year: 2000, -}; -assert.throws(TypeError, () => instance.dateFromFields(missingMonth), "month should be resolved last"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/name.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/name.js deleted file mode 100644 index 35ea11bcd53..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields.name is "dateFromFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dateFromFields, "name", { - value: "dateFromFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/not-a-constructor.js deleted file mode 100644 index aca5ec28165..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: > - Temporal.Calendar.prototype.dateFromFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.dateFromFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.dateFromFields), false, - "isConstructor(Temporal.Calendar.prototype.dateFromFields)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/one-of-era-erayear-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/one-of-era-erayear-undefined.js deleted file mode 100644 index 4d36b89c818..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/one-of-era-erayear-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Does not throw a RangeError if only one of era/eraYear fields is present -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const base = { year: 2000, month: 5, day: 2, era: 'ce' }; -const instance = new Temporal.Calendar('iso8601'); -TemporalHelpers.assertPlainDate(instance.dateFromFields({ ...base }), 2000, 5, 'M05', 2); - -const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 }; -TemporalHelpers.assertPlainDate(instance.dateFromFields({ ...base }), 2000, 5, 'M05', 2); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-object.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-object.js deleted file mode 100644 index 21fdb7242ce..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-object.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Empty or a function object may be used as options -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const result1 = instance.dateFromFields({ year: 1976, month: 11, day: 18 }, {}); -TemporalHelpers.assertPlainDate( - result1, 1976, 11, "M11", 18, - "options may be an empty plain object" -); - -const result2 = instance.dateFromFields({ year: 1976, month: 11, day: 18 }, () => {}); -TemporalHelpers.assertPlainDate( - result2, 1976, 11, "M11", 18, - "options may be a function object" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-wrong-type.js deleted file mode 100644 index 011851c7550..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/options-wrong-type.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: TypeError thrown when options argument is a primitive -features: [BigInt, Symbol, Temporal] ----*/ - -const badOptions = [ - null, - true, - "some string", - Symbol(), - 1, - 2n, -]; - -const instance = new Temporal.Calendar("iso8601"); -for (const value of badOptions) { - assert.throws(TypeError, () => instance.dateFromFields({ year: 1976, month: 11, day: 18 }, value), - `TypeError on wrong options type ${typeof value}`); -}; diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/order-of-operations.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/order-of-operations.js deleted file mode 100644 index e28b27c2813..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/order-of-operations.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Properties on objects passed to dateFromFields() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get fields.day", - "get fields.day.valueOf", - "call fields.day.valueOf", - "get fields.month", - "get fields.month.valueOf", - "call fields.month.valueOf", - "get fields.monthCode", - "get fields.monthCode.toString", - "call fields.monthCode.toString", - "get fields.year", - "get fields.year.valueOf", - "call fields.year.valueOf", - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; -const actual = []; - -const instance = new Temporal.Calendar("iso8601"); - -const fields = TemporalHelpers.propertyBagObserver(actual, { - year: 1.7, - month: 1.7, - monthCode: "M01", - day: 1.7, -}, "fields"); - -const options = TemporalHelpers.propertyBagObserver(actual, { - overflow: "reject", -}, "options"); - -const result = instance.dateFromFields(fields, options); -TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1, "date result"); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot should store a string"); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-invalid-string.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-invalid-string.js deleted file mode 100644 index 28e81de7ceb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-invalid-string.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: RangeError thrown when overflow option not one of the allowed string values -info: | - sec-getoption step 10: - 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal-isodatefromfields step 2: - 2. Let _overflow_ be ? ToTemporalOverflow(_options_). - sec-temporal.calendar.prototype.datefromfields step 6: - 6. Let _result_ be ? ISODateFromFields(_fields_, _options_). -features: [Temporal, arrow-function] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"]; -for (const overflow of badOverflows) { - assert.throws( - RangeError, - () => calendar.dateFromFields({ year: 2000, month: 5, day: 2 }, - { overflow }), - `invalid overflow ("${overflow}")` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-undefined.js deleted file mode 100644 index 841cebd9518..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-undefined.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Fallback value for overflow option -info: | - sec-getoption step 3: - 3. If _value_ is *undefined*, return _fallback_. - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal-isodatefromfields step 2: - 2. Let _overflow_ be ? ToTemporalOverflow(_options_). - sec-temporal.calendar.prototype.datefromfields step 6: - 6. Let _result_ be ? ISODateFromFields(_fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); - -const explicit = calendar.dateFromFields({ year: 2000, month: 15, day: 2 }, { overflow: undefined }); -TemporalHelpers.assertPlainDate(explicit, 2000, 12, "M12", 2, "default overflow is constrain"); -const implicit = calendar.dateFromFields({ year: 2000, month: 15, day: 2 }, {}); -TemporalHelpers.assertPlainDate(implicit, 2000, 12, "M12", 2, "default overflow is constrain"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-wrong-type.js deleted file mode 100644 index 41adc3d46e3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/overflow-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Type conversions for overflow option -info: | - sec-getoption step 9.a: - a. Set _value_ to ? ToString(_value_). - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal-isodatefromfields step 2: - 2. Let _overflow_ be ? ToTemporalOverflow(_options_). - sec-temporal.calendar.prototype.datefromfields step 6: - 6. Let _result_ be ? ISODateFromFields(_fields_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -TemporalHelpers.checkStringOptionWrongType("overflow", "constrain", - (overflow) => calendar.dateFromFields({ year: 2000, month: 5, day: 2 }, { overflow }), - (result, descr) => TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2, descr), -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/prop-desc.js deleted file mode 100644 index 886e3a42ac5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: The "dateFromFields" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.dateFromFields, - "function", - "`typeof Calendar.prototype.dateFromFields` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "dateFromFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-GetOptionsObject.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-GetOptionsObject.js deleted file mode 100644 index 5ec1e2c75af..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-GetOptionsObject.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields should throw TypeError from GetOptionsObject. -info: | - 4. If Type(fields) is not Object, throw a TypeError exception. -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar('iso8601'); - -let fields = { - year: 2021, - month: 7, - day: 20 -}; - -let notObjectList = [null, 'string', Symbol('efg'), true, false, Infinity, NaN, 123, 456n]; - -notObjectList.forEach(function(options) { - assert.throws( - TypeError, - () => cal.dateFromFields(fields, options), - 'cal.dateFromFields(fields, options) throws a TypeError exception' - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throws-range-error.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throws-range-error.js deleted file mode 100644 index 7f433249a80..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throws-range-error.js +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: > - Temporal.Calendar.prototype.dateFromFields should throw RangeError for - input not in valid range. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISODateFromFields(fields, options). - 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601") - -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "m1", day: 17}), - 'cal.dateFromFields({year: 2021, monthCode: "m1", day: 17}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M1", day: 17}), - 'cal.dateFromFields({year: 2021, monthCode: "M1", day: 17}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "m01", day: 17}), - 'cal.dateFromFields({year: 2021, monthCode: "m01", day: 17}) throws a RangeError exception'); - -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 12, monthCode: "M11", day: 17}), - 'cal.dateFromFields({year: 2021, month: 12, monthCode: "M11", day: 17}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M00", day: 17}), - 'cal.dateFromFields({year: 2021, monthCode: "M00", day: 17}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M19", day: 17}), - 'cal.dateFromFields({year: 2021, monthCode: "M19", day: 17}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M99", day: 17}), - 'cal.dateFromFields({year: 2021, monthCode: "M99", day: 17}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, monthCode: "M13", day: 17}), - 'cal.dateFromFields({year: 2021, monthCode: "M13", day: 17}) throws a RangeError exception'); - -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: -1, day: 17}), - 'cal.dateFromFields({year: 2021, month: -1, day: 17}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: -Infinity, day: 17}), - 'cal.dateFromFields({year: 2021, month: -Infinity, day: 17}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 7, day: -17}), - 'cal.dateFromFields({year: 2021, month: 7, day: -17}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 7, day: -Infinity}), - 'cal.dateFromFields({year: 2021, month: 7, day: -Infinity}) throws a RangeError exception'); - -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 12, day: 0}, {overflow: "reject"}), - 'cal.dateFromFields({year: 2021, month: 12, day: 0}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 12, day: 32}, {overflow: "reject"}), - 'cal.dateFromFields({year: 2021, month: 12, day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 1, day: 32}, {overflow: "reject"}), - 'cal.dateFromFields({year: 2021, month: 1, day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 2, day: 29}, {overflow: "reject"}), - 'cal.dateFromFields({year: 2021, month: 2, day: 29}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 6, day: 31}, {overflow: "reject"}), - 'cal.dateFromFields({year: 2021, month: 6, day: 31}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 9, day: 31}, {overflow: "reject"}), - 'cal.dateFromFields({year: 2021, month: 9, day: 31}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 0, day: 5}, {overflow: "reject"}), - 'cal.dateFromFields({year: 2021, month: 0, day: 5}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields({year: 2021, month: 13, day: 5}, {overflow: "reject"}), - 'cal.dateFromFields({year: 2021, month: 13, day: 5}, {overflow: "reject"}) throws a RangeError exception'); - -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, monthCode: "M12", day: 0}, {overflow: "reject"}), - 'cal.dateFromFields( {year: 2021, monthCode: "M12", day: 0}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, monthCode: "M12", day: 32}, {overflow: "reject"}), - 'cal.dateFromFields( {year: 2021, monthCode: "M12", day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, monthCode: "M01", day: 32}, {overflow: "reject"}), - 'cal.dateFromFields( {year: 2021, monthCode: "M01", day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, monthCode: "M02", day: 29}, {overflow: "reject"}), - 'cal.dateFromFields( {year: 2021, monthCode: "M02", day: 29}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, monthCode: "M06", day: 31}, {overflow: "reject"}), - 'cal.dateFromFields( {year: 2021, monthCode: "M06", day: 31}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, monthCode: "M09", day: 31}, {overflow: "reject"}), - 'cal.dateFromFields( {year: 2021, monthCode: "M09", day: 31}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, monthCode: "M00", day: 5}, {overflow: "reject"}), - 'cal.dateFromFields( {year: 2021, monthCode: "M00", day: 5}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, monthCode: "M13", day: 5}, {overflow: "reject"}), - 'cal.dateFromFields( {year: 2021, monthCode: "M13", day: 5}, {overflow: "reject"}) throws a RangeError exception'); - -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 12, day: 0}), 'cal.dateFromFields( {year: 2021, month: 12, day: 0}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 0, day: 3}), 'cal.dateFromFields( {year: 2021, month: 0, day: 3}) throws a RangeError exception'); - -// Check throw for the second arg -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 7, day: 13}, {overflow: "invalid"}), 'cal.dateFromFields( {year: 2021, month: 7, day: 13}, {overflow: "invalid"}) throws a RangeError exception'); - -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 1, day: 32}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 1, day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 2, day: 29}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 2, day: 29}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 3, day: 32}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 3, day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 4, day: 31}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 4, day: 31}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 5, day: 32}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 5, day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 6, day: 31}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 6, day: 31}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 7, day: 32}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 7, day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 8, day: 32}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 8, day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 9, day: 31}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 9, day: 31}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 10, day: 32}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 10, day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 11, day: 31}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 11, day: 31}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 12, day: 32}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 12, day: 32}, {overflow: "reject"}) throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateFromFields( - {year: 2021, month: 13, day: 5}, {overflow: "reject"}), 'cal.dateFromFields( {year: 2021, month: 13, day: 5}, {overflow: "reject"}) throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throws-type-error.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throws-type-error.js deleted file mode 100644 index b970735574b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/throws-type-error.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields should throw TypeError with wrong type. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISODateFromFields(fields, options). - 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ -// Check throw for first arg -let cal = new Temporal.Calendar('iso8601'); -assert.throws(TypeError, () => cal.dateFromFields(), 'cal.dateFromFields() throws a TypeError exception'); - -[undefined, true, false, 123, 456n, Symbol(), 'string'].forEach(function(fields) { - assert.throws( - TypeError, - () => cal.dateFromFields(fields), - 'cal.dateFromFields(fields) throws a TypeError exception' - ); - - assert.throws( - TypeError, - () => cal.dateFromFields(fields, undefined), - 'cal.dateFromFields(fields, undefined) throws a TypeError exception' - ); - - assert.throws(TypeError, () => cal.dateFromFields(fields, { - overflow: 'constrain' - }), 'cal.dateFromFields(fields, {overflow: "constrain"}) throws a TypeError exception'); - - assert.throws(TypeError, () => cal.dateFromFields(fields, { - overflow: 'reject' - }), 'cal.dateFromFields(fields, {overflow: "reject"}) throws a TypeError exception'); -}); - -assert.throws(TypeError, () => cal.dateFromFields({ - month: 1, - day: 17 -}), 'cal.dateFromFields({month: 1, day: 17}) throws a TypeError exception'); - -assert.throws(TypeError, () => cal.dateFromFields({ - year: 2021, - day: 17 -}), 'cal.dateFromFields({year: 2021, day: 17}) throws a TypeError exception'); - -assert.throws(TypeError, () => cal.dateFromFields({ - year: 2021, - month: 12 -}), 'cal.dateFromFields({year: 2021, month: 12}) throws a TypeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-month-day-need-constrain.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-month-day-need-constrain.js deleted file mode 100644 index 223c9f42f2e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-month-day-need-constrain.js +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields with year/month/day and need constrain -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISODateFromFields(fields, options). - 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601") - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 1, day: 133}), - 2021, 1, "M01", 31, - "year/month/day with day need to be constrained in Jan"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 2, day: 133}), - 2021, 2, "M02", 28, - "year/month/day with day need to be constrained in Feb"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 3, day: 133}), - 2021, 3, "M03", 31, - "year/month/day with day need to be constrained in March"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 4, day: 133}), - 2021, 4, "M04", 30, - "year/month/day with day need to be constrained in April"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 5, day: 133}), - 2021, 5, "M05", 31, - "year/month/day with day need to be constrained in May"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 6, day: 133}), - 2021, 6, "M06", 30, - "year/month/day with day need to be constrained in Jun"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 7, day: 133}), - 2021, 7, "M07", 31, - "year/month/day with day need to be constrained in July"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 8, day: 133}), - 2021, 8, "M08", 31, - "year/month/day with day need to be constrained in Aug"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 9, day: 133}), - 2021, 9, "M09", 30, - "year/month/day with day need to be constrained in Sept."); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 10, day: 133}), - 2021, 10, "M10", 31, - "year/month/day with day need to be constrained in Oct."); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 11, day: 133}), - 2021, 11, "M11", 30, - "year/month/day with day need to be constrained in Nov."); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 12, day: 133}), - 2021, 12, "M12", 31, - "year/month/day with day need to be constrained in Dec."); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 13, day: 500}), - 2021, 12, "M12", 31, - "year/month/day with month and day need to be constrained"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 999999, day: 500}), - 2021, 12, "M12", 31, - "year/month/day with month and day need to be constrained"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-monthCode-day-need-constrain.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-monthCode-day-need-constrain.js deleted file mode 100644 index 7a021938a08..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-monthCode-day-need-constrain.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields with year, monthCode and day and need constrain -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISODateFromFields(fields, options). - 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601") - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M01", day: 133}), - 2021, 1, "M01", 31, - "year/monthCode/day with day need to be constrained in Jan"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M02", day: 133}), - 2021, 2, "M02", 28, - "year/monthCode/day with day need to be constrained in Feb"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M03", day: 133}), - 2021, 3, "M03", 31, - "year/monthCode/day with day need to be constrained in March"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M04", day: 133}), - 2021, 4, "M04", 30, - "year/monthCode/day with day need to be constrained in April"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M05", day: 133}), - 2021, 5, "M05", 31, - "year/monthCode/day with day need to be constrained in May"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M06", day: 133}), - 2021, 6, "M06", 30, - "year/monthCode/day with day need to be constrained in Jun"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M07", day: 133}), - 2021, 7, "M07", 31, - "year/monthCode/day with day need to be constrained in July"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M08", day: 133}), - 2021, 8, "M08", 31, - "year/monthCode/day with day need to be constrained in Aug"); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M09", day: 133}), - 2021, 9, "M09", 30, - "year/monthCode/day with day need to be constrained in Sept."); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M10", day: 133}), - 2021, 10, "M10", 31, - "year/monthCode/day with day need to be constrained in Oct."); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M11", day: 133}), - 2021, 11, "M11", 30, - "year/monthCode/day with day need to be constrained in Nov."); - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M12", day: 133}), - 2021, 12, "M12", 31, - "year/monthCode/day with day need to be constrained in Dec."); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-monthCode-day.js b/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-monthCode-day.js deleted file mode 100644 index 8b27f81026b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-monthCode-day.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields with year, monthCode and day. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISODateFromFields(fields, options). - 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601") - -TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, monthCode: "M07", day: 15}), - 2021, 7, "M07", 15, - "year/monthCode/day"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 840fe7252e1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)); -instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 473b4eab42a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg1 = { year: 2000, month: 5, day: 2, calendar }; -const arg2 = new Temporal.PlainDate(1977, 11, 19); - -instance.dateUntil(arg1, arg2); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar (first argument)"); - -calendar.dateFromFieldsCallCount = 0; - -instance.dateUntil(arg2, arg1); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar (second argument)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-constructor-in-calendar-fields.js deleted file mode 100644 index df2e1392069..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19))); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-duplicate-calendar-fields.js deleted file mode 100644 index 1039216a5af..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19))); - assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-infinity-throws-rangeerror.js deleted file mode 100644 index 9f8cec10b7e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-infinity-throws-rangeerror.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in a property bag for either argument is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.dateuntil -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const other = new Temporal.PlainDate(2001, 6, 3); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.dateUntil({ ...base, [prop]: inf }, other), `${prop} property cannot be ${inf}`); - - assert.throws(RangeError, () => instance.dateUntil(other, { ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls1 = []; - const obj1 = TemporalHelpers.toPrimitiveObserver(calls1, inf, prop); - assert.throws(RangeError, () => instance.dateUntil({ ...base, [prop]: obj1 }, other)); - assert.compareArray(calls1, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - - const calls2 = []; - const obj2 = TemporalHelpers.toPrimitiveObserver(calls2, inf, prop); - assert.throws(RangeError, () => instance.dateUntil(other, { ...base, [prop]: obj2 })); - assert.compareArray(calls2, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-number.js deleted file mode 100644 index 945826da088..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-number.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 18)), - "A number is not a valid ISO string for PlainDate (first argument)" - ); - assert.throws( - TypeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 18), arg), - "A number is not a valid ISO string for PlainDate (second argument)" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-plaindatetime.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-plaindatetime.js deleted file mode 100644 index 29cbe4481ed..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-plaindatetime.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Fast path for converting Temporal.PlainDateTime to Temporal.PlainDate by reading internal slots -info: | - sec-temporal.calendar.prototype.dateuntil steps 4–5: - 4. Set _one_ to ? ToTemporalDate(_one_). - 5. Set _two_ to ? ToTemporalDate(_two_). - sec-temporal-totemporaldate step 2.b: - b. If _item_ has an [[InitializedTemporalDateTime]] internal slot, then - i. Return ! CreateTemporalDate(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], _item_.[[Calendar]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const date = new Temporal.PlainDate(2000, 5, 2); - -TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { - const calendar = new Temporal.Calendar("iso8601"); - const result = calendar.dateUntil(datetime, date); - assert.sameValue(result.total({ unit: "nanoseconds" }), 0, "time part dropped"); -}); - -TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { - const calendar = new Temporal.Calendar("iso8601"); - const result = calendar.dateUntil(date, datetime); - assert.sameValue(result.total({ unit: "nanoseconds" }), 0, "time part dropped"); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 0055d3b8bf3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: The calendar name is case-insensitive -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19)); -TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "Calendar is case-insensitive (first argument)"); -const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg); -TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "Calendar is case-insensitive (second argument)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index a86e90aaa64..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: An ISO 8601 string can be converted to a calendar ID in Calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19)); - TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}" (first argument)`); - const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg); - TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}" (second argument)`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index daf2fe1e66e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Leap second is a valid ISO string for a calendar in a property bag -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19)); -TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for calendar (first argument)"); -const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg); -TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for calendar (second argument)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-number.js deleted file mode 100644 index 9a0106aaa89..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), - "A number is not a valid ISO string for calendar (first argument)" - ); - assert.throws( - TypeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), - "A number is not a valid ISO string for calendar (second argument)" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-string.js deleted file mode 100644 index 77dc4a82b50..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: A calendar ID is valid input for Calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -Object.defineProperty(instance, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up on receiver"); - }, -}); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - -const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 18)); -TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${arg} (first argument)"`); - -const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 18), arg); -TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, `Calendar created from string "${arg} (second argument)"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 30902127664..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === "string" ? RangeError : TypeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), - `${description} does not convert to a valid ISO string (first argument)` - ); - assert.throws( - typeof calendar === "string" ? RangeError : TypeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), - `${description} does not convert to a valid ISO string (second argument)` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} is not a valid property bag and does not convert to a string (first argument)`); - assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 773fe54515f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), - "reject minus zero as extended year (first argument)" - ); - assert.throws( - RangeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), - "reject minus zero as extended year (second argument)" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-proto-in-calendar-fields.js deleted file mode 100644 index a1a5f68b330..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19))); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 28260458d4e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), - `annotation keys must be lowercase: ${arg} - ${descr} (first argument)` - ); - assert.throws( - RangeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), - `annotation keys must be lowercase: ${arg} - ${descr} (second argument)` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation.js deleted file mode 100644 index 12548196eff..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-calendar-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dateUntil(arg, arg); - - TemporalHelpers.assertDuration( - result, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 1efacbd80e5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), - `reject unknown annotation with critical flag: ${arg} (first argument)` - ); - assert.throws( - RangeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), - `reject unknown annotation with critical flag: ${arg} (second argument)` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-date-with-utc-offset.js deleted file mode 100644 index 1d923f43b37..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: UTC offset not valid with format that does not include a time -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - TemporalHelpers.assertDuration( - instance.dateUntil(arg, arg), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), - `"${arg}" UTC offset without time is not valid for PlainDate (first argument)` - ); - assert.throws( - RangeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), - `"${arg}" UTC offset without time is not valid for PlainDate (second argument)` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-invalid.js deleted file mode 100644 index d7c7321ce4f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-invalid.js +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -const other = new Temporal.PlainDate(2020, 1, 1, instance); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.dateUntil(arg, other), - `"${arg}" should not be a valid ISO string for a PlainDate (first argument)` - ); - assert.throws( - RangeError, - () => instance.dateUntil(other, arg), - `"${arg}" should not be a valid ISO string for a PlainDate (second argument)` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-calendar.js deleted file mode 100644 index 59ecbccad7c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-calendar.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), - `reject more than one calendar annotation if any critical: ${arg} (first argument)` - ); - assert.throws( - RangeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), - `reject more than one calendar annotation if any critical: ${arg} (second argument)` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-time-zone.js deleted file mode 100644 index 80a55915b3b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), - `reject more than one time zone annotation: ${arg} (first argument)` - ); - assert.throws( - RangeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), - `reject more than one time zone annotation: ${arg} (second argument)` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-separators.js deleted file mode 100644 index ce4b1b09241..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-separators.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Time separator in string argument can vary -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const date = new Temporal.PlainDate(2000, 5, 3); -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - TemporalHelpers.assertDuration( - instance.dateUntil(arg, date), - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - `variant time separators (${description}), first argument` - ); - - TemporalHelpers.assertDuration( - instance.dateUntil(date, arg), - 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, - `variant time separators (${description}), second argument` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-zone-annotation.js deleted file mode 100644 index 77511ae0078..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ['2000-05-02[Asia/Kolkata]', 'named, with no time'], - ['2000-05-02[!Europe/Vienna]', 'named, with ! and no time'], - ['2000-05-02[+00:00]', 'numeric, with no time'], - ['2000-05-02[!-02:30]', 'numeric, with ! and no time'], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dateUntil(arg, arg); - - TemporalHelpers.assertDuration( - result, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-unknown-annotation.js deleted file mode 100644 index 3b83c67e5fb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-unknown-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Various forms of unknown annotation -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dateUntil(arg, arg); - - TemporalHelpers.assertDuration( - result, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-with-utc-designator.js deleted file mode 100644 index 8aa77d5e756..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-string-with-utc-designator.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -const plainDate = new Temporal.PlainDate(2000, 5, 2); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dateUntil(arg, plainDate), - "String with UTC designator should not be valid as a PlainDate (first argument)" - ); - assert.throws( - RangeError, - () => instance.dateUntil(plainDate, arg), - "String with UTC designator should not be valid as a PlainDate (second argument)" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-wrong-type.js deleted file mode 100644 index 79d344baab0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-wrong-type.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), - `${description} does not convert to a valid ISO string (first argument)` - ); - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), - `${description} does not convert to a valid ISO string (second argument)` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} is not a valid property bag and does not convert to a string (first argument)`); - assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-slots.js deleted file mode 100644 index b3f36182333..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)); -instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index accc9ceb667..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, Infinity, -Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - - assert.throws(RangeError, () => calendar.dateUntil(datetime, date)); - assert.throws(RangeError, () => calendar.dateUntil(date, datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index a01e5a0b031..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - - assert.throws( - TypeError, - () => calendar.dateUntil(datetime, date), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); - assert.throws( - TypeError, - () => calendar.dateUntil(date, datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 0f28480b061..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - - assert.throws(RangeError, () => calendar.dateUntil(datetime, date)); - assert.throws(RangeError, () => calendar.dateUntil(date, datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 6d283f4a15f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - - assert.throws(TypeError, () => calendar.dateUntil(datetime, date)); - assert.throws(TypeError, () => calendar.dateUntil(date, datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/basic.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/basic.js deleted file mode 100644 index c7d4d4b49f0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/basic.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Basic tests for dateUntil(). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const date1 = Temporal.PlainDate.from("1999-09-03"); -const date2 = Temporal.PlainDate.from("2000-01-01"); - -TemporalHelpers.assertDuration( - iso.dateUntil(date1, date2, {}), - 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, "two PlainDates"); - -TemporalHelpers.assertDuration( - iso.dateUntil(Temporal.PlainDateTime.from("1999-09-03T08:15:30"), date2, {}), - 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, "first argument: PlainDateTime"); - -TemporalHelpers.assertDuration( - iso.dateUntil({ year: 1999, month: 9, day: 3 }, date2, {}), - 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, "first argument: property bag"); - -TemporalHelpers.assertDuration( - iso.dateUntil("1999-09-03", date2, {}), - 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, "first argument: string"); - -assert.throws(TypeError, () => iso.dateUntil({ month: 11 }, date2, {}), "first argument: missing property"); - -TemporalHelpers.assertDuration( - iso.dateUntil(date1, Temporal.PlainDateTime.from("2000-01-01T08:15:30"), {}), - 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, "second argument: PlainDateTime"); - -TemporalHelpers.assertDuration( - iso.dateUntil(date1, { year: 2000, month: 1, day: 1 }, {}), - 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, "second argument: property bag"); - -TemporalHelpers.assertDuration( - iso.dateUntil(date1, "2000-01-01", {}), - 0, 0, 0, 120, 0, 0, 0, 0, 0, 0, "second argument: string"); - -assert.throws(TypeError, () => iso.dateUntil(date1, { month: 11 }, {}), "second argument: missing property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/branding.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/branding.js deleted file mode 100644 index 992cc02b9c2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const dateUntil = Temporal.Calendar.prototype.dateUntil; - -assert.sameValue(typeof dateUntil, "function"); - -const args = [new Temporal.PlainDate(2021, 7, 16), new Temporal.PlainDate(2021, 7, 17)]; - -assert.throws(TypeError, () => dateUntil.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => dateUntil.apply(null, args), "null"); -assert.throws(TypeError, () => dateUntil.apply(true, args), "true"); -assert.throws(TypeError, () => dateUntil.apply("", args), "empty string"); -assert.throws(TypeError, () => dateUntil.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => dateUntil.apply(1, args), "1"); -assert.throws(TypeError, () => dateUntil.apply({}, args), "plain object"); -assert.throws(TypeError, () => dateUntil.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => dateUntil.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/builtin.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/builtin.js deleted file mode 100644 index 94ebc2df633..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: > - Tests that Temporal.Calendar.prototype.dateUntil - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.dateUntil), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.dateUntil), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.dateUntil), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.dateUntil.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 419334f252e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.dateUntil({ year: 2000, month: 5, day: 2, calendar }, { year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 2); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/calendar-fields-iterable.js deleted file mode 100644 index a14e3fa7cac..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/calendar-fields-iterable.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.dateuntil steps 4–5: - 4. Set _one_ to ? ToTemporalDate(_one_). - 5. Set _two_ to ? ToTemporalDate(_two_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -const calendar3 = TemporalHelpers.calendarFieldsIterable(); -calendar1.dateUntil( - { year: 2000, month: 5, day: 2, calendar: calendar2 }, - { year: 2005, month: 6, day: 3, calendar: calendar3 }, -); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.sameValue(calendar3.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); -assert.compareArray(calendar3.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar3.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/calendar-temporal-object.js deleted file mode 100644 index 57e94608a19..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/calendar-temporal-object.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.dateuntil steps 4–5: - 4. Set _one_ to ? ToTemporalDate(_one_). - 5. Set _two_ to ? ToTemporalDate(_two_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.dateUntil( - { year: 2000, month: 5, day: 2, calendar: temporalObject }, - { year: 2005, month: 6, day: 3, calendar: temporalObject }, - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-day.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-day.js deleted file mode 100644 index 530d104afa3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-day.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil with largestUnit is "day" -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. Set one to ? ToTemporalDate(one). - 5. Set two to ? ToTemporalDate(two). - 6. Set options to ? GetOptionsObject(options). - 7. Let largestUnit be ? ToLargestTemporalUnit(options, « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" », "auto", "day"). - 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). - 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -["day", "days"].forEach(function(largestUnit) { - let opt = {largestUnit}; - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-16", opt), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-17", opt), - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-17", opt), - 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, "32 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-09-16", opt), - 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, "62 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2022-07-16", opt), - 0, 0, 0, 365, 0, 0, 0, 0, 0, 0, "365 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2031-07-16", opt), - 0, 0, 0, 3652, 0, 0, 0, 0, 0, 0, "3652 days"); - - - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-17", "2021-07-16", opt), - 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-17", "2021-07-16", opt), - 0, 0, 0, -32, 0, 0, 0, 0, 0, 0, "negative 32 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-09-16", "2021-07-16", opt), - 0, 0, 0, -62, 0, 0, 0, 0, 0, 0, "negative 62 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2022-07-16", "2021-07-16", opt), - 0, 0, 0, -365, 0, 0, 0, 0, 0, 0, "negative 365 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2031-07-16", "2021-07-16", opt), - 0, 0, 0, -3652, 0, 0, 0, 0, 0, 0, "negative 3652 days"); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-month.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-month.js deleted file mode 100644 index 5953c7886ae..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-month.js +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil with largestUnit is "month" -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. Set one to ? ToTemporalDate(one). - 5. Set two to ? ToTemporalDate(two). - 6. Set options to ? GetOptionsObject(options). - 7. Let largestUnit be ? ToLargestTemporalUnit(options, « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" », "auto", "day"). - 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). - 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -["month", "months"].forEach(function(largestUnit) { - let opt = {largestUnit}; - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-16", opt), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-17", opt), - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-23", opt), - 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, "7 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-16", opt), - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2020-12-16", "2021-01-16", opt), - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in different year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-01-05", "2021-02-05", opt), - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-01-07", "2021-03-07", opt), - 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 month in same year across Feb 28"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-17", opt), - 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, "1 month and 1 day in a month with 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-13", opt), - 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, "28 days roll across a month which has 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-09-16", opt), - 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 months with both months which have 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2022-07-16", opt), - 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, "12 months"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2031-07-16", opt), - 0, 120, 0, 0, 0, 0, 0, 0, 0, 0, "120 months"); - - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-17", "2021-07-16", opt), - 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-23", "2021-07-16", opt), - 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, "negative 7 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-16", "2021-07-16", opt), - 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-01-16", "2020-12-16", opt), - 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in different year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-02-05", "2021-01-05", opt), - 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-03-07", "2021-01-07", opt), - 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 month in same year across Feb 28"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-17", "2021-07-16", opt), - 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, "negative 1 month and 1 day in a month with 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-13", "2021-07-16", opt), - 0, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 28 days roll across a month which has 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-09-16", "2021-07-16", opt), - 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 months with both months which have 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2022-07-16", "2021-07-16", opt), - 0, -12, 0, 0, 0, 0, 0, 0, 0, 0, "negative 12 months"); - TemporalHelpers.assertDuration( - cal.dateUntil("2031-07-16", "2021-07-16", opt), - 0, -120, 0, 0, 0, 0, 0, 0, 0, 0, "negative 120 months"); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-week.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-week.js deleted file mode 100644 index 757794631b3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-week.js +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil with largestUnit is "week" -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. Set one to ? ToTemporalDate(one). - 5. Set two to ? ToTemporalDate(two). - 6. Set options to ? GetOptionsObject(options). - 7. Let largestUnit be ? ToLargestTemporalUnit(options, « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" », "auto", "day"). - 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). - 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -["week", "weeks"].forEach(function(largestUnit) { - let opt = {largestUnit}; - - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-16", opt), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-17", opt), - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-23", opt), - 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "7 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-16", opt), - 0, 0, 4, 3, 0, 0, 0, 0, 0, 0, "4 weeks and 3 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-13", opt), - 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, "4 weeks"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-09-16", opt), - 0, 0, 8, 6, 0, 0, 0, 0, 0, 0, "8 weeks and 6 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2022-07-16", opt), - 0, 0, 52, 1, 0, 0, 0, 0, 0, 0, "52 weeks and 1 day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2031-07-16", opt), - 0, 0, 521, 5, 0, 0, 0, 0, 0, 0, "521 weeks and 5 days"); - - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-17", "2021-07-16", opt), - 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-23", "2021-07-16", opt), - 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, "negative 7 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-16", "2021-07-16", opt), - 0, 0, -4, -3, 0, 0, 0, 0, 0, 0, "negative 4 weeks and 3 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-13", "2021-07-16", opt), - 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, "negative 4 weeks"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-09-16", "2021-07-16", opt), - 0, 0, -8, -6, 0, 0, 0, 0, 0, 0, "negative 8 weeks and 6 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2022-07-16", "2021-07-16", opt), - 0, 0, -52, -1, 0, 0, 0, 0, 0, 0, "negative 52 weeks and 1 day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2031-07-16", "2021-07-16", opt), - 0, 0, -521, -5, 0, 0, 0, 0, 0, 0, "negative 521 weeks and 5 days"); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-year.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-year.js deleted file mode 100644 index 03773ec893b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largest-unit-year.js +++ /dev/null @@ -1,204 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil with largestUnit is "year" -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. Set one to ? ToTemporalDate(one). - 5. Set two to ? ToTemporalDate(two). - 6. Set options to ? GetOptionsObject(options). - 7. Let largestUnit be ? ToLargestTemporalUnit(options, « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" », "auto", "day"). - 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). - 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -["year", "years"].forEach(function(largestUnit) { - let opt = {largestUnit}; - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-16", opt), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-17", opt), - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-23", opt), - 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, "7 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-16", opt), - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2020-12-16", "2021-01-16", opt), - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in different year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-01-05", "2021-02-05", opt), - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-01-07", "2021-03-07", opt), - 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 month in same year across Feb 28"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-17", opt), - 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, "1 month and 1 day in a month with 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-13", opt), - 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, "28 days roll across a month which has 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-09-16", opt), - 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 months with both months which have 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2022-07-16", opt), - 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "1 year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2031-07-16", opt), - 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, "10 years"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2022-07-19", opt), - 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, "1 year and 3 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2022-09-19", opt), - 1, 2, 0, 3, 0, 0, 0, 0, 0, 0, "1 year 2 months and 3 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2031-12-16", opt), - 10, 5, 0, 0, 0, 0, 0, 0, 0, 0, "10 years and 5 months"); - TemporalHelpers.assertDuration( - cal.dateUntil("1997-12-16", "2021-07-16", opt), - 23, 7, 0, 0, 0, 0, 0, 0, 0, 0, "23 years and 7 months"); - TemporalHelpers.assertDuration( - cal.dateUntil("1997-07-16", "2021-07-16", opt), - 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, "24 years"); - TemporalHelpers.assertDuration( - cal.dateUntil("1997-07-16", "2021-07-15", opt), - 23, 11, 0, 29, 0, 0, 0, 0, 0, 0, "23 years, 11 months and 29 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("1997-06-16", "2021-06-15", opt), - 23, 11, 0, 30, 0, 0, 0, 0, 0, 0, "23 years, 11 months and 30 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("1960-02-16", "2020-03-16", opt), - 60, 1, 0, 0, 0, 0, 0, 0, 0, 0, "60 years, 1 month"); - TemporalHelpers.assertDuration( - cal.dateUntil("1960-02-16", "2021-03-15", opt), - 61, 0, 0, 27, 0, 0, 0, 0, 0, 0, "61 years, 27 days in non leap year"); - TemporalHelpers.assertDuration( - cal.dateUntil("1960-02-16", "2020-03-15", opt), - 60, 0, 0, 28, 0, 0, 0, 0, 0, 0, "60 years, 28 days in leap year"); - - TemporalHelpers.assertDuration( - cal.dateUntil("2021-03-30", "2021-07-16", opt), - 0, 3, 0, 16, 0, 0, 0, 0, 0, 0, "3 months and 16 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2020-03-30", "2021-07-16", opt), - 1, 3, 0, 16, 0, 0, 0, 0, 0, 0, "1 year, 3 months and 16 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("1960-03-30", "2021-07-16", opt), - 61, 3, 0, 16, 0, 0, 0, 0, 0, 0, "61 years, 3 months and 16 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2019-12-30", "2021-07-16", opt), - 1, 6, 0, 16, 0, 0, 0, 0, 0, 0, "1 year, 6 months and 16 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2020-12-30", "2021-07-16", opt), - 0, 6, 0, 16, 0, 0, 0, 0, 0, 0, "6 months and 16 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("1997-12-30", "2021-07-16", opt), - 23, 6, 0, 16, 0, 0, 0, 0, 0, 0, "23 years, 6 months and 16 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("0001-12-25", "2021-07-16", opt), - 2019, 6, 0, 21, 0, 0, 0, 0, 0, 0, "2019 years, 6 months and 21 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2019-12-30", "2021-03-05", opt), - 1, 2, 0, 5, 0, 0, 0, 0, 0, 0, "1 year, 2 months and 5 days"); - - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-17", "2021-07-16", opt), - 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-23", "2021-07-16", opt), - 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, "negative 7 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-16", "2021-07-16", opt), - 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-01-16", "2020-12-16", opt), - 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in different year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-02-05", "2021-01-05", opt), - 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-03-07", "2021-01-07", opt), - 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 month in same year across Feb 28"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-17", "2021-07-16", opt), - 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, "negative 1 month and 1 day in a month with 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-13", "2021-07-16", opt), - 0, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 28 days roll across a month which has 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-09-16", "2021-07-16", opt), - 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 months with both months which have 31 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2022-07-16", "2021-07-16", opt), - -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2031-07-16", "2021-07-16", opt), - -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, "negative 10 years"); - TemporalHelpers.assertDuration( - cal.dateUntil("2022-07-19", "2021-07-16", opt), - -1, 0, 0, -3, 0, 0, 0, 0, 0, 0, "negative 1 year and 3 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2022-09-19", "2021-07-16", opt), - -1, -2, 0, -3, 0, 0, 0, 0, 0, 0, "negative 1 year 2 months and 3 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2031-12-16", "2021-07-16", opt), - -10, -5, 0, 0, 0, 0, 0, 0, 0, 0, "negative 10 years and 5 months"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "1997-12-16", opt), - -23, -7, 0, 0, 0, 0, 0, 0, 0, 0, "negative 23 years and 7 months"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "1997-07-16", opt), - -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, "negative 24 years"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-15", "1997-07-16", opt), - -23, -11, 0, -30, 0, 0, 0, 0, 0, 0, "negative 23 years, 11 months and 30 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-06-15", "1997-06-16", opt), - -23, -11, 0, -29, 0, 0, 0, 0, 0, 0, "negative 23 years, 11 months and 29 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2020-03-16", "1960-02-16", opt), - -60, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 60 years, 1 month"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-03-15", "1960-02-16", opt), - -61, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 61 years, 28 days in non leap year"); - TemporalHelpers.assertDuration( - cal.dateUntil("2020-03-15", "1960-02-16", opt), - -60, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 60 years, 28 days in leap year"); - - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-03-30", opt), - 0, -3, 0, -17, 0, 0, 0, 0, 0, 0, "negative 3 months and 17 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2020-03-30", opt), - -1, -3, 0, -17, 0, 0, 0, 0, 0, 0, "negative 1 year, 3 months and 17 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "1960-03-30", opt), - -61, -3, 0, -17, 0, 0, 0, 0, 0, 0, "negative 61 years, 3 months and 17 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2019-12-30", opt), - -1, -6, 0, -17, 0, 0, 0, 0, 0, 0, "negative 1 year, 6 months and 17 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2020-12-30", opt), - 0, -6, 0, -17, 0, 0, 0, 0, 0, 0, "negative 6 months and 17 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "1997-12-30", opt), - -23, -6, 0, -17, 0, 0, 0, 0, 0, 0, "negative 23 years, 6 months and 17 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "0001-12-25", opt), - -2019, -6, 0, -22, 0, 0, 0, 0, 0, 0, "negative 2019 years, 6 months and 22 days"); - TemporalHelpers.assertDuration( - cal.dateUntil("2021-03-05", "2019-12-30", opt), - -1, -2, 0, -6, 0, 0, 0, 0, 0, 0, "negative 1 year, 2 months and 6 days"); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largestunit-plurals-accepted.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/largestunit-plurals-accepted.js deleted file mode 100644 index 45048044742..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/largestunit-plurals-accepted.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Plural units are accepted as well for the largestUnit option -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const earlier = new Temporal.PlainDate(2000, 5, 2); -const later = new Temporal.PlainDate(2001, 6, 12); -const calendar = new Temporal.Calendar("iso8601"); -const validUnits = [ - "year", - "month", - "week", - "day", -]; -TemporalHelpers.checkPluralUnitsAccepted((largestUnit) => calendar.dateUntil(earlier, later, { largestUnit }), validUnits); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/leap-second.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/leap-second.js deleted file mode 100644 index f28efbb20ab..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/leap-second.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Leap second is a valid ISO string for PlainDate -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -let result = instance.dateUntil(arg, new Temporal.PlainDate(2017, 1, 1)); -TemporalHelpers.assertDuration(result, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for PlainDate (first argument)"); -result = instance.dateUntil(new Temporal.PlainDate(2017, 1, 1), arg); -TemporalHelpers.assertDuration(result, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for PlainDate (second argument)"); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -result = instance.dateUntil(arg, new Temporal.PlainDate(2017, 1, 1)); -TemporalHelpers.assertDuration(result, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "second: 60 is ignored in property bag for PlainDate (first argument)"); -result = instance.dateUntil(new Temporal.PlainDate(2017, 1, 1), arg); -TemporalHelpers.assertDuration(result, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "second: 60 is ignored in property bag for PlainDate (second argument)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/length.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/length.js deleted file mode 100644 index 30c15f19ada..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil.length is 2 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dateUntil, "length", { - value: 2, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/name.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/name.js deleted file mode 100644 index c648ae3738e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil.name is "dateUntil". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dateUntil, "name", { - value: "dateUntil", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/no-options.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/no-options.js deleted file mode 100644 index 962400e354a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/no-options.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil with no options -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. Set one to ? ToTemporalDate(one). - 5. Set two to ? ToTemporalDate(two). - 6. Set options to ? GetOptionsObject(options). - 7. Let largestUnit be ? ToLargestTemporalUnit(options, « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" », "auto", "day"). - 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). - 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-16"), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); -TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-07-17"), - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); -TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-08-17"), - 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, "32 days"); -TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2021-09-16"), - 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, "62 days"); -TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2022-07-16"), - 0, 0, 0, 365, 0, 0, 0, 0, 0, 0, "365 days"); -TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-16", "2031-07-16"), - 0, 0, 0, 3652, 0, 0, 0, 0, 0, 0, "3652 days"); - - -TemporalHelpers.assertDuration( - cal.dateUntil("2021-07-17", "2021-07-16"), - 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); -TemporalHelpers.assertDuration( - cal.dateUntil("2021-08-17", "2021-07-16"), - 0, 0, 0, -32, 0, 0, 0, 0, 0, 0, "negative 32 days"); -TemporalHelpers.assertDuration( - cal.dateUntil("2021-09-16", "2021-07-16"), - 0, 0, 0, -62, 0, 0, 0, 0, 0, 0, "negative 62 days"); -TemporalHelpers.assertDuration( - cal.dateUntil("2022-07-16", "2021-07-16"), - 0, 0, 0, -365, 0, 0, 0, 0, 0, 0, "negative 365 days"); -TemporalHelpers.assertDuration( - cal.dateUntil("2031-07-16", "2021-07-16"), - 0, 0, 0, -3652, 0, 0, 0, 0, 0, 0, "negative 3652 days"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/not-a-constructor.js deleted file mode 100644 index c0293659bb2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: > - Temporal.Calendar.prototype.dateUntil does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.dateUntil(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.dateUntil), false, - "isConstructor(Temporal.Calendar.prototype.dateUntil)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-object.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-object.js deleted file mode 100644 index d130e96b7c9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-object.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Empty or a function object may be used as options -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const result1 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 18), new Temporal.PlainDate(1984, 5, 31), {}); -TemporalHelpers.assertDuration( - result1, 0, 0, 0, 2751, 0, 0, 0, 0, 0, 0, - "options may be an empty plain object" -); - -const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 18), new Temporal.PlainDate(1984, 5, 31), () => {}); -TemporalHelpers.assertDuration( - result2, 0, 0, 0, 2751, 0, 0, 0, 0, 0, 0, - "options may be a function object" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-wrong-type.js deleted file mode 100644 index 1191edf29fe..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/options-wrong-type.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: TypeError thrown when options argument is a primitive -features: [BigInt, Symbol, Temporal] ----*/ - -const badOptions = [ - null, - true, - "some string", - Symbol(), - 1, - 2n, -]; - -const instance = new Temporal.Calendar("iso8601"); -for (const value of badOptions) { - assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1976, 11, 18), new Temporal.PlainDate(1984, 5, 31), value), - `TypeError on wrong options type ${typeof value}`); -}; diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/order-of-operations.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/order-of-operations.js deleted file mode 100644 index 4df183fc4b8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/order-of-operations.js +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Properties on an object passed to dateUntil() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - // ToTemporalDate 1 → GetTemporalCalendarSlotValueWithISODefault - "get one.calendar", - "has one.calendar.dateAdd", - "has one.calendar.dateFromFields", - "has one.calendar.dateUntil", - "has one.calendar.day", - "has one.calendar.dayOfWeek", - "has one.calendar.dayOfYear", - "has one.calendar.daysInMonth", - "has one.calendar.daysInWeek", - "has one.calendar.daysInYear", - "has one.calendar.fields", - "has one.calendar.id", - "has one.calendar.inLeapYear", - "has one.calendar.mergeFields", - "has one.calendar.month", - "has one.calendar.monthCode", - "has one.calendar.monthDayFromFields", - "has one.calendar.monthsInYear", - "has one.calendar.weekOfYear", - "has one.calendar.year", - "has one.calendar.yearMonthFromFields", - "has one.calendar.yearOfWeek", - // lookup - "get one.calendar.dateFromFields", - "get one.calendar.fields", - // ToTemporalDate 1 → CalendarFields - "call one.calendar.fields", - // ToTemporalDate 1 → PrepareTemporalFields - "get one.day", - "get one.day.valueOf", - "call one.day.valueOf", - "get one.month", - "get one.month.valueOf", - "call one.month.valueOf", - "get one.monthCode", - "get one.monthCode.toString", - "call one.monthCode.toString", - "get one.year", - "get one.year.valueOf", - "call one.year.valueOf", - // ToTemporalDate 1 → CalendarDateFromFields - "call one.calendar.dateFromFields", - // ToTemporalDate 2 → GetTemporalCalendarSlotValueWithISODefault - "get two.calendar", - "has two.calendar.dateAdd", - "has two.calendar.dateFromFields", - "has two.calendar.dateUntil", - "has two.calendar.day", - "has two.calendar.dayOfWeek", - "has two.calendar.dayOfYear", - "has two.calendar.daysInMonth", - "has two.calendar.daysInWeek", - "has two.calendar.daysInYear", - "has two.calendar.fields", - "has two.calendar.id", - "has two.calendar.inLeapYear", - "has two.calendar.mergeFields", - "has two.calendar.month", - "has two.calendar.monthCode", - "has two.calendar.monthDayFromFields", - "has two.calendar.monthsInYear", - "has two.calendar.weekOfYear", - "has two.calendar.year", - "has two.calendar.yearMonthFromFields", - "has two.calendar.yearOfWeek", - // lookup - "get two.calendar.dateFromFields", - "get two.calendar.fields", - // ToTemporalDate 2 → CalendarFields - "call two.calendar.fields", - // ToTemporalDate 2 → PrepareTemporalFields - "get two.day", - "get two.day.valueOf", - "call two.day.valueOf", - "get two.month", - "get two.month.valueOf", - "call two.month.valueOf", - "get two.monthCode", - "get two.monthCode.toString", - "call two.monthCode.toString", - "get two.year", - "get two.year.valueOf", - "call two.year.valueOf", - // ToTemporalDate 2 → CalendarDateFromFields - "call two.calendar.dateFromFields", - // GetTemporalUnit - "get options.largestUnit", - "get options.largestUnit.toString", - "call options.largestUnit.toString", -]; -const actual = []; - -const instance = new Temporal.Calendar("iso8601"); - -const one = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 5, - monthCode: "M05", - day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "one.calendar"), -}, "one"); - -const two = TemporalHelpers.propertyBagObserver(actual, { - year: 2001, - month: 10, - monthCode: "M10", - day: 4, - calendar: TemporalHelpers.calendarObserver(actual, "two.calendar"), -}, "two"); - -const options = TemporalHelpers.propertyBagObserver(actual, { largestUnit: "day" }, "options"); - -instance.dateUntil(one, two, options); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/prop-desc.js deleted file mode 100644 index b0ce5761b97..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: The "dateUntil" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.dateUntil, - "function", - "`typeof Calendar.prototype.dateUntil` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "dateUntil", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToLargestTemporalUnit.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToLargestTemporalUnit.js deleted file mode 100644 index eda0c7b4583..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToLargestTemporalUnit.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil throw RangeError on ToLargestTemporalUnit with invalide or disallowed unit -info: | - 7. Let largestUnit be ? ToLargestTemporalUnit(options, « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" », "auto", "day"). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -["invalid", "hour", "minute", "second", "millisecond", "microsecond", - "nanosecond"].forEach(function(largestUnit) { - assert.throws(RangeError, () => cal.dateUntil("2021-07-16", "2022-03-04", {largestUnit}), - 'cal.dateUntil("2021-07-16", "2022-03-04", {largestUnit}) throws a RangeError exception'); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToTemporalDate.js deleted file mode 100644 index 75384d627e3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-range-error-ToTemporalDate.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil throw RangeError on ToTemporalDate -info: | - 1. Let calendar be the this value. - 4. Set one to ? ToTemporalDate(one). - 5. Set two to ? ToTemporalDate(two). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.dateUntil("2021-07-16", "invalide date"), - 'cal.dateUntil("2021-07-16", "invalide date") throws a RangeError exception'); -assert.throws(RangeError, () => cal.dateUntil("invalide date", "2021-07-16"), - 'cal.dateUntil("invalide date", "2021-07-16") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-type-error-GetOptionsObject.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-type-error-GetOptionsObject.js deleted file mode 100644 index 3cce0671f02..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/throws-type-error-GetOptionsObject.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Temporal.Calendar.prototype.dateUntil throw TypeError on GetOptionsObject -info: | - 6. Set options to ? GetOptionsObject(options). -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar('iso8601'); - -['string', null, true, false, 123, 456n, Symbol(), Infinity, NaN].forEach(function(opt) { - assert.throws( - TypeError, - () => cal.dateUntil('2021-07-16', '2021-08-11', opt), - 'cal.dateUntil("2021-07-16", "2021-08-11", opt) throws a TypeError exception' - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/year-zero.js deleted file mode 100644 index b6c4ea0415a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dateUntil/year-zero.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dateuntil -description: Negative zero, as extended year, is invalid -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const date = new Temporal.PlainDate(2000, 5, 2); -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; - -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => calendar.dateUntil(arg, date), - "cannot use minus zero as extended date (first argument)" - ); - - assert.throws( - RangeError, - () => calendar.dateUntil(date, arg), - "cannot use minus zero as extended date (second argument)" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 7760bdf2600..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.day(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 8a0b10cd80b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.day(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-constructor-in-calendar-fields.js deleted file mode 100644 index b61e725dd6f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.day -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.day(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-duplicate-calendar-fields.js deleted file mode 100644 index a170c7ad471..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.day -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.day(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-leap-second.js deleted file mode 100644 index 38c3e724ea6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.day(arg); -assert.sameValue( - result1, - 31, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.day(arg); -assert.sameValue( - result2, - 31, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-number.js deleted file mode 100644 index 576fa745a1c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.day(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index dffee306c0b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.day(arg); -assert.sameValue(result, 18, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 3b27c619703..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.day(arg); - assert.sameValue(result, 18, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index f147e6cf626..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.day(arg); -assert.sameValue( - result, - 18, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-number.js deleted file mode 100644 index 728e4d36303..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.day(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-string.js deleted file mode 100644 index 72c2dea5cf7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.day(arg); -assert.sameValue(result, 18, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index a71dcd28d6f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.day(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.day(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index db6c1e0a3a3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.day(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-proto-in-calendar-fields.js deleted file mode 100644 index 01a7de5317f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.day -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.day(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index c883f62f1e5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.day(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation.js deleted file mode 100644 index 622017206eb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.day(arg); - - assert.sameValue( - result, - 2, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 028bdf0b94c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.day(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-date-with-utc-offset.js deleted file mode 100644 index 76bbfee6a50..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.day(arg); - - assert.sameValue( - result, - 2, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.day(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-invalid.js deleted file mode 100644 index 95a33903b79..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.day(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-calendar.js deleted file mode 100644 index 54c4b3fe5ef..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.day(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-time-zone.js deleted file mode 100644 index 252ed87a442..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.day(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-separators.js deleted file mode 100644 index 7b1d040927d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.day(arg); - - assert.sameValue( - result, - 2, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-zone-annotation.js deleted file mode 100644 index 8145e8c70f9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.day(arg); - - assert.sameValue( - result, - 2, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-unknown-annotation.js deleted file mode 100644 index 40038e90dac..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.day(arg); - - assert.sameValue( - result, - 2, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-string-with-utc-designator.js deleted file mode 100644 index 04a1a7af9cc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.day(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-wrong-type.js deleted file mode 100644 index cdc27390301..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.day(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.day(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-convert.js deleted file mode 100644 index 801809482ca..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.day(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-slots.js deleted file mode 100644 index 492ed2456c1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.day(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 4aba77d4c46..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.day(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index d4450fbf865..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.day(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index a30ce83f136..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.day(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 6f26cfb828d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.day(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/basic.js b/test/built-ins/Temporal/Calendar/prototype/day/basic.js deleted file mode 100644 index 3ae7fd4421a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/basic.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Basic tests for day(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 5; -assert.sameValue(iso.day(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.day(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.day(Temporal.PlainMonthDay.from("11-05")), res, "PlainMonthDay"); -assert.sameValue(iso.day({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.day("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.day({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/branding.js b/test/built-ins/Temporal/Calendar/prototype/day/branding.js deleted file mode 100644 index 775ecf6fd1b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const day = Temporal.Calendar.prototype.day; - -assert.sameValue(typeof day, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1)]; - -assert.throws(TypeError, () => day.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => day.apply(null, args), "null"); -assert.throws(TypeError, () => day.apply(true, args), "true"); -assert.throws(TypeError, () => day.apply("", args), "empty string"); -assert.throws(TypeError, () => day.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => day.apply(1, args), "1"); -assert.throws(TypeError, () => day.apply({}, args), "plain object"); -assert.throws(TypeError, () => day.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => day.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/builtin.js b/test/built-ins/Temporal/Calendar/prototype/day/builtin.js deleted file mode 100644 index cb44767482d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Tests that Temporal.Calendar.prototype.day - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.day), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.day), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.day), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.day.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/day/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 80cd4dae2e1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.day({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/day/calendar-fields-iterable.js deleted file mode 100644 index 55a1eb8ebe1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/calendar-fields-iterable.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.day step 4: - 4. Return ? ISODay(_dateOrDateTime_). - sec-temporal-isoday step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(calendar, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.day({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/day/calendar-temporal-object.js deleted file mode 100644 index ce9beec1838..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/calendar-temporal-object.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.day step 4: - 4. Return ? ISODay(_dateOrDateTime_). - sec-temporal-isoday step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.day({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/date-time.js b/test/built-ins/Temporal/Calendar/prototype/day/date-time.js deleted file mode 100644 index 687a01c65cc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/date-time.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Temporal.Calendar.prototype.day will take PlainDateTime and return - the value of the day. -info: | - 5. Return ! ISODay(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let dateTime = new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13) -assert.sameValue(cal.day(dateTime), 23, 'cal.day(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13)) must return 23'); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/date.js b/test/built-ins/Temporal/Calendar/prototype/day/date.js deleted file mode 100644 index 3f4abd38f47..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/date.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Temporal.Calendar.prototype.day will take PlainDate and return - the value of the day. -info: | - 5. Return ! ISODay(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let date = new Temporal.PlainDate(2021, 7, 15); -assert.sameValue(cal.day(date), 15, 'cal.day(new Temporal.PlainDate(2021, 7, 15)) must return 15'); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/day/infinity-throws-rangeerror.js deleted file mode 100644 index 0299adbd58e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.day -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.day({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.day({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/length.js b/test/built-ins/Temporal/Calendar/prototype/day/length.js deleted file mode 100644 index df2b2e82ac8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Temporal.Calendar.prototype.day.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.day, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/month-day.js b/test/built-ins/Temporal/Calendar/prototype/day/month-day.js deleted file mode 100644 index 7a357fe035b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/month-day.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Temporal.Calendar.prototype.day will take PlainMonthDay and return - the value of the day. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have - an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal - slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return ! ISODay(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let monthDay = new Temporal.PlainMonthDay(7, 15); -assert.sameValue(cal.day(monthDay), 15, 'cal.day(new Temporal.PlainMonthDay(7, 15)) must return 15'); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/name.js b/test/built-ins/Temporal/Calendar/prototype/day/name.js deleted file mode 100644 index 260ecb88760..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Temporal.Calendar.prototype.day.name is "day". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.day, "name", { - value: "day", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/day/not-a-constructor.js deleted file mode 100644 index fcb976cd0c3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Temporal.Calendar.prototype.day does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.day(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.day), false, - "isConstructor(Temporal.Calendar.prototype.day)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/day/prop-desc.js deleted file mode 100644 index dd590a2245d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: The "day" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.day, - "function", - "`typeof Calendar.prototype.day` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "day", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/string.js b/test/built-ins/Temporal/Calendar/prototype/day/string.js deleted file mode 100644 index 81a19d9468f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/string.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Temporal.Calendar.prototype.day will take ISO8601 string and return - the value of the day. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have - an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal - slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return ! ISODay(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.sameValue(cal.day("2019-03-15"), 15, 'cal.day("2019-03-15") must return 15'); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/throw-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/day/throw-range-error-ToTemporalDate.js deleted file mode 100644 index 873dd2b1142..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/throw-range-error-ToTemporalDate.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: > - Temporal.Calendar.prototype.day throws RangeError on - ToTemporalDate when temporalDateLike is invalid string. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike - does not have an [[InitializedTemporalDate]] or - [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.day("invalid string"), - 'cal.day("invalid string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js deleted file mode 100644 index 91daa874762..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/day/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.day -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.day(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 66dcdb52550..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.dayOfWeek(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index b90f7f82d78..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.dayOfWeek(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 290f8c82324..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.dayOfWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-duplicate-calendar-fields.js deleted file mode 100644 index 69fbae0f803..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.dayOfWeek(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-leap-second.js deleted file mode 100644 index 4d78c15bbc2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.dayOfWeek(arg); -assert.sameValue( - result1, - 6, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.dayOfWeek(arg); -assert.sameValue( - result2, - 6, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-number.js deleted file mode 100644 index d9e2640c0a8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.dayOfWeek(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 1b285a463e4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.dayOfWeek(arg); -assert.sameValue(result, 4, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 7b631ec7c28..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.dayOfWeek(arg); - assert.sameValue(result, 4, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 616fcd01181..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.dayOfWeek(arg); -assert.sameValue( - result, - 4, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-number.js deleted file mode 100644 index 9841269b65f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.dayOfWeek(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-string.js deleted file mode 100644 index ff85fc04f27..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.dayOfWeek(arg); -assert.sameValue(result, 4, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index eea8ddc492e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.dayOfWeek(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.dayOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index c7dfa7db059..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.dayOfWeek(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-proto-in-calendar-fields.js deleted file mode 100644 index 930b2560ad1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.dayOfWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 67defe4d91b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.dayOfWeek(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation.js deleted file mode 100644 index 3f8737b22d3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dayOfWeek(arg); - - assert.sameValue( - result, - 2, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 8b24b8afd5d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfWeek(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-date-with-utc-offset.js deleted file mode 100644 index b078c711f48..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.dayOfWeek(arg); - - assert.sameValue( - result, - 2, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.dayOfWeek(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-invalid.js deleted file mode 100644 index 77d600bffde..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.dayOfWeek(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-calendar.js deleted file mode 100644 index 51d52285afe..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfWeek(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-time-zone.js deleted file mode 100644 index 33393f9c754..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfWeek(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-separators.js deleted file mode 100644 index 262f525948f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dayOfWeek(arg); - - assert.sameValue( - result, - 2, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-zone-annotation.js deleted file mode 100644 index 36182fdd4b1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dayOfWeek(arg); - - assert.sameValue( - result, - 2, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-unknown-annotation.js deleted file mode 100644 index 806494ecf37..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dayOfWeek(arg); - - assert.sameValue( - result, - 2, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-with-utc-designator.js deleted file mode 100644 index 03e1b79e161..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfWeek(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-wrong-type.js deleted file mode 100644 index 2ffc506ca67..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.dayOfWeek(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.dayOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-convert.js deleted file mode 100644 index b4116255704..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.dayOfWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-slots.js deleted file mode 100644 index 856218e17bc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.dayOfWeek(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 3730b6d373f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.dayOfWeek(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index ce65f9084fd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.dayOfWeek(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 59460de188b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.dayOfWeek(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index dd21b6c28bb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.dayOfWeek(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/basic.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/basic.js deleted file mode 100644 index f8d6b84ae50..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/basic.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Basic tests for dayOfWeek(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 6; -assert.sameValue(iso.dayOfWeek(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.dayOfWeek(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.dayOfWeek({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.dayOfWeek("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.dayOfWeek({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/branding.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/branding.js deleted file mode 100644 index daf44df8342..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const dayOfWeek = Temporal.Calendar.prototype.dayOfWeek; - -assert.sameValue(typeof dayOfWeek, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1)]; - -assert.throws(TypeError, () => dayOfWeek.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => dayOfWeek.apply(null, args), "null"); -assert.throws(TypeError, () => dayOfWeek.apply(true, args), "true"); -assert.throws(TypeError, () => dayOfWeek.apply("", args), "empty string"); -assert.throws(TypeError, () => dayOfWeek.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => dayOfWeek.apply(1, args), "1"); -assert.throws(TypeError, () => dayOfWeek.apply({}, args), "plain object"); -assert.throws(TypeError, () => dayOfWeek.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => dayOfWeek.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/builtin.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/builtin.js deleted file mode 100644 index 85957bda82d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Tests that Temporal.Calendar.prototype.dayOfWeek - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.dayOfWeek), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.dayOfWeek), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.dayOfWeek), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.dayOfWeek.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index e67d34fdcc0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.dayOfWeek({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/calendar-fields-iterable.js deleted file mode 100644 index 3f8a861f64c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/calendar-fields-iterable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.dayofweek step 4: - 4. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.dayOfWeek({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/calendar-temporal-object.js deleted file mode 100644 index bdc9e50e2c4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.dayofweek step 4: - 4. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.dayOfWeek({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/infinity-throws-rangeerror.js deleted file mode 100644 index ad7c225f87e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.dayofweek -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.dayOfWeek({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.dayOfWeek({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/length.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/length.js deleted file mode 100644 index 0192cbf9157..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Temporal.Calendar.prototype.dayOfWeek.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dayOfWeek, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/name.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/name.js deleted file mode 100644 index ea8c9f97943..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Temporal.Calendar.prototype.dayOfWeek.name is "dayOfWeek". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dayOfWeek, "name", { - value: "dayOfWeek", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/not-a-constructor.js deleted file mode 100644 index b5a3810f4be..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Temporal.Calendar.prototype.dayOfWeek does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.dayOfWeek(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.dayOfWeek), false, - "isConstructor(Temporal.Calendar.prototype.dayOfWeek)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/plain-date-time.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/plain-date-time.js deleted file mode 100644 index b85f84c9d16..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/plain-date-time.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Temporal.Calendar.prototype.dayOfWeek will take Temporal.PlainDateTime objects - and return the day of week. -info: | - 5. Return 𝔽(! ToISODayOfWeek(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let dt = new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13); -assert.sameValue( - cal.dayOfWeek(dt), - 4, - 'cal.dayOfWeek(new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13)) must return 4' -); -dt = new Temporal.PlainDateTime(1996, 2, 23, 5, 30, 13); -assert.sameValue( - cal.dayOfWeek(dt), - 5, - 'cal.dayOfWeek(new Temporal.PlainDateTime(1996, 2, 23, 5, 30, 13)) must return 5' -); -dt = new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13); -assert.sameValue( - cal.dayOfWeek(dt), - 7, - 'cal.dayOfWeek(new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13)) must return 7' -); -dt = new Temporal.PlainDateTime(1997, 6, 23, 5, 30, 13); -assert.sameValue( - cal.dayOfWeek(dt), - 1, - 'cal.dayOfWeek(new Temporal.PlainDateTime(1997, 6, 23, 5, 30, 13)) must return 1' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/plain-date.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/plain-date.js deleted file mode 100644 index 5a629c25cdf..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/plain-date.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Temporal.Calendar.prototype.dayOfWeek will take Temporal.PlainDate objects - and return the day of week. -info: | - 5. Return 𝔽(! ToISODayOfWeek(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let d = new Temporal.PlainDate(1970, 1, 1); -assert.sameValue(4, cal.dayOfWeek(d), '4 must return the same value returned by cal.dayOfWeek(d)'); -d = new Temporal.PlainDate(2021, 2, 15); -assert.sameValue(1, cal.dayOfWeek(d), '1 must return the same value returned by cal.dayOfWeek(d)'); -d = new Temporal.PlainDate(2021, 8, 15); -assert.sameValue(7, cal.dayOfWeek(d), '7 must return the same value returned by cal.dayOfWeek(d)'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/prop-desc.js deleted file mode 100644 index 8f8f31290a0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: The "dayOfWeek" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.dayOfWeek, - "function", - "`typeof Calendar.prototype.dayOfWeek` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "dayOfWeek", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/string.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/string.js deleted file mode 100644 index d1066e605f9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/string.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: > - Temporal.Calendar.prototype.dayOfWeek will take ISO8601 string - and return the day of week. -info: | - 4. Let temporalDate be ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ToISODayOfWeek(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.sameValue(cal.dayOfWeek("2019-01-18"), 5, 'cal.dayOfWeek("2019-01-18") must return 5'); -assert.sameValue(cal.dayOfWeek("2019-03-18"), 1, 'cal.dayOfWeek("2019-03-18") must return 1'); -assert.sameValue(cal.dayOfWeek("2019-05-18"), 6, 'cal.dayOfWeek("2019-05-18") must return 6'); -assert.sameValue(cal.dayOfWeek("2019-08-18"), 7, 'cal.dayOfWeek("2019-08-18") must return 7'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/throw-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/throw-range-error-ToTemporalDate.js deleted file mode 100644 index 5ecccf52283..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/throw-range-error-ToTemporalDate.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayOfWeek -description: > - Temporal.Calendar.prototype.dayOfWeek throws RangeError on - ToTemporalDate when temporalDateLike is invalid string. -info: | - 4. Let temporalDate be ? ToTemporalDate(temporalDateLike). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.dayOfWeek("invalid string"), - 'cal.dayOfWeek("invalid string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/year-zero.js deleted file mode 100644 index 0d887a39780..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfWeek(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index c14286eb273..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.dayOfYear(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index bca628c0f93..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.dayOfYear(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-constructor-in-calendar-fields.js deleted file mode 100644 index f48a2ec2def..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.dayOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-duplicate-calendar-fields.js deleted file mode 100644 index 3434126f799..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.dayOfYear(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-leap-second.js deleted file mode 100644 index f41dfb5f736..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.dayOfYear(arg); -assert.sameValue( - result1, - 366, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.dayOfYear(arg); -assert.sameValue( - result2, - 366, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-number.js deleted file mode 100644 index c147954c580..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.dayOfYear(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index d1d195f9540..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.dayOfYear(arg); -assert.sameValue(result, 323, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index d33484f8a22..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.dayOfYear(arg); - assert.sameValue(result, 323, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index ca8263b8e19..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.dayOfYear(arg); -assert.sameValue( - result, - 323, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-number.js deleted file mode 100644 index 1c621af7b79..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.dayOfYear(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-string.js deleted file mode 100644 index 8d56f169b4a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.dayOfYear(arg); -assert.sameValue(result, 323, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 452c1216020..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.dayOfYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.dayOfYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index a5217dbd38c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.dayOfYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-proto-in-calendar-fields.js deleted file mode 100644 index 723c9e39d96..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.dayOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 11583c26993..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.dayOfYear(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation.js deleted file mode 100644 index 0235ad75bee..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dayOfYear(arg); - - assert.sameValue( - result, - 123, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-critical-unknown-annotation.js deleted file mode 100644 index cdccc47fec8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfYear(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-date-with-utc-offset.js deleted file mode 100644 index 6aec6f3c0fb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.dayOfYear(arg); - - assert.sameValue( - result, - 123, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.dayOfYear(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-invalid.js deleted file mode 100644 index 8768faa6381..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.dayOfYear(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-calendar.js deleted file mode 100644 index f66c4785e29..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfYear(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-time-zone.js deleted file mode 100644 index 8dd85df4bfd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfYear(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-separators.js deleted file mode 100644 index 5d0f4363a64..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dayOfYear(arg); - - assert.sameValue( - result, - 123, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-zone-annotation.js deleted file mode 100644 index 8978c0ccbde..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dayOfYear(arg); - - assert.sameValue( - result, - 123, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-unknown-annotation.js deleted file mode 100644 index dbeb37d96f8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.dayOfYear(arg); - - assert.sameValue( - result, - 123, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-with-utc-designator.js deleted file mode 100644 index 9a9a64034da..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfYear(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-wrong-type.js deleted file mode 100644 index bd7d078b791..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.dayOfYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.dayOfYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-convert.js deleted file mode 100644 index 81fb544505c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.dayOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-slots.js deleted file mode 100644 index 8738b2649ed..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.dayOfYear(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 086fe1d5530..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.dayOfYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index a77d6dbff7d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.dayOfYear(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 19011a7dd89..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.dayOfYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index ec98fd7ede7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.dayOfYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/basic.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/basic.js deleted file mode 100644 index 6c1621547a7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/basic.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Basic tests for dayOfYear(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 309; -assert.sameValue(iso.dayOfYear(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.dayOfYear(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.dayOfYear({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.dayOfYear("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.dayOfYear({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/branding.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/branding.js deleted file mode 100644 index 93ccd917845..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const dayOfYear = Temporal.Calendar.prototype.dayOfYear; - -assert.sameValue(typeof dayOfYear, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1)]; - -assert.throws(TypeError, () => dayOfYear.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => dayOfYear.apply(null, args), "null"); -assert.throws(TypeError, () => dayOfYear.apply(true, args), "true"); -assert.throws(TypeError, () => dayOfYear.apply("", args), "empty string"); -assert.throws(TypeError, () => dayOfYear.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => dayOfYear.apply(1, args), "1"); -assert.throws(TypeError, () => dayOfYear.apply({}, args), "plain object"); -assert.throws(TypeError, () => dayOfYear.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => dayOfYear.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/builtin.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/builtin.js deleted file mode 100644 index 8abab318b23..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Tests that Temporal.Calendar.prototype.dayOfYear - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.dayOfYear), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.dayOfYear), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.dayOfYear), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.dayOfYear.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 2ebc1c96f30..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.dayOfYear({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/calendar-fields-iterable.js deleted file mode 100644 index 902ec1f349d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/calendar-fields-iterable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.dayofyear step 4: - 4. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.dayOfYear({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/calendar-temporal-object.js deleted file mode 100644 index 414c9ac960f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.dayofyear step 4: - 4. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.dayOfYear({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/infinity-throws-rangeerror.js deleted file mode 100644 index 50a59ef1567..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.dayofyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.dayOfYear({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.dayOfYear({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/length.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/length.js deleted file mode 100644 index 045b87e800e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Temporal.Calendar.prototype.dayOfYear.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dayOfYear, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/name.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/name.js deleted file mode 100644 index 60dfa0b8e9a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Temporal.Calendar.prototype.dayOfYear.name is "dayOfYear". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.dayOfYear, "name", { - value: "dayOfYear", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/not-a-constructor.js deleted file mode 100644 index c66309a410f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Temporal.Calendar.prototype.dayOfYear does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.dayOfYear(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.dayOfYear), false, - "isConstructor(Temporal.Calendar.prototype.dayOfYear)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/plain-date-time.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/plain-date-time.js deleted file mode 100644 index fa20620da1a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/plain-date-time.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Temporal.Calendar.prototype.dayOfYear will take PlainDateTime object and - return the day of year. -info: | - 4. Let temporalDate be ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ToISODayOfYear(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let dt = new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13); -assert.sameValue( - cal.dayOfYear(dt), - 23, - 'cal.dayOfYear(new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13)) must return 23' -); - -dt = new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13); -assert.sameValue( - cal.dayOfYear(dt), - 54, - 'cal.dayOfYear(new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13)) must return 54' -); - -dt = new Temporal.PlainDateTime(1996, 3, 23, 5, 30, 13); -assert.sameValue( - cal.dayOfYear(dt), - 83, - 'cal.dayOfYear(new Temporal.PlainDateTime(1996, 3, 23, 5, 30, 13)) must return 83' -); - -dt = new Temporal.PlainDateTime(1997, 3, 23, 5, 30, 13); -assert.sameValue( - cal.dayOfYear(dt), - 82, - 'cal.dayOfYear(new Temporal.PlainDateTime(1997, 3, 23, 5, 30, 13)) must return 82' -); - -dt = new Temporal.PlainDateTime(1997, 12, 31, 5, 30, 13); -assert.sameValue( - cal.dayOfYear(dt), - 365, - 'cal.dayOfYear(new Temporal.PlainDateTime(1997, 12, 31, 5, 30, 13)) must return 365' -); - -dt = new Temporal.PlainDateTime(1996, 12, 31, 5, 30, 13); -assert.sameValue( - cal.dayOfYear(dt), - 366, - 'cal.dayOfYear(new Temporal.PlainDateTime(1996, 12, 31, 5, 30, 13)) must return 366' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/plain-date.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/plain-date.js deleted file mode 100644 index 64096e4498b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/plain-date.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Temporal.Calendar.prototype.dayOfYear will take PlainDate object and - return the day of year. -info: | - 5. Return 𝔽(! ToISODayOfYear(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let d = new Temporal.PlainDate(1970, 1, 1); -assert.sameValue(cal.dayOfYear(d), 1, 'cal.dayOfYear(new Temporal.PlainDate(1970, 1, 1)) must return 1'); -d = new Temporal.PlainDate(2000, 1, 1); -assert.sameValue(cal.dayOfYear(d), 1, 'cal.dayOfYear(new Temporal.PlainDate(2000, 1, 1)) must return 1'); - -d = new Temporal.PlainDate(2021, 1, 15); -assert.sameValue(cal.dayOfYear(d), 15, 'cal.dayOfYear(new Temporal.PlainDate(2021, 1, 15)) must return 15'); - -d = new Temporal.PlainDate(2020, 2, 15); -assert.sameValue(cal.dayOfYear(d), 46, 'cal.dayOfYear(new Temporal.PlainDate(2020, 2, 15)) must return 46'); - -d = new Temporal.PlainDate(2020, 3, 15); -assert.sameValue(cal.dayOfYear(d), 75, 'cal.dayOfYear(new Temporal.PlainDate(2020, 3, 15)) must return 75'); - -d = new Temporal.PlainDate(2000, 3, 15); -assert.sameValue(cal.dayOfYear(d), 75, 'cal.dayOfYear(new Temporal.PlainDate(2000, 3, 15)) must return 75'); - -d = new Temporal.PlainDate(2001, 3, 15); -assert.sameValue(cal.dayOfYear(d), 74, 'cal.dayOfYear(new Temporal.PlainDate(2001, 3, 15)) must return 74'); - -d = new Temporal.PlainDate(2000, 12, 31); -assert.sameValue(cal.dayOfYear(d), 366, 'cal.dayOfYear(new Temporal.PlainDate(2000, 12, 31)) must return 366'); - -d = new Temporal.PlainDate(2001, 12, 31); -assert.sameValue(cal.dayOfYear(d), 365, 'cal.dayOfYear(new Temporal.PlainDate(2001, 12, 31)) must return 365'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/prop-desc.js deleted file mode 100644 index 6d9c5be9123..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: The "dayOfYear" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.dayOfYear, - "function", - "`typeof Calendar.prototype.dayOfYear` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "dayOfYear", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/string.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/string.js deleted file mode 100644 index 5a0bbb583a5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/string.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: > - Temporal.Calendar.prototype.dayOfYear will take ISO8601 string and - return the day of year. -info: | - 4. Let temporalDate be ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ToISODayOfYear(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.sameValue( - cal.dayOfYear("2019-01-18"), - 18, - 'cal.dayOfYear("2019-01-18") must return 18' -); -assert.sameValue( - cal.dayOfYear("2020-02-18"), - 49, - 'cal.dayOfYear("2020-02-18") must return 49' -); -assert.sameValue( - cal.dayOfYear("2019-12-31"), - 365, - 'cal.dayOfYear("2019-12-31") must return 365' -); -assert.sameValue( - cal.dayOfYear("2000-12-31"), - 366, - 'cal.dayOfYear("2000-12-31") must return 366' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/throw-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/throw-range-error-ToTemporalDate.js deleted file mode 100644 index d720c8c52a9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/throw-range-error-ToTemporalDate.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.dayOfYear -description: > - Temporal.Calendar.prototype.dayOfYear throws RangeError on - ToTemporalDate when temporalDateLike is invalid string. -info: | - 4. Let temporalDate be ? ToTemporalDate(temporalDateLike). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.dayOfYear("invalid string"), - 'cal.dayOfYear("invalid string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/year-zero.js deleted file mode 100644 index 6fec20e4691..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.dayOfYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 86604156b73..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.daysInMonth(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 6a4924c0a28..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.daysInMonth(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-constructor-in-calendar-fields.js deleted file mode 100644 index c424f636f2c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.daysInMonth(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-duplicate-calendar-fields.js deleted file mode 100644 index dc0081f5da4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.daysInMonth(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-leap-second.js deleted file mode 100644 index 3274f449169..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.daysInMonth(arg); -assert.sameValue( - result1, - 31, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.daysInMonth(arg); -assert.sameValue( - result2, - 31, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-number.js deleted file mode 100644 index 69a369ae85c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.daysInMonth(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index ca24cf52ad2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.daysInMonth(arg); -assert.sameValue(result, 30, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index e78affabc26..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.daysInMonth(arg); - assert.sameValue(result, 30, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 40ce56d528a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.daysInMonth(arg); -assert.sameValue( - result, - 30, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-number.js deleted file mode 100644 index fe4e8d04a62..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.daysInMonth(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-string.js deleted file mode 100644 index 5b27cf9e200..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.daysInMonth(arg); -assert.sameValue(result, 30, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 45ad76393a4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.daysInMonth(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.daysInMonth(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 462d8e42c44..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.daysInMonth(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-proto-in-calendar-fields.js deleted file mode 100644 index 397e366f918..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.daysInMonth(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index be5615d56fb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.daysInMonth(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation.js deleted file mode 100644 index 059c2aea608..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInMonth(arg); - - assert.sameValue( - result, - 31, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-critical-unknown-annotation.js deleted file mode 100644 index bfd23689e38..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInMonth(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-date-with-utc-offset.js deleted file mode 100644 index 2ef94ed68cb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.daysInMonth(arg); - - assert.sameValue( - result, - 31, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.daysInMonth(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-invalid.js deleted file mode 100644 index 97ecac0fa8f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.daysInMonth(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-calendar.js deleted file mode 100644 index 2738cd5d665..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInMonth(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-time-zone.js deleted file mode 100644 index fd86a9be34a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInMonth(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-separators.js deleted file mode 100644 index 53b94d83dbe..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInMonth(arg); - - assert.sameValue( - result, - 31, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-zone-annotation.js deleted file mode 100644 index 36d7a5d194a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInMonth(arg); - - assert.sameValue( - result, - 31, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-unknown-annotation.js deleted file mode 100644 index 8541062e59f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInMonth(arg); - - assert.sameValue( - result, - 31, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-with-utc-designator.js deleted file mode 100644 index c0c1db53d34..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInMonth(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-wrong-type.js deleted file mode 100644 index e41fdfe7b78..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.daysInMonth(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.daysInMonth(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-convert.js deleted file mode 100644 index db08f3038e1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.daysInMonth(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-slots.js deleted file mode 100644 index c6a233a87d7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.daysInMonth(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 9d38028a54a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.daysInMonth(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index a1b25778320..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.daysInMonth(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 45e5734a3af..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.daysInMonth(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 73b153938d4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.daysInMonth(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/basic.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/basic.js deleted file mode 100644 index 7405e97587a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/basic.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Basic tests for daysInMonth(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 30; -assert.sameValue(iso.daysInMonth(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.daysInMonth(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.daysInMonth({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.daysInMonth("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.daysInMonth({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/branding.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/branding.js deleted file mode 100644 index 167035dcad4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const daysInMonth = Temporal.Calendar.prototype.daysInMonth; - -assert.sameValue(typeof daysInMonth, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1)]; - -assert.throws(TypeError, () => daysInMonth.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => daysInMonth.apply(null, args), "null"); -assert.throws(TypeError, () => daysInMonth.apply(true, args), "true"); -assert.throws(TypeError, () => daysInMonth.apply("", args), "empty string"); -assert.throws(TypeError, () => daysInMonth.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => daysInMonth.apply(1, args), "1"); -assert.throws(TypeError, () => daysInMonth.apply({}, args), "plain object"); -assert.throws(TypeError, () => daysInMonth.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => daysInMonth.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/builtin.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/builtin.js deleted file mode 100644 index d588deb0aab..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Tests that Temporal.Calendar.prototype.daysInMonth - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.daysInMonth), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.daysInMonth), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.daysInMonth), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.daysInMonth.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 86e25eb109a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.daysInMonth({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-fields-iterable.js deleted file mode 100644 index 835fc7bea21..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-fields-iterable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.daysinmonth step 4.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.daysInMonth({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-temporal-object.js deleted file mode 100644 index a2aa62f9e37..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.daysinmonth step 4.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.daysInMonth({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/infinity-throws-rangeerror.js deleted file mode 100644 index 83a50e18cbc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.daysinmonth -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.daysInMonth({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.daysInMonth({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/length.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/length.js deleted file mode 100644 index ca315427f3e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Temporal.Calendar.prototype.daysInMonth.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.daysInMonth, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/name.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/name.js deleted file mode 100644 index 8634c31f4bd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Temporal.Calendar.prototype.daysInMonth.name is "daysInMonth". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.daysInMonth, "name", { - value: "daysInMonth", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/not-a-constructor.js deleted file mode 100644 index d621f79b0b6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Temporal.Calendar.prototype.daysInMonth does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.daysInMonth(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.daysInMonth), false, - "isConstructor(Temporal.Calendar.prototype.daysInMonth)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/plain-date-time.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/plain-date-time.js deleted file mode 100644 index d8e902c8e6c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/plain-date-time.js +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Temporal.Calendar.prototype.daysInMonth will take Temporal.PlainDateTime object - and return the number of days in that month. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slots, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ISODaysInMonth(temporalDateLike.[[ISOYear]], temporalDateLike.[[ISOMonth]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let dt = new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 31, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 1, 23, 5, 30, 13)) must return 31' -); - -// leap year -dt = new Temporal.PlainDateTime(1996, 2, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 29, - 'cal.daysInMonth(new Temporal.PlainDateTime(1996, 2, 23, 5, 30, 13)) must return 29' -); -dt = new Temporal.PlainDateTime(2000, 2, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 29, - 'cal.daysInMonth(new Temporal.PlainDateTime(2000, 2, 23, 5, 30, 13)) must return 29' -); - -// non leap year -dt = new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 28, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 2, 23, 5, 30, 13)) must return 28' -); - -dt = new Temporal.PlainDateTime(1997, 3, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 31, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 3, 23, 5, 30, 13)) must return 31' -); - -dt = new Temporal.PlainDateTime(1997, 4, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 30, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 4, 23, 5, 30, 13)) must return 30' -); - -dt = new Temporal.PlainDateTime(1997, 5, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 31, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 5, 23, 5, 30, 13)) must return 31' -); - -dt = new Temporal.PlainDateTime(1997, 6, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 30, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 6, 23, 5, 30, 13)) must return 30' -); - -dt = new Temporal.PlainDateTime(1997, 7, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 31, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 7, 23, 5, 30, 13)) must return 31' -); - -dt = new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 31, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13)) must return 31' -); - -dt = new Temporal.PlainDateTime(1997, 9, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 30, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 9, 23, 5, 30, 13)) must return 30' -); - -dt = new Temporal.PlainDateTime(1997, 10, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 31, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 10, 23, 5, 30, 13)) must return 31' -); - -dt = new Temporal.PlainDateTime(1997, 11, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 30, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 11, 23, 5, 30, 13)) must return 30' -); - -dt = new Temporal.PlainDateTime(1997, 12, 23, 5, 30, 13); -assert.sameValue( - cal.daysInMonth(dt), - 31, - 'cal.daysInMonth(new Temporal.PlainDateTime(1997, 12, 23, 5, 30, 13)) must return 31' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/plain-date.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/plain-date.js deleted file mode 100644 index 86a98d0ecca..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/plain-date.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Temporal.Calendar.prototype.daysInMonth will take Temporal.PlainDate object - and return the number of days in that month. -info: | - 5. Return 𝔽(! ISODaysInMonth(temporalDateLike.[[ISOYear]], temporalDateLike.[[ISOMonth]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let d = new Temporal.PlainDate(2021, 1, 15); -assert.sameValue(cal.daysInMonth(d), 31, 'cal.daysInMonth(new Temporal.PlainDate(2021, 1, 15)) must return 31'); - -// non-leap year -d = new Temporal.PlainDate(2021, 2, 15); -assert.sameValue(cal.daysInMonth(d), 28, 'cal.daysInMonth(new Temporal.PlainDate(2021, 2, 15)) must return 28'); - -// leap year -d = new Temporal.PlainDate(2020, 2, 15); -assert.sameValue(cal.daysInMonth(d), 29, 'cal.daysInMonth(new Temporal.PlainDate(2020, 2, 15)) must return 29'); -d = new Temporal.PlainDate(2000, 2, 15); -assert.sameValue(cal.daysInMonth(d), 29, 'cal.daysInMonth(new Temporal.PlainDate(2000, 2, 15)) must return 29'); - -d = new Temporal.PlainDate(2021, 3, 15); -assert.sameValue(cal.daysInMonth(d), 31, 'cal.daysInMonth(new Temporal.PlainDate(2021, 3, 15)) must return 31'); - -d = new Temporal.PlainDate(2021, 4, 15); -assert.sameValue(cal.daysInMonth(d), 30, 'cal.daysInMonth(new Temporal.PlainDate(2021, 4, 15)) must return 30'); - -d = new Temporal.PlainDate(2021, 5, 15); -assert.sameValue(cal.daysInMonth(d), 31, 'cal.daysInMonth(new Temporal.PlainDate(2021, 5, 15)) must return 31'); - -d = new Temporal.PlainDate(2021, 6, 15); -assert.sameValue(cal.daysInMonth(d), 30, 'cal.daysInMonth(new Temporal.PlainDate(2021, 6, 15)) must return 30'); - -d = new Temporal.PlainDate(2021, 7, 15); -assert.sameValue(cal.daysInMonth(d), 31, 'cal.daysInMonth(new Temporal.PlainDate(2021, 7, 15)) must return 31'); - -d = new Temporal.PlainDate(2021, 8, 15); -assert.sameValue(cal.daysInMonth(d), 31, 'cal.daysInMonth(new Temporal.PlainDate(2021, 8, 15)) must return 31'); - -d = new Temporal.PlainDate(2021, 9, 15); -assert.sameValue(cal.daysInMonth(d), 30, 'cal.daysInMonth(new Temporal.PlainDate(2021, 9, 15)) must return 30'); - -d = new Temporal.PlainDate(2021, 10, 15); -assert.sameValue(cal.daysInMonth(d), 31, 'cal.daysInMonth(new Temporal.PlainDate(2021, 10, 15)) must return 31'); - -d = new Temporal.PlainDate(2021, 11, 15); -assert.sameValue(cal.daysInMonth(d), 30, 'cal.daysInMonth(new Temporal.PlainDate(2021, 11, 15)) must return 30'); - -d = new Temporal.PlainDate(2021, 12, 15); -assert.sameValue(cal.daysInMonth(d), 31, 'cal.daysInMonth(new Temporal.PlainDate(2021, 12, 15)) must return 31'); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/prop-desc.js deleted file mode 100644 index 5ea6170c686..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: The "daysInMonth" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.daysInMonth, - "function", - "`typeof Calendar.prototype.daysInMonth` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "daysInMonth", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/string.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/string.js deleted file mode 100644 index 9e21d79b980..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/string.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: > - Temporal.Calendar.prototype.daysInMonth will take ISO8601 string - and return the number of days in that month. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have - an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal - slots, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ISODaysInMonth(temporalDateLike.[[ISOYear]], temporalDateLike.[[ISOMonth]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.sameValue(cal.daysInMonth("2019-01-18"), 31, 'cal.daysInMonth("2019-01-18") must return 31'); -// leap year -assert.sameValue(cal.daysInMonth("2020-02-18"), 29, 'cal.daysInMonth("2020-02-18") must return 29'); -// non leap -assert.sameValue(cal.daysInMonth("2019-02-18"), 28, 'cal.daysInMonth("2019-02-18") must return 28'); -assert.sameValue(cal.daysInMonth("2019-03-18"), 31, 'cal.daysInMonth("2019-03-18") must return 31'); -assert.sameValue(cal.daysInMonth("2019-04-18"), 30, 'cal.daysInMonth("2019-04-18") must return 30'); -assert.sameValue(cal.daysInMonth("2019-05-18"), 31, 'cal.daysInMonth("2019-05-18") must return 31'); -assert.sameValue(cal.daysInMonth("2019-06-18"), 30, 'cal.daysInMonth("2019-06-18") must return 30'); -assert.sameValue(cal.daysInMonth("2019-07-18"), 31, 'cal.daysInMonth("2019-07-18") must return 31'); -assert.sameValue(cal.daysInMonth("2019-08-18"), 31, 'cal.daysInMonth("2019-08-18") must return 31'); -assert.sameValue(cal.daysInMonth("2019-09-18"), 30, 'cal.daysInMonth("2019-09-18") must return 30'); -assert.sameValue(cal.daysInMonth("2019-10-18"), 31, 'cal.daysInMonth("2019-10-18") must return 31'); -assert.sameValue(cal.daysInMonth("2019-11-18"), 30, 'cal.daysInMonth("2019-11-18") must return 30'); -assert.sameValue(cal.daysInMonth("2019-12-18"), 31, 'cal.daysInMonth("2019-12-18") must return 31'); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/throw-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/throw-range-error-ToTemporalDate.js deleted file mode 100644 index 538fa92836e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/throw-range-error-ToTemporalDate.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysInMonth -description: > - Temporal.Calendar.prototype.daysInMonth throws RangeError on - ToTemporalDate when temporalDateLike is invalid string. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have - an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal - slots, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.daysInMonth("invalid string"), - 'cal.daysInMonth("invalid string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/year-zero.js deleted file mode 100644 index d4a5d70149b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinmonth -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInMonth(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 4affcad77d0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.daysInWeek(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index e2e2f472d8a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.daysInWeek(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 6db6ae26881..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.daysInWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-duplicate-calendar-fields.js deleted file mode 100644 index 9abf392169f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.daysInWeek(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-leap-second.js deleted file mode 100644 index b88af835e50..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.daysInWeek(arg); -assert.sameValue( - result1, - 7, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.daysInWeek(arg); -assert.sameValue( - result2, - 7, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-number.js deleted file mode 100644 index d6b7bb535de..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.daysInWeek(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 6616112eb03..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.daysInWeek(arg); -assert.sameValue(result, 7, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index d6165f639fb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.daysInWeek(arg); - assert.sameValue(result, 7, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index ff74cf1de1c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.daysInWeek(arg); -assert.sameValue( - result, - 7, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-number.js deleted file mode 100644 index 32f26e66e68..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.daysInWeek(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-string.js deleted file mode 100644 index 7f4f5105575..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.daysInWeek(arg); -assert.sameValue(result, 7, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 4a289448570..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.daysInWeek(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.daysInWeek(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 70335a5d01c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.daysInWeek(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-proto-in-calendar-fields.js deleted file mode 100644 index 8198113c231..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.daysInWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index ea1697559e6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.daysInWeek(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation.js deleted file mode 100644 index e0867649e51..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInWeek(arg); - - assert.sameValue( - result, - 7, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-critical-unknown-annotation.js deleted file mode 100644 index d6a7f654750..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInWeek(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-date-with-utc-offset.js deleted file mode 100644 index ac216a5ffad..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.daysInWeek(arg); - - assert.sameValue( - result, - 7, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.daysInWeek(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-invalid.js deleted file mode 100644 index 9c98bd32957..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.daysInWeek(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-calendar.js deleted file mode 100644 index 3b0bc93a041..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInWeek(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-time-zone.js deleted file mode 100644 index 43af6dac0cd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInWeek(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-separators.js deleted file mode 100644 index 1e545cfe0d9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInWeek(arg); - - assert.sameValue( - result, - 7, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-zone-annotation.js deleted file mode 100644 index 82603259fea..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInWeek(arg); - - assert.sameValue( - result, - 7, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-unknown-annotation.js deleted file mode 100644 index 56f900bb369..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInWeek(arg); - - assert.sameValue( - result, - 7, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-with-utc-designator.js deleted file mode 100644 index 3db13fecb3a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInWeek(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-wrong-type.js deleted file mode 100644 index 3cdfb3c1de1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.daysInWeek(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.daysInWeek(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-convert.js deleted file mode 100644 index aec5f24ffec..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.daysInWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-slots.js deleted file mode 100644 index 2a96f91e2c9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.daysInWeek(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 03c9ed64332..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.daysInWeek(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 5e6bbc198cc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.daysInWeek(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index cdae7d999ef..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.daysInWeek(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index b9c8693588a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.daysInWeek(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/basic.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/basic.js deleted file mode 100644 index 4392bc53224..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/basic.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Basic tests for daysInWeek(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 7; -assert.sameValue(iso.daysInWeek(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.daysInWeek(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.daysInWeek({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.daysInWeek("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.daysInWeek({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/branding.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/branding.js deleted file mode 100644 index cb0da2bd22a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const daysInWeek = Temporal.Calendar.prototype.daysInWeek; - -assert.sameValue(typeof daysInWeek, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1)]; - -assert.throws(TypeError, () => daysInWeek.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => daysInWeek.apply(null, args), "null"); -assert.throws(TypeError, () => daysInWeek.apply(true, args), "true"); -assert.throws(TypeError, () => daysInWeek.apply("", args), "empty string"); -assert.throws(TypeError, () => daysInWeek.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => daysInWeek.apply(1, args), "1"); -assert.throws(TypeError, () => daysInWeek.apply({}, args), "plain object"); -assert.throws(TypeError, () => daysInWeek.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => daysInWeek.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/builtin.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/builtin.js deleted file mode 100644 index e7781c447d7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: > - Tests that Temporal.Calendar.prototype.daysInWeek - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.daysInWeek), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.daysInWeek), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.daysInWeek), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.daysInWeek.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 68e86ffc1e5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.daysInWeek({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-fields-iterable.js deleted file mode 100644 index fdc68aee0d1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-fields-iterable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.daysinweek step 4: - 4. Perform ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.daysInWeek({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-temporal-object.js deleted file mode 100644 index 2cf851b1ff5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.daysinweek step 4: - 4. Perform ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.daysInWeek({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/date-time.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/date-time.js deleted file mode 100644 index 9f16c42507b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/date-time.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinweeks -description: Temporal.Calendar.prototype.daysInWeek will take PlainDateTime and return 7. -info: | - 4. Perform ? ToTemporalDate(temporalDateLike). - 5. Return 7𝔽. -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let dt = new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInWeek(dt), - 7, - 'cal.daysInWeek(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13)) must return 7' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/date.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/date.js deleted file mode 100644 index f7a88e4f2a9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/date.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinweeks -description: Temporal.Calendar.prototype.daysInWeek will take PlainDate and return 7. -info: | - 5. Return 7𝔽. -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let d = new Temporal.PlainDate(2021, 7, 15); -assert.sameValue(cal.daysInWeek(d), 7, 'cal.daysInWeek(new Temporal.PlainDate(2021, 7, 15)) must return 7'); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/infinity-throws-rangeerror.js deleted file mode 100644 index 2e44133cdc3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.daysinweek -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.daysInWeek({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.daysInWeek({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/length.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/length.js deleted file mode 100644 index 5cdbe2226e7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Temporal.Calendar.prototype.daysInWeek.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.daysInWeek, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/name.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/name.js deleted file mode 100644 index 06e99bcb85c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Temporal.Calendar.prototype.daysInWeek.name is "daysInWeek". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.daysInWeek, "name", { - value: "daysInWeek", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/not-a-constructor.js deleted file mode 100644 index 0d37c1cfc7a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: > - Temporal.Calendar.prototype.daysInWeek does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.daysInWeek(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.daysInWeek), false, - "isConstructor(Temporal.Calendar.prototype.daysInWeek)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/prop-desc.js deleted file mode 100644 index 0b597f93d86..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: The "daysInWeek" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.daysInWeek, - "function", - "`typeof Calendar.prototype.daysInWeek` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "daysInWeek", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/string.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/string.js deleted file mode 100644 index bdca739cc86..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/string.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinweeks -description: > - Temporal.Calendar.prototype.daysInWeek will take valid ISO8601 string - and return 7. -info: | - 4. Perform ? ToTemporalDate(temporalDateLike). - 5. Return 7𝔽. -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); -assert.sameValue(cal.daysInWeek("2019-03-18"), 7, 'cal.daysInWeek("2019-03-18") must return 7'); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/throw-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/throw-range-error-ToTemporalDate.js deleted file mode 100644 index 8eab417f80e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/throw-range-error-ToTemporalDate.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysInWeek -description: > - Temporal.Calendar.prototype.daysInWeek throws RangeError on - ToTemporalDate when temporalDateLike is invalid string. -info: | - 4. Let temporalDate be ? ToTemporalDate(temporalDateLike). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.daysInWeek("invalid string"), - 'cal.daysInWeek("invalid string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/year-zero.js deleted file mode 100644 index 67caad3a5e6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinweek -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInWeek(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 853b733cfb5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.daysInYear(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 9d14fa2b87b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.daysInYear(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 6d76185838a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.daysInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-duplicate-calendar-fields.js deleted file mode 100644 index b1e3ca69352..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.daysInYear(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-leap-second.js deleted file mode 100644 index ab2f0fb25b5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.daysInYear(arg); -assert.sameValue( - result1, - 366, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.daysInYear(arg); -assert.sameValue( - result2, - 366, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-number.js deleted file mode 100644 index db378618444..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.daysInYear(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 401ba888a9e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.daysInYear(arg); -assert.sameValue(result, 366, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 1fc57421437..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.daysInYear(arg); - assert.sameValue(result, 366, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 32595247a43..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.daysInYear(arg); -assert.sameValue( - result, - 366, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-number.js deleted file mode 100644 index 2679323a38c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.daysInYear(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-string.js deleted file mode 100644 index 3ce72bbc344..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.daysInYear(arg); -assert.sameValue(result, 366, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 5b155d42ada..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.daysInYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.daysInYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 3ba5ba745e2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.daysInYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-proto-in-calendar-fields.js deleted file mode 100644 index 7fe5c089ab5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.daysInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 8720589b58d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.daysInYear(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation.js deleted file mode 100644 index b55d8408508..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInYear(arg); - - assert.sameValue( - result, - 366, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 65a7981d01e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInYear(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-date-with-utc-offset.js deleted file mode 100644 index dcebadfb47d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.daysInYear(arg); - - assert.sameValue( - result, - 366, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.daysInYear(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-invalid.js deleted file mode 100644 index 8d92ef970d0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.daysInYear(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-calendar.js deleted file mode 100644 index fbfda521dfe..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInYear(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-time-zone.js deleted file mode 100644 index e91a96ca07a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInYear(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-separators.js deleted file mode 100644 index 2ef6c0f1f55..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInYear(arg); - - assert.sameValue( - result, - 366, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-zone-annotation.js deleted file mode 100644 index 1821d2d7cd5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInYear(arg); - - assert.sameValue( - result, - 366, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-unknown-annotation.js deleted file mode 100644 index 12c900339c3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.daysInYear(arg); - - assert.sameValue( - result, - 366, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-with-utc-designator.js deleted file mode 100644 index b19041f274a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInYear(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-wrong-type.js deleted file mode 100644 index eec826312f6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.daysInYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.daysInYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-convert.js deleted file mode 100644 index 5fa002c9490..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.daysInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-slots.js deleted file mode 100644 index 44d112eb749..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.daysInYear(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 8c9b14ba36b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.daysInYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index b38c0ebfe57..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.daysInYear(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 119df41d656..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.daysInYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 8c8f3ad8671..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.daysInYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/basic.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/basic.js deleted file mode 100644 index 37f70cd3ee8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/basic.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Basic tests for daysInYear(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 365; -assert.sameValue(iso.daysInYear(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.daysInYear(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.daysInYear(Temporal.PlainYearMonth.from("1994-11")), res, "PlainYearMonth"); -assert.sameValue(iso.daysInYear({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.daysInYear("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.daysInYear({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/branding.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/branding.js deleted file mode 100644 index 24a8b829b4d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const daysInYear = Temporal.Calendar.prototype.daysInYear; - -assert.sameValue(typeof daysInYear, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1)]; - -assert.throws(TypeError, () => daysInYear.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => daysInYear.apply(null, args), "null"); -assert.throws(TypeError, () => daysInYear.apply(true, args), "true"); -assert.throws(TypeError, () => daysInYear.apply("", args), "empty string"); -assert.throws(TypeError, () => daysInYear.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => daysInYear.apply(1, args), "1"); -assert.throws(TypeError, () => daysInYear.apply({}, args), "plain object"); -assert.throws(TypeError, () => daysInYear.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => daysInYear.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/builtin.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/builtin.js deleted file mode 100644 index 70eb5b2051a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Tests that Temporal.Calendar.prototype.daysInYear - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.daysInYear), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.daysInYear), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.daysInYear), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.daysInYear.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 20b64607d61..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.daysInYear({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/calendar-fields-iterable.js deleted file mode 100644 index 74f9874efa3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/calendar-fields-iterable.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.daysinyear step 4: - 4. Let _year_ be ? ISOYear(_dateOrDateTime_). - sec-temporal-isoyear step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.daysInYear({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/calendar-temporal-object.js deleted file mode 100644 index 0334233bfb6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/calendar-temporal-object.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.daysinyear step 4: - 4. Let _year_ be ? ISOYear(_dateOrDateTime_). - sec-temporal-isoyear step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.daysInYear({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/infinity-throws-rangeerror.js deleted file mode 100644 index 8c21c5b7a75..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.daysinyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.daysInYear({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.daysInYear({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/length.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/length.js deleted file mode 100644 index 52deaf36d8b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Temporal.Calendar.prototype.daysInYear.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.daysInYear, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/name.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/name.js deleted file mode 100644 index 1adacb830ba..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Temporal.Calendar.prototype.daysInYear.name is "daysInYear". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.daysInYear, "name", { - value: "daysInYear", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/not-a-constructor.js deleted file mode 100644 index c351d1e5acd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Temporal.Calendar.prototype.daysInYear does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.daysInYear(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.daysInYear), false, - "isConstructor(Temporal.Calendar.prototype.daysInYear)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/plain-date-time.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/plain-date-time.js deleted file mode 100644 index ac67d8c9268..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/plain-date-time.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Temporal.Calendar.prototype.daysInYear will take PlainDateTime and return - the number of days in a year. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ISODaysInYear(temporalDateLike.[[ISOYear]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let dt = new Temporal.PlainDateTime(1995, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 365, - 'cal.daysInYear(new Temporal.PlainDateTime(1995, 8, 23, 5, 30, 13)) must return 365' -); - -dt = new Temporal.PlainDateTime(1996, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 366, - 'cal.daysInYear(new Temporal.PlainDateTime(1996, 8, 23, 5, 30, 13)) must return 366' -); - -dt = new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 365, - 'cal.daysInYear(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13)) must return 365' -); - -dt = new Temporal.PlainDateTime(1998, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 365, - 'cal.daysInYear(new Temporal.PlainDateTime(1998, 8, 23, 5, 30, 13)) must return 365' -); - -dt = new Temporal.PlainDateTime(1999, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 365, - 'cal.daysInYear(new Temporal.PlainDateTime(1999, 8, 23, 5, 30, 13)) must return 365' -); - -dt = new Temporal.PlainDateTime(2000, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 366, - 'cal.daysInYear(new Temporal.PlainDateTime(2000, 8, 23, 5, 30, 13)) must return 366' -); - -dt = new Temporal.PlainDateTime(2001, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 365, - 'cal.daysInYear(new Temporal.PlainDateTime(2001, 8, 23, 5, 30, 13)) must return 365' -); - -dt = new Temporal.PlainDateTime(2002, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 365, - 'cal.daysInYear(new Temporal.PlainDateTime(2002, 8, 23, 5, 30, 13)) must return 365' -); - -dt = new Temporal.PlainDateTime(2003, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 365, - 'cal.daysInYear(new Temporal.PlainDateTime(2003, 8, 23, 5, 30, 13)) must return 365' -); - -dt = new Temporal.PlainDateTime(2004, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 366, - 'cal.daysInYear(new Temporal.PlainDateTime(2004, 8, 23, 5, 30, 13)) must return 366' -); - -dt = new Temporal.PlainDateTime(2005, 8, 23, 5, 30, 13); -assert.sameValue( - cal.daysInYear(dt), - 365, - 'cal.daysInYear(new Temporal.PlainDateTime(2005, 8, 23, 5, 30, 13)) must return 365' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/plain-date.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/plain-date.js deleted file mode 100644 index 0cf76b8c2de..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/plain-date.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Temporal.Calendar.prototype.daysInYear will take PlainDate and return - the number of days in a year. -info: | - 5. Return 𝔽(! ISODaysInYear(temporalDateLike.[[ISOYear]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let d = new Temporal.PlainDate(1995, 7, 15); -assert.sameValue(cal.daysInYear(d), 365, 'cal.daysInYear(new Temporal.PlainDate(1995, 7, 15)) must return 365'); - -d = new Temporal.PlainDate(1996, 7, 15); -assert.sameValue(cal.daysInYear(d), 366, 'cal.daysInYear(new Temporal.PlainDate(1996, 7, 15)) must return 366'); - -d = new Temporal.PlainDate(1997, 7, 15); -assert.sameValue(cal.daysInYear(d), 365, 'cal.daysInYear(new Temporal.PlainDate(1997, 7, 15)) must return 365'); - -d = new Temporal.PlainDate(1998, 7, 15); -assert.sameValue(cal.daysInYear(d), 365, 'cal.daysInYear(new Temporal.PlainDate(1998, 7, 15)) must return 365'); - -d = new Temporal.PlainDate(1999, 7, 15); -assert.sameValue(cal.daysInYear(d), 365, 'cal.daysInYear(new Temporal.PlainDate(1999, 7, 15)) must return 365'); - -d = new Temporal.PlainDate(2000, 7, 15); -assert.sameValue(cal.daysInYear(d), 366, 'cal.daysInYear(new Temporal.PlainDate(2000, 7, 15)) must return 366'); - -d = new Temporal.PlainDate(2001, 7, 15); -assert.sameValue(cal.daysInYear(d), 365, 'cal.daysInYear(new Temporal.PlainDate(2001, 7, 15)) must return 365'); - -d = new Temporal.PlainDate(2002, 7, 15); -assert.sameValue(cal.daysInYear(d), 365, 'cal.daysInYear(new Temporal.PlainDate(2002, 7, 15)) must return 365'); - -d = new Temporal.PlainDate(2003, 7, 15); -assert.sameValue(cal.daysInYear(d), 365, 'cal.daysInYear(new Temporal.PlainDate(2003, 7, 15)) must return 365'); - -d = new Temporal.PlainDate(2004, 7, 15); -assert.sameValue(cal.daysInYear(d), 366, 'cal.daysInYear(new Temporal.PlainDate(2004, 7, 15)) must return 366'); - -d = new Temporal.PlainDate(2005, 7, 15); -assert.sameValue(cal.daysInYear(d), 365, 'cal.daysInYear(new Temporal.PlainDate(2005, 7, 15)) must return 365'); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/prop-desc.js deleted file mode 100644 index 0f2af09c078..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: The "daysInYear" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.daysInYear, - "function", - "`typeof Calendar.prototype.daysInYear` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "daysInYear", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/string.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/string.js deleted file mode 100644 index 39b7ae2ce1f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/string.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: > - Temporal.Calendar.prototype.daysInYear will take PlainDate and return - the number of days in a year. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ISODaysInYear(temporalDateLike.[[ISOYear]])). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.sameValue(cal.daysInYear("2019-03-18"), 365, 'cal.daysInYear("2019-03-18") must return 365'); -assert.sameValue(cal.daysInYear("2020-03-18"), 366, 'cal.daysInYear("2020-03-18") must return 366'); -assert.sameValue(cal.daysInYear("2021-03-18"), 365, 'cal.daysInYear("2021-03-18") must return 365'); -assert.sameValue(cal.daysInYear("2022-03-18"), 365, 'cal.daysInYear("2022-03-18") must return 365'); -assert.sameValue(cal.daysInYear("2023-03-18"), 365, 'cal.daysInYear("2023-03-18") must return 365'); -assert.sameValue(cal.daysInYear("2024-03-18"), 366, 'cal.daysInYear("2024-03-18") must return 366'); -assert.sameValue(cal.daysInYear("2025-03-18"), 365, 'cal.daysInYear("2025-03-18") must return 365'); -assert.sameValue(cal.daysInYear("2026-03-18"), 365, 'cal.daysInYear("2026-03-18") must return 365'); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/throw-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/throw-range-error-ToTemporalDate.js deleted file mode 100644 index 9b9f755bce3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/throw-range-error-ToTemporalDate.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.daysInYear -description: > - Temporal.Calendar.prototype.daysInYear throws RangeError on - ToTemporalDate when temporalDateLike is invalid string. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike does - not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] - internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.daysInYear("invalid string"), - 'cal.daysInYear("invalid string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/year-zero.js deleted file mode 100644 index 9bb94a19d3c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/daysInYear/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.daysinyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.daysInYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/argument-iterable-not-array.js b/test/built-ins/Temporal/Calendar/prototype/fields/argument-iterable-not-array.js deleted file mode 100644 index 31e6a75b758..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/argument-iterable-not-array.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: A non-Array iterable passed as the argument is exhausted -info: | - sec-temporal.calendar.prototype.fields step 4: - 4. Let _fieldNames_ be ? IterableToList(_fields_). -includes: [compareArray.js] -features: [Temporal] ----*/ - -const fieldNames = ["day", "month", "monthCode", "year"]; -const iterable = { - iteratorExhausted: false, - *[Symbol.iterator]() { - yield* fieldNames; - this.iteratorExhausted = true; - }, -}; - -const calendar = new Temporal.Calendar("iso8601"); -const result = calendar.fields(iterable); - -assert.compareArray(result, fieldNames); -assert(iterable.iteratorExhausted); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-duplicate-keys.js b/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-duplicate-keys.js deleted file mode 100644 index ac6a90574d8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-duplicate-keys.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: Duplicate fields are not allowed in the argument to Calendar.prototype.fields -info: | - sec-temporal.calendar.prototype.fields step 7.b.iii: - iii. If _fieldNames_ contains _nextValue_, then - 1. Let _completion_ be ThrowCompletion(a newly created *RangeError* object). - 2. Return ? IteratorClose(_iteratorRecord_, _completion_). -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -assert.throws(RangeError, () => calendar.fields(["day", "month", "day"])); -assert.throws(RangeError, () => calendar.fields(["year", "month", "monthCode", "day", "year"])); - -const manyFields = { - count: 0 -}; - -manyFields[Symbol.iterator] = function*() { - while (this.count++ < 100) yield "year"; -}; - -assert.throws(RangeError, () => calendar.fields(manyFields), "Rejected duplicate values"); -assert.sameValue(manyFields.count, 2, "Rejected first duplicate value"); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-invalid-keys.js b/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-invalid-keys.js deleted file mode 100644 index 8f3627af357..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/argument-throws-invalid-keys.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: > - Calendar.prototype.fields rejects input field names that are not singular - names of Temporal date units -info: | - sec-temporal.calendar.prototype.fields step 7.b.ii: - 7. Repeat, while next is not false, - a. Set next to ? IteratorStep(iteratorRecord). - b. If next is not false, then - i. Let nextValue be ? IteratorValue(next). - ii. If Type(nextValue) is not String, then - 1. Let completion be ThrowCompletion(a newly created TypeError object). - 2. Return ? IteratorClose(iteratorRecord, completion). - sec-temporal.calendar.prototype.fields step 7.b.iv: - iv. If _nextValue_ is not one of *"year"*, *"month"*, *"monthCode"*, or *"day"*, then - 1. Let _completion_ be ThrowCompletion(a newly created *RangeError* object). - 2. Return ? IteratorClose(_iteratorRecord_, _completion_). - -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -assert.throws(TypeError, () => calendar.fields([1])); -assert.throws(TypeError, () => calendar.fields([1n])); -assert.throws(TypeError, () => calendar.fields([Symbol('foo')])); -assert.throws(TypeError, () => calendar.fields([true])); -assert.throws(TypeError, () => calendar.fields([null])); -assert.throws(TypeError, () => calendar.fields([{}])); -assert.throws(TypeError, () => calendar.fields([undefined])); -assert.throws(TypeError, () => calendar.fields(["day", 1])); -assert.throws(RangeError, () => calendar.fields(["hour"])); -assert.throws(RangeError, () => calendar.fields(["minute"])); -assert.throws(RangeError, () => calendar.fields(["second"])); -assert.throws(RangeError, () => calendar.fields(["millisecond"])); -assert.throws(RangeError, () => calendar.fields(["microsecond"])); -assert.throws(RangeError, () => calendar.fields(["nanosecond"])); -assert.throws(RangeError, () => calendar.fields(["month", "days"])); -assert.throws(RangeError, () => calendar.fields(["days"])); -assert.throws(RangeError, () => calendar.fields(["people"])); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/branding.js b/test/built-ins/Temporal/Calendar/prototype/fields/branding.js deleted file mode 100644 index 9b4225274c3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const fields = Temporal.Calendar.prototype.fields; - -assert.sameValue(typeof fields, "function"); - -const args = [[]]; - -assert.throws(TypeError, () => fields.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => fields.apply(null, args), "null"); -assert.throws(TypeError, () => fields.apply(true, args), "true"); -assert.throws(TypeError, () => fields.apply("", args), "empty string"); -assert.throws(TypeError, () => fields.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => fields.apply(1, args), "1"); -assert.throws(TypeError, () => fields.apply({}, args), "plain object"); -assert.throws(TypeError, () => fields.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => fields.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/builtin.js b/test/built-ins/Temporal/Calendar/prototype/fields/builtin.js deleted file mode 100644 index 7467b415cec..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: > - Tests that Temporal.Calendar.prototype.fields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.fields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.fields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.fields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.fields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/length.js b/test/built-ins/Temporal/Calendar/prototype/fields/length.js deleted file mode 100644 index b5d53e02103..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: Temporal.Calendar.prototype.fields.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.fields, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/long-input.js b/test/built-ins/Temporal/Calendar/prototype/fields/long-input.js deleted file mode 100644 index 6e8b32ed7b8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/long-input.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: > - Temporal.Calendar.prototype.fields will throw when its input iterable yields an - invalid field. -info: | - ## 12.4.21 Temporal.Calendar.prototype.fields ( fields ) - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 4. Let iteratorRecord be ? Getiterator(fields, sync). - 5. Let fieldNames be a new empty List. - 6. Let next be true. - 7. Repeat, while next is not false, - a. Set next to ? IteratorStep(iteratorRecord). - b. If next is not false, then - i. Let nextValue be ? IteratorValue(next). - iv. If nextValue is not one of "year", "month", "monthCode", or "day", then - 1. Let completion be ThrowCompletion(a newly created RangeError object). - 2. Return ? IteratorClose(iteratorRecord, completion). -features: [Symbol, Symbol.iterator, Temporal, computed-property-names, generators] ----*/ -let cal = new Temporal.Calendar("iso8601") -let i = 0; -const fields = { - *[Symbol.iterator]() { - // The first three are valid values - yield "year"; - i++; - yield "month"; - i++; - yield "monthCode"; - i++; - // The fourth one is wrong and should throw after the next line. - yield "garbage"; - // The following three lines should not be reached if the implemention - // correctly check the previous line. - i++; - yield "day"; - i++; - } -} -assert.throws(RangeError, () => cal.fields(fields), "Garbage content"); -// stop after the third one. -assert.sameValue(i, 3); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/name.js b/test/built-ins/Temporal/Calendar/prototype/fields/name.js deleted file mode 100644 index 1d80b465503..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: Temporal.Calendar.prototype.fields.name is "fields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.fields, "name", { - value: "fields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/non-string-element-throws.js b/test/built-ins/Temporal/Calendar/prototype/fields/non-string-element-throws.js deleted file mode 100644 index 40ca483693f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/non-string-element-throws.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: TypeError thrown if the input iterable yields a non-String value -info: | - sec-temporal.calendar.prototype.fields step 5: - 5. For each element _fieldName_ of _fieldNames_, do - a. If Type(_fieldName_) is not String, throw a *TypeError* exception. -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -[true, 3, 3n, {}, () => {}, Symbol(), undefined, null].forEach((element) => { - assert.throws(TypeError, () => calendar.fields([element]), "bad input to calendar.fields()"); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/fields/not-a-constructor.js deleted file mode 100644 index d38455b080a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: > - Temporal.Calendar.prototype.fields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.fields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.fields), false, - "isConstructor(Temporal.Calendar.prototype.fields)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/fields/prop-desc.js deleted file mode 100644 index 480de4f9cf9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: The "fields" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.fields, - "function", - "`typeof Calendar.prototype.fields` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "fields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/repeated-throw.js b/test/built-ins/Temporal/Calendar/prototype/fields/repeated-throw.js deleted file mode 100644 index 2d82b084238..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/repeated-throw.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: > - Temporal.Calendar.prototype.fields will throw if its input iterable yields - the same value twice. -info: | - ## 12.4.21 Temporal.Calendar.prototype.fields ( fields ) - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 4. Let iteratorRecord be ? Getiterator(fields, sync). - 5. Let fieldNames be a new empty List. - 6. Let next be true. - 7. Repeat, while next is not false, - a. Set next to ? IteratorStep(iteratorRecord). - b. If next is not false, then - i. Let nextValue be ? IteratorValue(next). - iii. If fieldNames contains nextValue, then - 1. Let completion be ThrowCompletion(a newly created RangeError object). - 2. Return ? IteratorClose(iteratorRecord, completion). -features: [Symbol, Symbol.iterator, Temporal, computed-property-names, generators] ----*/ -let cal = new Temporal.Calendar("iso8601") -let i = 0; -const fields = { - *[Symbol.iterator]() { - yield "month"; - i++; - yield "year"; - i++; - yield "year"; - i++; - } -} -assert.throws( - RangeError, () => cal.fields(fields), "repeated valid value should throw"); -assert.sameValue(i, 2, "Should stop at 2"); - -// Test all valid values will throw when repeated -[ "day", "monthCode", "month", "year" ].forEach((f) => { - i = 0; - const fields2 = { - *[Symbol.iterator]() { - yield f; - i++; - yield f; - i++; - } - } - assert.throws( - RangeError, () => cal.fields(fields2), "repeated valid value should throw"); - assert.sameValue(i, 1, "Should stop at 1"); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/fields/reverse.js b/test/built-ins/Temporal/Calendar/prototype/fields/reverse.js deleted file mode 100644 index 76035475f61..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/fields/reverse.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.fields -description: > - Temporal.Calendar.prototype.fields will return the iterable in array if all - input are valid regardless of it's order. -info: | - ## 12.4.21 Temporal.Calendar.prototype.fields ( fields ) - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 4. Let iteratorRecord be ? Getiterator(fields, sync). - 5. Let fieldNames be a new empty List. - 6. Let next be true. - 7. Repeat, while next is not false, - a. Set next to ? IteratorStep(iteratorRecord). - b. If next is not false, then - i. Let nextValue be ? IteratorValue(next). - iv. If nextValue is not one of "year", "month", "monthCode", or "day", then - 1. Let completion be ThrowCompletion(a newly created RangeError object). - 2. Return ? IteratorClose(iteratorRecord, completion). -features: [Symbol, Symbol.iterator, Temporal, computed-property-names, generators] -includes: [compareArray.js] ----*/ -let cal = new Temporal.Calendar("iso8601") -const fields = { - *[Symbol.iterator]() { - yield "day"; - yield "monthCode"; - yield "month"; - yield "year"; - } -} -assert.compareArray(cal.fields(fields), Array.from(fields), - 'valid fields should be supported even if they are in reversed order of the spec'); diff --git a/test/built-ins/Temporal/Calendar/prototype/id/branding.js b/test/built-ins/Temporal/Calendar/prototype/id/branding.js deleted file mode 100644 index bd3cef876cf..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/id/branding.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.calendar.prototype.id -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const descriptor = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -const id = descriptor.get; - -assert.sameValue(typeof id, "function"); - -assert.throws(TypeError, () => id.call(undefined), "undefined"); -assert.throws(TypeError, () => id.call(null), "null"); -assert.throws(TypeError, () => id.call(true), "true"); -assert.throws(TypeError, () => id.call(""), "empty string"); -assert.throws(TypeError, () => id.call(Symbol()), "symbol"); -assert.throws(TypeError, () => id.call(1), "1"); -assert.throws(TypeError, () => id.call({}), "plain object"); -assert.throws(TypeError, () => id.call(Temporal.Calendar), "Temporal.Calendar"); -assert.throws(TypeError, () => id.call(Temporal.Calendar.prototype), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/id/custom-calendar.js b/test/built-ins/Temporal/Calendar/prototype/id/custom-calendar.js deleted file mode 100644 index 47821321a71..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/id/custom-calendar.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.calendar.prototype.id -description: Getter does not call toString(), returns the ID from internal slot -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = []; - -const calendar = new Temporal.Calendar("iso8601"); -TemporalHelpers.observeProperty(actual, calendar, Symbol.toPrimitive, undefined); -TemporalHelpers.observeProperty(actual, calendar, "toString", function () { - actual.push("call calendar.toString"); - return "calendar ID"; -}); - -const result = calendar.id; -assert.compareArray(actual, expected); -assert.sameValue(result, "iso8601"); diff --git a/test/built-ins/Temporal/Calendar/prototype/id/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/id/prop-desc.js deleted file mode 100644 index 7b2dbe4e914..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/id/prop-desc.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.calendar.prototype.id -description: The "id" property of Temporal.Calendar.prototype -features: [Temporal] ----*/ - -const descriptor = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -assert.sameValue(typeof descriptor.get, "function"); -assert.sameValue(descriptor.set, undefined); -assert.sameValue(descriptor.enumerable, false); -assert.sameValue(descriptor.configurable, true); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 712b350ca5c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.inLeapYear(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 7ee264b639b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.inLeapYear(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 6eef9693552..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.inLeapYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-duplicate-calendar-fields.js deleted file mode 100644 index 02870abe190..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.inLeapYear(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-leap-second.js deleted file mode 100644 index e64bef3048b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.inLeapYear(arg); -assert.sameValue( - result1, - true, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.inLeapYear(arg); -assert.sameValue( - result2, - true, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-number.js deleted file mode 100644 index 03b89c68b98..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.inLeapYear(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 1214c1b8be9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.inLeapYear(arg); -assert.sameValue(result, true, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 01b3ac6f8fc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.inLeapYear(arg); - assert.sameValue(result, true, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index d7a4e62013b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.inLeapYear(arg); -assert.sameValue( - result, - true, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-number.js deleted file mode 100644 index f2010c4ccba..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.inLeapYear(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-string.js deleted file mode 100644 index 69ee72c9afb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.inLeapYear(arg); -assert.sameValue(result, true, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 6b0002ca25e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.inLeapYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.inLeapYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index bcfca66ad95..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.inLeapYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-proto-in-calendar-fields.js deleted file mode 100644 index 79ad523e9ce..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.inLeapYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 8c3d445d7f4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.inLeapYear(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation.js deleted file mode 100644 index 357c21fa025..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.inLeapYear(arg); - - assert.sameValue( - result, - true, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 6387d90667a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.inLeapYear(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-date-with-utc-offset.js deleted file mode 100644 index e13911f52b0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.inLeapYear(arg); - - assert.sameValue( - result, - true, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.inLeapYear(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-invalid.js deleted file mode 100644 index 6a1c1d5d6b7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.inLeapYear(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-calendar.js deleted file mode 100644 index 5830790c2be..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.inLeapYear(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-time-zone.js deleted file mode 100644 index 253a580aa60..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.inLeapYear(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-separators.js deleted file mode 100644 index a963e6dab8d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.inLeapYear(arg); - - assert.sameValue( - result, - true, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-zone-annotation.js deleted file mode 100644 index 98e496c32f2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.inLeapYear(arg); - - assert.sameValue( - result, - true, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-unknown-annotation.js deleted file mode 100644 index 539fe4533a8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.inLeapYear(arg); - - assert.sameValue( - result, - true, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-with-utc-designator.js deleted file mode 100644 index a4ef7f78a37..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.inLeapYear(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string.js deleted file mode 100644 index 1c4272fbd72..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-string.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: An ISO 8601 date string should be converted as input -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return ! IsISOLeapYear(temporalDateLike.[[ISOYear]]). -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -assert.sameValue(cal.inLeapYear("2019-03-18"), false); -assert.sameValue(cal.inLeapYear("2020-03-18"), true); - -assert.sameValue(cal.inLeapYear("+002023-03-18"), false); -assert.sameValue(cal.inLeapYear("+002024-03-18"), true); - -assert.sameValue(cal.inLeapYear("2019-03-18T13:00:00+00:00[UTC]"), false); -assert.sameValue(cal.inLeapYear("2020-12-31T23:59:59+00:00[UTC]"), true); - -assert.sameValue(cal.inLeapYear("+002023-03-18T13:00:00+00:00[UTC]"), false); -assert.sameValue(cal.inLeapYear("+002024-03-18T13:00:00+00:00[UTC]"), true); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-wrong-type.js deleted file mode 100644 index fe8718eaa2b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.inLeapYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.inLeapYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-convert.js deleted file mode 100644 index 477767c7e17..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.inLeapYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-slots.js deleted file mode 100644 index afc1f701261..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.inLeapYear(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 4899fee9201..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.inLeapYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 5891388d2e3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.inLeapYear(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 493732aa754..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.inLeapYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 6b114ea0f82..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.inLeapYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/basic.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/basic.js deleted file mode 100644 index 7e8d3cf048b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/basic.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Basic tests for inLeapYear(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -let res = false; - -assert.sameValue(iso.inLeapYear(new Temporal.PlainDate(1994, 11, 5)), res, "PlainDate"); -assert.sameValue(iso.inLeapYear(new Temporal.PlainDateTime(1994, 11, 5, 8, 15, 30)), res, "PlainDateTime"); -assert.sameValue(iso.inLeapYear(new Temporal.PlainYearMonth(1994, 11)), res, "PlainYearMonth"); -assert.sameValue(iso.inLeapYear({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.inLeapYear("1994-11-05"), res, "string"); - -res = true; -assert.sameValue(iso.inLeapYear(new Temporal.PlainDate(1996, 7, 15)), res, "PlainDate in leap year"); -assert.sameValue(iso.inLeapYear(new Temporal.PlainDateTime(1996, 7, 15, 5, 30, 13)), res, "PlainDateTime in leap year"); -assert.sameValue(iso.inLeapYear(new Temporal.PlainYearMonth(1996, 7)), res, "PlainYearMonth in leap year"); -assert.sameValue(iso.inLeapYear({ year: 1996, month: 7, day: 15 }), res, "property bag in leap year"); -assert.sameValue(iso.inLeapYear("1996-07-15"), res, "string in leap year"); - -assert.throws(TypeError, () => iso.inLeapYear({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/branding.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/branding.js deleted file mode 100644 index 4cde009d422..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const inLeapYear = Temporal.Calendar.prototype.inLeapYear; - -assert.sameValue(typeof inLeapYear, "function"); - -const args = [new Temporal.PlainDate(2021, 3, 4)]; - -assert.throws(TypeError, () => inLeapYear.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => inLeapYear.apply(null, args), "null"); -assert.throws(TypeError, () => inLeapYear.apply(true, args), "true"); -assert.throws(TypeError, () => inLeapYear.apply("", args), "empty string"); -assert.throws(TypeError, () => inLeapYear.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => inLeapYear.apply(1, args), "1"); -assert.throws(TypeError, () => inLeapYear.apply({}, args), "plain object"); -assert.throws(TypeError, () => inLeapYear.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => inLeapYear.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/builtin.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/builtin.js deleted file mode 100644 index 2c66b6b67a0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: > - Tests that Temporal.Calendar.prototype.inLeapYear - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.inLeapYear), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.inLeapYear), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.inLeapYear), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.inLeapYear.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 2b89a6b531a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.inLeapYear({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/calendar-fields-iterable.js deleted file mode 100644 index 26719069f3a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/calendar-fields-iterable.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.inleapyear step 4: - 4. Let _year_ be ? ISOYear(_dateOrDateTime_). - sec-temporal-isoyear step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.inLeapYear({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/calendar-temporal-object.js deleted file mode 100644 index e31a15dd393..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.inleapyear step 4: - 4. Let _year_ be ? ISOYear(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.inLeapYear({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/infinity-throws-rangeerror.js deleted file mode 100644 index 083bbb50735..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.inleapyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.inLeapYear({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.inLeapYear({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/length.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/length.js deleted file mode 100644 index b186375f710..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Temporal.Calendar.prototype.inLeapYear.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.inLeapYear, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/name.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/name.js deleted file mode 100644 index e5efe9b8375..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Temporal.Calendar.prototype.inLeapYear.name is "inLeapYear". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.inLeapYear, "name", { - value: "inLeapYear", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/not-a-constructor.js deleted file mode 100644 index fcafccbbef2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: > - Temporal.Calendar.prototype.inLeapYear does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.inLeapYear(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.inLeapYear), false, - "isConstructor(Temporal.Calendar.prototype.inLeapYear)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/prop-desc.js deleted file mode 100644 index eb21f1a0497..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: The "inLeapYear" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.inLeapYear, - "function", - "`typeof Calendar.prototype.inLeapYear` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "inLeapYear", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/year-zero.js deleted file mode 100644 index f96bac46a4b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.inleapyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.inLeapYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/arguments-empty-object.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/arguments-empty-object.js deleted file mode 100644 index bd8d760257e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/arguments-empty-object.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: Either argument being an empty object should result in a copy of the other object -includes: [compareArray.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); - -let calls = 0; -const yearObserver = { - get year() { - calls++; - return 2021; - } -}; - -const result1 = calendar.mergeFields(yearObserver, {}); -assert.sameValue(calls, 1, "property copied"); -assert.compareArray(Object.keys(result1), ["year"]); -assert.sameValue(result1.year, 2021); -assert.sameValue(calls, 1, "result has a data property"); - -calls = 0; -const result2 = calendar.mergeFields({}, yearObserver); -assert.sameValue(calls, 1, "property copied"); -assert.compareArray(Object.keys(result2), ["year"]); -assert.sameValue(result2.year, 2021); -assert.sameValue(calls, 1, "result has a data property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/arguments-not-object.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/arguments-not-object.js deleted file mode 100644 index 89d89169ac8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/arguments-not-object.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: Non-object arguments are converted with ToObject and merge their [[OwnPropertyKeys]] onto a new object -includes: [compareArray.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); - -assert.throws(TypeError, () => calendar.mergeFields(undefined, {})); -assert.throws(TypeError, () => calendar.mergeFields({}, undefined)); - -assert.throws(TypeError, () => calendar.mergeFields(null, {})); -assert.throws(TypeError, () => calendar.mergeFields({}, null)); - -const boolResult = calendar.mergeFields(true, false); -assert.compareArray(Object.keys(boolResult), [], "Boolean objects have no own property keys"); -assert.sameValue(Object.getPrototypeOf(boolResult), null, "null-prototype object returned"); - -const numResult = calendar.mergeFields(3, 4); -assert.compareArray(Object.keys(numResult), [], "Number objects have no own property keys"); -assert.sameValue(Object.getPrototypeOf(boolResult), null, "null-prototype object returned"); - -const strResult = calendar.mergeFields("abc", "de"); -assert.compareArray(Object.keys(strResult), ["0", "1", "2"], "String objects have integer indices as own property keys"); -assert.sameValue(strResult["0"], "d"); -assert.sameValue(strResult["1"], "e"); -assert.sameValue(strResult["2"], "c"); -assert.sameValue(Object.getPrototypeOf(boolResult), null, "null-prototype object returned"); - -const symResult = calendar.mergeFields(Symbol("foo"), Symbol("bar")); -assert.compareArray(Object.keys(symResult), [], "Symbol objects have no own property keys"); -assert.sameValue(Object.getPrototypeOf(symResult), null, "null-prototype object returned"); - -const bigintResult = calendar.mergeFields(3n, 4n); -assert.compareArray(Object.keys(bigintResult), [], "BigInt objects have no own property keys"); -assert.sameValue(Object.getPrototypeOf(bigintResult), null, "null-prototype object returned"); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/basic.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/basic.js deleted file mode 100644 index 72483362e8b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/basic.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: > - Temporal.Calendar.prototype.mergeFields will merge own data properties on its - arguments -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. Set fields to ? ToObject(fields). - 5. Set additionalFields to ? ToObject(additionalFields). - 6. Return ? DefaultMergeFields(fields, additionalFields). -features: [Temporal] -includes: [deepEqual.js] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2 }, { c: 3, d: 4 }), - { a: 1, b: 2, c: 3, d: 4 }, - "properties are merged" -); - -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2 }, { b: 3, c: 4 }), - { a: 1, b: 3, c: 4 }, - "property in additionalFields should overwrite one in fields" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/branding.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/branding.js deleted file mode 100644 index a1189bbb4d2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const mergeFields = Temporal.Calendar.prototype.mergeFields; - -assert.sameValue(typeof mergeFields, "function"); - -const args = [{}, {}]; - -assert.throws(TypeError, () => mergeFields.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => mergeFields.apply(null, args), "null"); -assert.throws(TypeError, () => mergeFields.apply(true, args), "true"); -assert.throws(TypeError, () => mergeFields.apply("", args), "empty string"); -assert.throws(TypeError, () => mergeFields.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => mergeFields.apply(1, args), "1"); -assert.throws(TypeError, () => mergeFields.apply({}, args), "plain object"); -assert.throws(TypeError, () => mergeFields.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => mergeFields.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/builtin.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/builtin.js deleted file mode 100644 index 721c566e000..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: > - Tests that Temporal.Calendar.prototype.mergeFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.mergeFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.mergeFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.mergeFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.mergeFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/iso8601-calendar-month-monthCode.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/iso8601-calendar-month-monthCode.js deleted file mode 100644 index e322a791e13..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/iso8601-calendar-month-monthCode.js +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: > - The default mergeFields algorithm from the ISO 8601 calendar should correctly - merge the month and monthCode properties -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. Set fields to ? ToObject(fields). - 5. Set additionalFields to ? ToObject(additionalFields). - 6. Return ? DefaultMergeFields(fields, additionalFields). -features: [Temporal] -includes: [deepEqual.js] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, month: 7 }, { b: 3, c: 4 }), - { a: 1, b: 3, c: 4, month: 7 }, - "month is copied from fields" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, monthCode: "M08" }, { b: 3, c: 4 }), - { a: 1, b: 3, c: 4, monthCode: "M08" }, - "monthCode is copied from fields" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, month: 7, monthCode: "M08" }, { b: 3, c: 4 }), - { a: 1, b: 3, c: 4, month: 7, monthCode: "M08" }, - "both month and monthCode are copied from fields, no validation is performed" -); - -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2 }, { b: 3, c: 4, month: 5 }), - { a: 1, b: 3, c: 4, month: 5 }, - "month is copied from additionalFields" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2 }, { b: 3, c: 4, monthCode: "M06" }), - { a: 1, b: 3, c: 4, monthCode: "M06" }, - "monthCode is copied from additionalFields" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2 }, { b: 3, c: 4, month: 5, monthCode: "M06" }), - { a: 1, b: 3, c: 4, month: 5, monthCode: "M06" }, - "both month and monthCode are copied from additionalFields, no validation is performed" -); - -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, month: 7 }, { b: 3, c: 4, month: 5 }), - { a: 1, b: 3, c: 4, month: 5 }, - "month from additionalFields overrides month from fields" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, monthCode: "M07" }, { b: 3, c: 4, monthCode: "M05" }), - { a: 1, b: 3, c: 4, monthCode: "M05" }, - "monthCode from additionalFields overrides monthCode from fields" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, monthCode: "M07" }, { b: 3, c: 4, month: 6 }), - { a: 1, b: 3, c: 4, month: 6 }, - "month's presence on additionalFields blocks monthCode from fields" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, month: 7 }, { b: 3, c: 4, monthCode: "M06" }), - { a: 1, b: 3, c: 4, monthCode: "M06"}, - "monthCode's presence on additionalFields blocks month from fields" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, month: 7, monthCode: "M08" },{ b: 3, c: 4, month: 5 }), - { a: 1, b: 3, c: 4, month: 5 }, - "month's presence on additionalFields blocks both month and monthCode from fields" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, month: 7, monthCode: "M08" }, { b: 3, c: 4, monthCode: "M06" }), - { a: 1, b: 3, c: 4, monthCode: "M06" }, - "monthCode's presence on additionalFields blocks both month and monthCode from fields" -); - -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, month: 7 }, { b: 3, c: 4, month: 5, monthCode: "M06" }), - { a: 1, b: 3, c: 4, month: 5, monthCode: "M06" }, - "both month and monthCode are copied from additionalFields even when fields has month" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, monthCode: "M07" }, { b: 3, c: 4, month: 5, monthCode: "M06" }), - { a: 1, b: 3, c: 4, month: 5, monthCode: "M06" }, - "both month and monthCode are copied from additionalFields even when fields has monthCode" -); -assert.deepEqual( - cal.mergeFields({ a: 1, b: 2, month: 7, monthCode: "M08" }, { b: 3, c: 4, month: 5, monthCode: "M06" }), - { a: 1, b: 3, c: 4, month: 5, monthCode: "M06" }, - "both month and monthCode are copied from additionalFields even when fields has both month and monthCode" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/length.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/length.js deleted file mode 100644 index 204a370fda2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: Temporal.Calendar.prototype.mergeFields.length is 2 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.mergeFields, "length", { - value: 2, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/name.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/name.js deleted file mode 100644 index ec7de2c03dd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: Temporal.Calendar.prototype.mergeFields.name is "mergeFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.mergeFields, "name", { - value: "mergeFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/non-string-properties.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/non-string-properties.js deleted file mode 100644 index 68f861c1f78..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/non-string-properties.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: Both string and symbol keys from the arguments are merged -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. Set fields to ? ToObject(fields). - 5. Set additionalFields to ? ToObject(additionalFields). - 6. Return ? DefaultMergeFields(fields, additionalFields). -features: [Temporal] ----*/ - -function assertEntriesEqual(actual, expectedEntries, message) { - const names = Object.getOwnPropertyNames(actual); - const symbols = Object.getOwnPropertySymbols(actual); - const actualKeys = names.concat(symbols); - assert.sameValue( - actualKeys.length, - expectedEntries.length, - `${message}: expected object to have ${expectedEntries.length} properties, not ${actualKeys.length}:` - ); - for (var index = 0; index < actualKeys.length; index++) { - const actualKey = actualKeys[index]; - const expectedKey = expectedEntries[index][0]; - const expectedValue = expectedEntries[index][1]; - assert.sameValue(actualKey, expectedKey, `${message}: key ${index}:`); - assert.sameValue(actual[actualKey], expectedValue, `${message}: value ${index}:`); - } -} - -const cal = new Temporal.Calendar("iso8601"); - -assertEntriesEqual( - cal.mergeFields({ 1: 2 }, { 3: 4 }), - [["1", 2], ["3", 4]], - "number keys are actually string keys and are merged as such" -); -assertEntriesEqual( - cal.mergeFields({ 1n: 2 }, { 2n: 4 }), - [["1", 2], ["2", 4]], - "bigint keys are actually string keys and are merged as such" -); - -const foo = Symbol("foo"); -const bar = Symbol("bar"); -assertEntriesEqual( - cal.mergeFields({ [foo]: 1 }, { [bar]: 2 }), - [[foo, 1], [bar, 2]], - "symbol keys are also merged" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/not-a-constructor.js deleted file mode 100644 index 1e4519325b7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: > - Temporal.Calendar.prototype.mergeFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.mergeFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.mergeFields), false, - "isConstructor(Temporal.Calendar.prototype.mergeFields)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/order-of-operations.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/order-of-operations.js deleted file mode 100644 index bcc750600ce..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/order-of-operations.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: Properties on objects passed to mergeFields() are accessed in the correct order -features: [Temporal] -includes: [compareArray.js, temporalHelpers.js] ----*/ - -const expected = [ - // CopyDataProperties on fields - "ownKeys fields", - "getOwnPropertyDescriptor fields.year", - "get fields.year", - "getOwnPropertyDescriptor fields.month", - "get fields.month", - "getOwnPropertyDescriptor fields.day", - "get fields.day", - "getOwnPropertyDescriptor fields.extra", - "get fields.extra", - // CopyDataProperties on additionalFields - "ownKeys additionalFields", - "getOwnPropertyDescriptor additionalFields[3]", - "get additionalFields[3]", - "getOwnPropertyDescriptor additionalFields.monthCode", - "get additionalFields.monthCode", - "getOwnPropertyDescriptor additionalFields[Symbol('extra')]", - "get additionalFields[Symbol('extra')]", -]; -const actual = []; - -const fields = TemporalHelpers.propertyBagObserver(actual, { - year: 2022, - month: 10, - day: 17, - extra: "extra property", -}, "fields"); -const additionalFields = TemporalHelpers.propertyBagObserver(actual, { - [Symbol("extra")]: "extra symbol property", - monthCode: "M10", - 3: "extra array index property", -}, "additionalFields"); - -const instance = new Temporal.Calendar("iso8601"); -instance.mergeFields(fields, additionalFields); -assert.compareArray(actual, expected, "order of observable operations"); diff --git a/test/built-ins/Temporal/Calendar/prototype/mergeFields/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/mergeFields/prop-desc.js deleted file mode 100644 index b5363f63f0a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/mergeFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: The "mergeFields" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.mergeFields, - "function", - "`typeof Calendar.prototype.mergeFields` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "mergeFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 55d5db1e368..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.month(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 1b8550f796e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.month(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 47b5719e189..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.month -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.month(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-duplicate-calendar-fields.js deleted file mode 100644 index dda70202ebe..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.month -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.month(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-leap-second.js deleted file mode 100644 index 61198fe9f4f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.month(arg); -assert.sameValue( - result1, - 12, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.month(arg); -assert.sameValue( - result2, - 12, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-number.js deleted file mode 100644 index 563801d4930..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.month(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 491085743c1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.month(arg); -assert.sameValue(result, 11, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 6588ae23183..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.month(arg); - assert.sameValue(result, 11, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 018fdf3210d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.month(arg); -assert.sameValue( - result, - 11, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-number.js deleted file mode 100644 index 923cf5ac890..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.month(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-string.js deleted file mode 100644 index d62b7b932a9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.month(arg); -assert.sameValue(result, 11, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 443a6f1d601..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.month(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.month(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 24d8f499a0a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.month(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-proto-in-calendar-fields.js deleted file mode 100644 index 8bf83066076..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.month -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.month(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 872a8dd73d0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.month(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation.js deleted file mode 100644 index 2bc9f9a4740..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.month(arg); - - assert.sameValue( - result, - 5, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 0e7b9ed0994..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.month(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-date-with-utc-offset.js deleted file mode 100644 index 8084e0e1588..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.month(arg); - - assert.sameValue( - result, - 5, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.month(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-invalid.js deleted file mode 100644 index e314a1d01e3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.month(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-calendar.js deleted file mode 100644 index 43cf9d0e5ea..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.month(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-time-zone.js deleted file mode 100644 index 95197fb917f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.month(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-separators.js deleted file mode 100644 index a238e5422a4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.month(arg); - - assert.sameValue( - result, - 5, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-zone-annotation.js deleted file mode 100644 index fa4bc3bd80b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.month(arg); - - assert.sameValue( - result, - 5, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-unknown-annotation.js deleted file mode 100644 index 6a966dfced8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.month(arg); - - assert.sameValue( - result, - 5, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-string-with-utc-designator.js deleted file mode 100644 index 874d8969a41..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.month(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-wrong-type.js deleted file mode 100644 index cff3d85132f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.month(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.month(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-convert.js deleted file mode 100644 index fc454a175d7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.month(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-slots.js deleted file mode 100644 index 523b92d4f25..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.month(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 689ee484cf2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.month(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index d3f3e1caafe..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.month(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 4bf83caa614..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.month(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 9e7b63a33c4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.month(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/basic.js b/test/built-ins/Temporal/Calendar/prototype/month/basic.js deleted file mode 100644 index 17eb081e592..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/basic.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Basic tests for month(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 11; -assert.sameValue(iso.month(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.month(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.month(Temporal.PlainYearMonth.from("1994-11")), res, "PlainYearMonth"); -assert.sameValue(iso.month({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.month("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.month({ year: 2000 }), "property bag with missing properties"); -assert.throws(TypeError, () => iso.month(Temporal.PlainMonthDay.from("11-05")), "PlainMonthDay"); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/branding.js b/test/built-ins/Temporal/Calendar/prototype/month/branding.js deleted file mode 100644 index 4df376111fe..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const month = Temporal.Calendar.prototype.month; - -assert.sameValue(typeof month, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1)]; - -assert.throws(TypeError, () => month.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => month.apply(null, args), "null"); -assert.throws(TypeError, () => month.apply(true, args), "true"); -assert.throws(TypeError, () => month.apply("", args), "empty string"); -assert.throws(TypeError, () => month.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => month.apply(1, args), "1"); -assert.throws(TypeError, () => month.apply({}, args), "plain object"); -assert.throws(TypeError, () => month.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => month.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/builtin.js b/test/built-ins/Temporal/Calendar/prototype/month/builtin.js deleted file mode 100644 index e2445cc42f0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Tests that Temporal.Calendar.prototype.month - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.month), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.month), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.month), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.month.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/month/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 77c6e75f829..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.month({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/month/calendar-fields-iterable.js deleted file mode 100644 index ed9939f5c7b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/calendar-fields-iterable.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.month step 4: - 4. Return ? ISOMonth(_dateOrDateTime_). - sec-temporal-isomonth step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.month({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/month/calendar-temporal-object.js deleted file mode 100644 index 907cd78aff0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/calendar-temporal-object.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.month step 4: - 4. Return ? ISOMonth(_dateOrDateTime_). - sec-temporal-isomonth step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.month({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/date-time.js b/test/built-ins/Temporal/Calendar/prototype/month/date-time.js deleted file mode 100644 index a8f65a61ba0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/date-time.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Temporal.Calendar.prototype.month will take PlainDateTime and return - the value of the month. -info: | - 5. If Type(temporalDateLike) is not Object or temporalDateLike does not have - an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] - internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 6. Return ! ISOMonth(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let dateTime = new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13) -assert.sameValue(cal.month(dateTime), 8, 'cal.month(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13)) must return 8'); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/date.js b/test/built-ins/Temporal/Calendar/prototype/month/date.js deleted file mode 100644 index 80e94a24d07..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/date.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Temporal.Calendar.prototype.month will take PlainDate and return - the value of the month. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(temporalDateLike) is Object and temporalDateLike has an - [[InitializedTemporalMonthDay]] internal slot, then - a. Throw a TypeError exception. - 5. If Type(temporalDateLike) is not Object or temporalDateLike does not have - an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] - internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 6. Return ! ISOMonth(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let date = new Temporal.PlainDate(2021, 7, 15); -assert.sameValue(cal.month(date), 7, 'cal.month(new Temporal.PlainDate(2021, 7, 15)) must return 7'); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/month/infinity-throws-rangeerror.js deleted file mode 100644 index 2bfe2315e31..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.month -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.month({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.month({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/length.js b/test/built-ins/Temporal/Calendar/prototype/month/length.js deleted file mode 100644 index 52af40a939d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Temporal.Calendar.prototype.month.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.month, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/month-day-throw-type-error.js b/test/built-ins/Temporal/Calendar/prototype/month/month-day-throw-type-error.js deleted file mode 100644 index 34220cb22d4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/month-day-throw-type-error.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Temporal.Calendar.prototype.month throws TypeError if temporalDateLike - is a PlainMonthDay object. - ToTemporalDate when temporalDateLike is invalid string. -info: | - 4. If Type(temporalDateLike) is Object and temporalDateLike has an - [[InitializedTemporalMonthDay]] internal slot, then - a. Throw a TypeError exception. -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let monthDay = new Temporal.PlainMonthDay(12, 25); -assert.throws(TypeError, () => cal.month(monthDay), - 'cal.month(monthDay) throws a TypeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/name.js b/test/built-ins/Temporal/Calendar/prototype/month/name.js deleted file mode 100644 index 79dc0b606ae..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Temporal.Calendar.prototype.month.name is "month". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.month, "name", { - value: "month", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/month/not-a-constructor.js deleted file mode 100644 index 31676f121a2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Temporal.Calendar.prototype.month does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.month(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.month), false, - "isConstructor(Temporal.Calendar.prototype.month)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/month/prop-desc.js deleted file mode 100644 index 684d4357005..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: The "month" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.month, - "function", - "`typeof Calendar.prototype.month` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "month", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/string.js b/test/built-ins/Temporal/Calendar/prototype/month/string.js deleted file mode 100644 index 7a8050d319e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/string.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Temporal.Calendar.prototype.month will take ISO8601 string and return - the value of the month. -info: | - 5. If Type(temporalDateLike) is not Object or temporalDateLike does not have - an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal - slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 6. Return ! ISOMonth(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.sameValue(cal.month("2019-03-15"), 3, 'cal.month("2019-03-15") must return 3'); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/throw-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/month/throw-range-error-ToTemporalDate.js deleted file mode 100644 index 7b5dd00ea5d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/throw-range-error-ToTemporalDate.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Temporal.Calendar.prototype.month throws RangeError on - ToTemporalDate when temporalDateLike is invalid string. -info: | - 5. If Type(temporalDateLike) is not Object or temporalDateLike - does not have an [[InitializedTemporalDate]] or - [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.month("invalid string"), - 'cal.month("invalid string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/year-month.js b/test/built-ins/Temporal/Calendar/prototype/month/year-month.js deleted file mode 100644 index 6cdc0ea732c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/year-month.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: > - Temporal.Calendar.prototype.month will take PlainYearMonth and return - the value of the month. -info: | - 6. Return ! ISOMonth(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let yearMonth = new Temporal.PlainYearMonth(1999, 6); -assert.sameValue(cal.month(yearMonth), 6, 'cal.month(new Temporal.PlainYearMonth(1999, 6)) must return 6'); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/month/year-zero.js deleted file mode 100644 index b54957b1c10..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/month/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.month -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.month(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 7dac75fde17..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.monthCode(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 7390575a7d0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.monthCode(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 6a25d2e6517..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.monthCode(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-duplicate-calendar-fields.js deleted file mode 100644 index c5229c71e83..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.monthCode(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-leap-second.js deleted file mode 100644 index 69c34c942be..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.monthCode(arg); -assert.sameValue( - result1, - "M12", - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.monthCode(arg); -assert.sameValue( - result2, - "M12", - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-number.js deleted file mode 100644 index 038a0b6632b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.monthCode(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 2692a8bd3d9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.monthCode(arg); -assert.sameValue(result, "M11", "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 8e546fbfe63..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.monthCode(arg); - assert.sameValue(result, "M11", `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 8f840d18297..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.monthCode(arg); -assert.sameValue( - result, - "M11", - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-number.js deleted file mode 100644 index 79864d0bf7c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.monthCode(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-string.js deleted file mode 100644 index cfd0da823e1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.monthCode(arg); -assert.sameValue(result, "M11", `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index b75ba9606d7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.monthCode(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.monthCode(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 10ea00aee6d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.monthCode(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-proto-in-calendar-fields.js deleted file mode 100644 index c7e0b17fc16..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.monthCode(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 829eda0614a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.monthCode(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation.js deleted file mode 100644 index b98f969fb3c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.monthCode(arg); - - assert.sameValue( - result, - "M05", - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-critical-unknown-annotation.js deleted file mode 100644 index ee3e52cddb6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthCode(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-date-with-utc-offset.js deleted file mode 100644 index ac8b7d67c57..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.monthCode(arg); - - assert.sameValue( - result, - "M05", - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.monthCode(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-invalid.js deleted file mode 100644 index 3994dee3bc9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.monthCode(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-calendar.js deleted file mode 100644 index 64b96901f0b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthCode(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-time-zone.js deleted file mode 100644 index c522cdcd286..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthCode(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-separators.js deleted file mode 100644 index 942c0ecb958..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.monthCode(arg); - - assert.sameValue( - result, - "M05", - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-zone-annotation.js deleted file mode 100644 index 79b41879362..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.monthCode(arg); - - assert.sameValue( - result, - "M05", - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-unknown-annotation.js deleted file mode 100644 index ed3ef4d428e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.monthCode(arg); - - assert.sameValue( - result, - "M05", - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-with-utc-designator.js deleted file mode 100644 index 36e61a87351..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthCode(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-wrong-type.js deleted file mode 100644 index 629ae17ef50..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.monthCode(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.monthCode(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-convert.js deleted file mode 100644 index 5f198246203..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.monthCode(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-slots.js deleted file mode 100644 index c1e05a4640f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.monthCode(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 9bd79d76e7e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.monthCode(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index b7314e82878..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.monthCode(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 9bdb3a13277..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.monthCode(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 3eea738fd44..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.monthCode(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/basic.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/basic.js deleted file mode 100644 index db6dcd1a740..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/basic.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Basic tests for monthCode(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = "M11"; -assert.sameValue(iso.monthCode(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.monthCode(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.monthCode(Temporal.PlainYearMonth.from("1994-11")), res, "PlainYearMonth"); -assert.sameValue(iso.monthCode(Temporal.PlainMonthDay.from("11-05")), res, "PlainMonthDay"); -assert.sameValue(iso.monthCode({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.monthCode("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.monthCode({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/branding.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/branding.js deleted file mode 100644 index cce6b714ca6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const monthCode = Temporal.Calendar.prototype.monthCode; - -assert.sameValue(typeof monthCode, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1)]; - -assert.throws(TypeError, () => monthCode.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => monthCode.apply(null, args), "null"); -assert.throws(TypeError, () => monthCode.apply(true, args), "true"); -assert.throws(TypeError, () => monthCode.apply("", args), "empty string"); -assert.throws(TypeError, () => monthCode.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => monthCode.apply(1, args), "1"); -assert.throws(TypeError, () => monthCode.apply({}, args), "plain object"); -assert.throws(TypeError, () => monthCode.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => monthCode.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/builtin.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/builtin.js deleted file mode 100644 index 5f7dc2c95a3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: > - Tests that Temporal.Calendar.prototype.monthCode - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.monthCode), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.monthCode), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.monthCode), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.monthCode.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 18111f2f165..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.monthCode({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/calendar-fields-iterable.js deleted file mode 100644 index 47a1dda723f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/calendar-fields-iterable.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.monthcode step 4: - 4. Return ? ISOMonthCode(_dateOrDateTime_). - sec-temporal-isomonthcode step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.monthCode({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/calendar-temporal-object.js deleted file mode 100644 index 87004fdae71..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/calendar-temporal-object.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.monthcode step 4: - 4. Return ? ISOMonthCode(_dateOrDateTime_). - sec-temporal-isomonthcode step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.monthCode({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/date-time.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/date-time.js deleted file mode 100644 index ef69d929a53..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/date-time.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthCode -description: > - Temporal.Calendar.prototype.month will take PlainDateTime and return - the value of the monthCode. -info: | - 6. Return ! ISOMonthCode(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let dateTime = new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13) -assert.sameValue( - cal.monthCode(dateTime), - "M08", - 'cal.monthCode(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13)) must return "M08"' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/date.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/date.js deleted file mode 100644 index 480a8eaa1a6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/date.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthCode -description: > - Temporal.Calendar.prototype.monthCode will take PlainDate and return - the value of the monthCode. -info: | - 5. Return ! ISOMonthCode(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let date = new Temporal.PlainDate(2021, 7, 15); -assert.sameValue(cal.monthCode(date), "M07", 'cal.monthCode(new Temporal.PlainDate(2021, 7, 15)) must return "M07"'); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/infinity-throws-rangeerror.js deleted file mode 100644 index 49f99671fb1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.monthcode -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.monthCode({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.monthCode({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/length.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/length.js deleted file mode 100644 index abc02d7dd67..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Temporal.Calendar.prototype.monthCode.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.monthCode, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/month-day.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/month-day.js deleted file mode 100644 index 9f9c21cd6f0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/month-day.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthCode -description: > - Temporal.Calendar.prototype.monthCode will take PlainMonthDay and return - the value of the monthCode. -info: | - 6. Return ! ISOMonthCode(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let monthDay = new Temporal.PlainMonthDay(12, 25); -assert.sameValue( - cal.monthCode(monthDay), - "M12", - 'cal.monthCode(new Temporal.PlainMonthDay(12, 25)) must return "M12"' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/name.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/name.js deleted file mode 100644 index 818c5d20d89..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Temporal.Calendar.prototype.monthCode.name is "monthCode". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.monthCode, "name", { - value: "monthCode", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/not-a-constructor.js deleted file mode 100644 index 78dccfe5b1c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: > - Temporal.Calendar.prototype.monthCode does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.monthCode(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.monthCode), false, - "isConstructor(Temporal.Calendar.prototype.monthCode)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/prop-desc.js deleted file mode 100644 index 3dca68e969e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: The "monthCode" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.monthCode, - "function", - "`typeof Calendar.prototype.monthCode` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "monthCode", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/string.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/string.js deleted file mode 100644 index 15bd86376c4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/string.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthCode -description: > - Temporal.Calendar.prototype.monthCode will take ISO8601 string and return - the value of the monthCode. -info: | - 5. If Type(temporalDateLike) is not Object or temporalDateLike does not have - an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal - slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 6. Return ! ISOYear(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); -assert.sameValue( - cal.monthCode("2019-03-15"), - "M03", - 'cal.monthCode("2019-03-15") must return "M03"' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/throw-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/throw-range-error-ToTemporalDate.js deleted file mode 100644 index 25cb5e38d3e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/throw-range-error-ToTemporalDate.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthCode -description: > - Temporal.Calendar.prototype.monthCode throws RangeError on - ToTemporalDate when temporalDateLike is invalid string. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike - does not have an [[InitializedTemporalDate]] or - [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.monthCode("invalid string"), - 'cal.monthCode("invalid string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/year-month.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/year-month.js deleted file mode 100644 index 9face924d33..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/year-month.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthCode -description: > - Temporal.Calendar.prototype.monthCode will take PlainYearMonth and return - the value of the monthCode. -info: | - 6. Return ! ISOMonthCode(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let yearMonth = new Temporal.PlainYearMonth(1999, 6); -assert.sameValue( - cal.monthCode(yearMonth), - "M06", - 'cal.monthCode(new Temporal.PlainYearMonth(1999, 6)) must return "M06"' -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/year-zero.js deleted file mode 100644 index 5ad4d0dde74..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthCode/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthcode -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthCode(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/basic.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/basic.js deleted file mode 100644 index 28aa00db184..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/basic.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Temporal.Calendar.prototype.monthDayFromFields will return correctly with valid data. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Set fields to ? PrepareTemporalFields(fields, « "day", "month", "monthCode", "year" », « "day" »). - 7. Let overflow be ? ToTemporalOverflow(options). - 8. Perform ? ISOResolveMonth(fields). - 9. Let result be ? ISOMonthDayFromFields(fields, overflow). - 10. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], "iso8601", result.[[ReferenceISOYear]]). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -const options = [ - { overflow: "constrain" }, - { overflow: "reject" }, - {}, - undefined, -]; -options.forEach((opt) => { - const optionsDesc = opt && JSON.stringify(opt); - let result = cal.monthDayFromFields({ year: 2021, month: 7, day: 3 }, opt); - TemporalHelpers.assertPlainMonthDay(result, "M07", 3, `month 7, day 3, with year, options = ${optionsDesc}`); - result = cal.monthDayFromFields({ year: 2021, month: 12, day: 31 }, opt); - TemporalHelpers.assertPlainMonthDay(result, "M12", 31, `month 12, day 31, with year, options = ${optionsDesc}`); - result = cal.monthDayFromFields({ monthCode: "M07", day: 3 }, opt); - TemporalHelpers.assertPlainMonthDay(result, "M07", 3, `monthCode M07, day 3, options = ${optionsDesc}`); - result = cal.monthDayFromFields({ monthCode: "M12", day: 31 }, opt); - TemporalHelpers.assertPlainMonthDay(result, "M12", 31, `monthCode M12, day 31, options = ${optionsDesc}`); -}); - -TemporalHelpers.ISOMonths.forEach(({ month, monthCode, daysInMonth }) => { - let result = cal.monthDayFromFields({ month, day: daysInMonth }); - TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, `month ${month}, day ${daysInMonth}`); - - result = cal.monthDayFromFields({ monthCode, day: daysInMonth }); - TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, `monthCode ${monthCode}, day ${daysInMonth}`); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/branding.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/branding.js deleted file mode 100644 index 05cefbf4f0e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const monthDayFromFields = Temporal.Calendar.prototype.monthDayFromFields; - -assert.sameValue(typeof monthDayFromFields, "function"); - -const args = [{ monthCode: "M01", day: 1 }]; - -assert.throws(TypeError, () => monthDayFromFields.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => monthDayFromFields.apply(null, args), "null"); -assert.throws(TypeError, () => monthDayFromFields.apply(true, args), "true"); -assert.throws(TypeError, () => monthDayFromFields.apply("", args), "empty string"); -assert.throws(TypeError, () => monthDayFromFields.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => monthDayFromFields.apply(1, args), "1"); -assert.throws(TypeError, () => monthDayFromFields.apply({}, args), "plain object"); -assert.throws(TypeError, () => monthDayFromFields.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => monthDayFromFields.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/builtin.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/builtin.js deleted file mode 100644 index d21652fc593..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: > - Tests that Temporal.Calendar.prototype.monthDayFromFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.monthDayFromFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.monthDayFromFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.monthDayFromFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.monthDayFromFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/fields-missing-properties.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/fields-missing-properties.js deleted file mode 100644 index 6a3d30d439f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/fields-missing-properties.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Temporal.Calendar.prototype.monthDayFromFields will throw TypeError with incorrect input data type. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Set fields to ? PrepareTemporalFields(fields, « "day", "month", "monthCode", "year" », « "day" »). - 7. Let overflow be ? ToTemporalOverflow(options). - 8. Perform ? ISOResolveMonth(fields). - 9. Let result be ? ISOMonthDayFromFields(fields, overflow). - 10. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], "iso8601", result.[[ReferenceISOYear]]). -features: [Temporal] ----*/ - -let cal = new Temporal.Calendar("iso8601") - -assert.throws(TypeError, () => cal.monthDayFromFields({}), "at least one correctly spelled property is required"); -assert.throws(TypeError, () => cal.monthDayFromFields({ month: 12 }), "day is required with month"); -assert.throws(TypeError, () => cal.monthDayFromFields({ monthCode: "M12" }), "day is required with monthCode"); -assert.throws(TypeError, () => cal.monthDayFromFields({ year: 2021, month: 12 }), "day is required with year and month"); -assert.throws(TypeError, () => cal.monthDayFromFields({ year: 2021, monthCode: "M12" }), "day is required with year and monthCode"); -assert.throws(TypeError, () => cal.monthDayFromFields({ year: 2021, day: 17 }), "either month or monthCode is required"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/fields-not-object.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/fields-not-object.js deleted file mode 100644 index 88c229f074c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/fields-not-object.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Throw a TypeError if the fields is not an object -features: [Symbol, Temporal] ----*/ - -const tests = [undefined, null, true, false, "string", Symbol("sym"), Math.PI, Infinity, NaN, 42n]; -const iso = Temporal.Calendar.from("iso8601"); -for (const fields of tests) { - assert.throws(TypeError, () => iso.monthDayFromFields(fields, {})); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/infinity-throws-rangeerror.js deleted file mode 100644 index 66e2a03b8b8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/infinity-throws-rangeerror.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.monthdayfromfields -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - ["constrain", "reject"].forEach((overflow) => { - assert.throws(RangeError, () => instance.monthDayFromFields({ ...base, [prop]: inf }, { overflow }), `${prop} property cannot be ${inf} (overflow ${overflow}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.monthDayFromFields({ ...base, [prop]: obj }, { overflow })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/length.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/length.js deleted file mode 100644 index a8049a487a3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Temporal.Calendar.prototype.monthDayFromFields.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.monthDayFromFields, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/missing-properties.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/missing-properties.js deleted file mode 100644 index 0c426af6869..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/missing-properties.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Errors due to missing properties on fields object are thrown in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const missingDay = { - get year() { - TemporalHelpers.assertUnreachable("day should be checked first"); - }, - get month() { - TemporalHelpers.assertUnreachable("day should be checked first"); - }, - get monthCode() { - TemporalHelpers.assertUnreachable("day should be checked first"); - }, -}; -assert.throws(TypeError, () => instance.monthDayFromFields(missingDay), "day should be checked before year and month"); - -let got = []; -const fieldsSpy = TemporalHelpers.propertyBagObserver(got, { day: 1 }); -assert.throws(TypeError, () => instance.monthDayFromFields(fieldsSpy), "incomplete fields should be rejected (but after reading all non-required fields)"); -assert.compareArray(got, [ - "get day", - "get day.valueOf", - "call day.valueOf", - "get month", - "get monthCode", - "get year", -], "fields should be read in alphabetical order"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/monthcode-invalid.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/monthcode-invalid.js deleted file mode 100644 index 29e5c4f0984..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/monthcode-invalid.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Throw RangeError for an out-of-range, conflicting, or ill-formed monthCode -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISOMonthDayFromFields(fields, options). - 7. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], calendar, result.[[ReferenceISOYear]]). -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -["m1", "M1", "m01"].forEach((monthCode) => { - assert.throws(RangeError, () => cal.monthDayFromFields({ monthCode, day: 17 }), - `monthCode '${monthCode}' is not well-formed`); -}); - -assert.throws(RangeError, () => cal.monthDayFromFields({ year: 2021, month: 12, monthCode: "M11", day: 17 }), - "monthCode and month conflict"); - -["M00", "M19", "M99", "M13"].forEach((monthCode) => { - assert.throws(RangeError, () => cal.monthDayFromFields({ monthCode, day: 17 }), - `monthCode '${monthCode}' is not valid for ISO 8601 calendar`); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/name.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/name.js deleted file mode 100644 index c3803624825..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Temporal.Calendar.prototype.monthDayFromFields.name is "monthDayFromFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.monthDayFromFields, "name", { - value: "monthDayFromFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/not-a-constructor.js deleted file mode 100644 index 63bcff79eae..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: > - Temporal.Calendar.prototype.monthDayFromFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.monthDayFromFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.monthDayFromFields), false, - "isConstructor(Temporal.Calendar.prototype.monthDayFromFields)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/one-of-era-erayear-undefined.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/one-of-era-erayear-undefined.js deleted file mode 100644 index 4b7f40e22a0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/one-of-era-erayear-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthDayFromFields -description: Does not throw a RangeError if only one of era/eraYear fields is present -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const base = { year: 2000, month: 5, day: 2, era: 'ce' }; -const instance = new Temporal.Calendar('iso8601'); -TemporalHelpers.assertPlainMonthDay(instance.monthDayFromFields({ ...base }), 'M05', 2); - -const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 }; -TemporalHelpers.assertPlainMonthDay(instance.monthDayFromFields({ ...base }), 'M05', 2); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-object.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-object.js deleted file mode 100644 index c8fc1e1dd34..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-object.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Empty or a function object may be used as options -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const result1 = instance.monthDayFromFields({ monthCode: "M12", day: 15 }, {}); -TemporalHelpers.assertPlainMonthDay( - result1, "M12", 15, - "options may be an empty plain object" -); - -const result2 = instance.monthDayFromFields({ monthCode: "M12", day: 15 }, () => {}); -TemporalHelpers.assertPlainMonthDay( - result2, "M12", 15, - "options may be a function object" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-wrong-type.js deleted file mode 100644 index f19f381f5d0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/options-wrong-type.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: TypeError thrown when options argument is a primitive -features: [BigInt, Symbol, Temporal] ----*/ - -const badOptions = [ - null, - true, - "some string", - Symbol(), - 1, - 2n, -]; - -const instance = new Temporal.Calendar("iso8601"); -for (const value of badOptions) { - assert.throws(TypeError, () => instance.monthDayFromFields({ monthCode: "M12", day: 15 }, value), - `TypeError on wrong options type ${typeof value}`); -}; diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/order-of-operations.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/order-of-operations.js deleted file mode 100644 index cc61cedf609..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/order-of-operations.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Properties on objects passed to monthDayFromFields() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get fields.day", - "get fields.day.valueOf", - "call fields.day.valueOf", - "get fields.month", - "get fields.month.valueOf", - "call fields.month.valueOf", - "get fields.monthCode", - "get fields.monthCode.toString", - "call fields.monthCode.toString", - "get fields.year", - "get fields.year.valueOf", - "call fields.year.valueOf", - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; -const actual = []; - -const instance = new Temporal.Calendar("iso8601"); - -const fields = TemporalHelpers.propertyBagObserver(actual, { - year: 1.7, - month: 1.7, - monthCode: "M01", - day: 1.7, -}, "fields"); - -const options = TemporalHelpers.propertyBagObserver(actual, { - overflow: "reject", -}, "options"); - -const result = instance.monthDayFromFields(fields, options); -TemporalHelpers.assertPlainMonthDay(result, "M01", 1, "monthDay result"); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot should store a string"); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-constrain.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-constrain.js deleted file mode 100644 index 4388661217f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-constrain.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Temporal.Calendar.prototype.monthDayFromFields will return correctly with data and overflow set to 'constrain'. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Set fields to ? PrepareTemporalFields(fields, « "day", "month", "monthCode", "year" », « "day" »). - 7. Let overflow be ? ToTemporalOverflow(options). - 8. Perform ? ISOResolveMonth(fields). - 9. Let result be ? ISOMonthDayFromFields(fields, overflow). - 10. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], "iso8601", result.[[ReferenceISOYear]]). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); -const opt = { overflow: "constrain" }; - -let result = cal.monthDayFromFields({ year: 2021, month: 13, day: 1 }, opt); -TemporalHelpers.assertPlainMonthDay(result, "M12", 1, "month 13 is constrained to 12"); - -result = cal.monthDayFromFields({ year: 2021, month: 999999, day: 500 }, opt); -TemporalHelpers.assertPlainMonthDay(result, "M12", 31, "month 999999 is constrained to 12 and day 500 is constrained to 31"); - -[-99999, -1, 0].forEach((month) => { - assert.throws( - RangeError, - () => cal.monthDayFromFields({ year: 2021, month, day: 1 }, opt), - `Month ${month} is out of range for 2021 even with overflow: constrain` - ); -}); - -TemporalHelpers.ISOMonths.forEach(({ month, monthCode, daysInMonth }) => { - const day = daysInMonth + 1; - - result = cal.monthDayFromFields({ month, day }, opt); - TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, - `day is constrained from ${day} to ${daysInMonth} in month ${month}`); - - result = cal.monthDayFromFields({ month, day: 9001 }, opt); - TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, - `day is constrained to ${daysInMonth} in month ${month}`); - - result = cal.monthDayFromFields({ monthCode, day }, opt); - TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, - `day is constrained from ${day} to ${daysInMonth} in monthCode ${monthCode}`); - - result = cal.monthDayFromFields({ monthCode, day: 9001 }, opt); - TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, - `day is constrained to ${daysInMonth} in monthCode ${monthCode}`); -}); - -[ ["month", 2], ["monthCode", "M02"] ].forEach(([ name, value ]) => { - result = cal.monthDayFromFields({ year: 2020, [name]: value, day: 30 }, opt); - TemporalHelpers.assertPlainMonthDay(result, "M02", 29, `${name} ${value} is constrained to 29 in leap year 2020`); - - result = cal.monthDayFromFields({ year: 2021, [name]: value, day: 29 }, opt); - TemporalHelpers.assertPlainMonthDay(result, "M02", 28, `${name} ${value} is constrained to 28 in common year 2021`); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-invalid-string.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-invalid-string.js deleted file mode 100644 index 6844c7e3d2b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-invalid-string.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: RangeError thrown when overflow option not one of the allowed string values -info: | - sec-getoption step 10: - 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal-isomonthdayfromfields step 2: - 2. Let _overflow_ be ? ToTemporalOverflow(_options_). - sec-temporal.calendar.prototype.monthdayfromfields step 6: - 6. Let _result_ be ? ISOMonthDayFromFields(_fields_, _options_). -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"]; -for (const overflow of badOverflows) { - assert.throws( - RangeError, - () => calendar.monthDayFromFields({ year: 2000, month: 5, day: 2 }, { overflow }), - `invalid overflow ("${overflow}")` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-reject.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-reject.js deleted file mode 100644 index 6fe0227ff3c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-reject.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Throw RangeError for input data out of range with overflow reject -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Set fields to ? PrepareTemporalFields(fields, « "day", "month", "monthCode", "year" », « "day" »). - 7. Let overflow be ? ToTemporalOverflow(options). - 8. Perform ? ISOResolveMonth(fields). - 9. Let result be ? ISOMonthDayFromFields(fields, overflow). - 10. Return ? CreateTemporalMonthDay(result.[[Month]], result.[[Day]], "iso8601", result.[[ReferenceISOYear]]). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -[-1, 0, 13, 9995].forEach((month) => { - assert.throws( - RangeError, - () => cal.monthDayFromFields({year: 2021, month, day: 5}, { overflow: "reject" }), - `Month ${month} is out of range for 2021 with overflow: reject` - ); -}); - -[-1, 0, 32, 999].forEach((day) => { - assert.throws( - RangeError, - () => cal.monthDayFromFields({ year: 2021, month: 12, day }, { overflow: "reject" }), - `Day ${day} is out of range for 2021-12 with overflow: reject` - ); - assert.throws( - RangeError, - () => cal.monthDayFromFields({ monthCode: "M12", day }, { overflow: "reject" }), - `Day ${day} is out of range for 2021-M12 with overflow: reject` - ); -}); - -TemporalHelpers.ISOMonths.forEach(({ month, monthCode, daysInMonth }) => { - const day = daysInMonth + 1; - assert.throws(RangeError, - () => cal.monthDayFromFields({ month, day }, { overflow: "reject" }), - `Day ${day} is out of range for month ${month} with overflow: reject`); - assert.throws(RangeError, - () => cal.monthDayFromFields({ monthCode, day }, { overflow: "reject" }), - `Day ${day} is out of range for monthCode ${monthCode} with overflow: reject`); -}); - -[ ["month", 2], ["monthCode", "M02"] ].forEach(([ name, value ]) => { - assert.throws(RangeError, - () => cal.monthDayFromFields({ year: 2020, [name]: value, day: 30 }, { overflow: "reject" }), - `Day 30 is out of range for ${name} ${value} in leap year 2020 with overflow: reject`); - assert.throws(RangeError, - () => cal.monthDayFromFields({ year: 2021, [name]: value, day: 29 }, { overflow: "reject" }), - `Day 29 is out of range for ${name} ${value} in common year 2021 with overflow: reject`); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-undefined.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-undefined.js deleted file mode 100644 index 75479d317ae..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-undefined.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Fallback value for overflow option -info: | - sec-getoption step 3: - 3. If _value_ is *undefined*, return _fallback_. - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal-isomonthdayfromfields step 2: - 2. Let _overflow_ be ? ToTemporalOverflow(_options_). - sec-temporal.calendar.prototype.monthdayfromfields step 6: - 6. Let _result_ be ? ISOMonthDayFromFields(_fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); - -const explicit = calendar.monthDayFromFields({ year: 2000, month: 15, day: 2 }, { overflow: undefined }); -TemporalHelpers.assertPlainMonthDay(explicit, "M12", 2, "default overflow is constrain"); -const implicit = calendar.monthDayFromFields({ year: 2000, month: 15, day: 2 }, {}); -TemporalHelpers.assertPlainMonthDay(implicit, "M12", 2, "default overflow is constrain"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-wrong-type.js deleted file mode 100644 index 197ad0677ea..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/overflow-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Type conversions for overflow option -info: | - sec-getoption step 9.a: - a. Set _value_ to ? ToString(_value_). - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal-isomonthdayfromfields step 2: - 2. Let _overflow_ be ? ToTemporalOverflow(_options_). - sec-temporal.calendar.prototype.monthdayfromfields step 6: - 6. Let _result_ be ? ISOMonthDayFromFields(_fields_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -TemporalHelpers.checkStringOptionWrongType("overflow", "constrain", - (overflow) => calendar.monthDayFromFields({ year: 2000, month: 5, day: 2 }, { overflow }), - (result, descr) => TemporalHelpers.assertPlainMonthDay(result, "M05", 2, descr), -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/prop-desc.js deleted file mode 100644 index edfb6881fc6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthDayFromFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: The "monthDayFromFields" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.monthDayFromFields, - "function", - "`typeof Calendar.prototype.monthDayFromFields` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "monthDayFromFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index f86fbfe1dae..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.monthsInYear(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 0728948c2b7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.monthsInYear(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 85db3e6b705..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.monthsInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-duplicate-calendar-fields.js deleted file mode 100644 index 90719c38f82..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.monthsInYear(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-leap-second.js deleted file mode 100644 index 7a80b2990e8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.monthsInYear(arg); -assert.sameValue( - result1, - 12, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.monthsInYear(arg); -assert.sameValue( - result2, - 12, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-number.js deleted file mode 100644 index 252ae005cd5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.monthsInYear(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 27a09872aae..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.monthsInYear(arg); -assert.sameValue(result, 12, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 920e9f49d1e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.monthsInYear(arg); - assert.sameValue(result, 12, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index f03a83024a2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.monthsInYear(arg); -assert.sameValue( - result, - 12, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-number.js deleted file mode 100644 index 169e31b8255..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.monthsInYear(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-string.js deleted file mode 100644 index 8c1930eb07c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.monthsInYear(arg); -assert.sameValue(result, 12, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 5ff6ccaed0b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.monthsInYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.monthsInYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index aa7239a6a59..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.monthsInYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-proto-in-calendar-fields.js deleted file mode 100644 index 7030f584d94..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.monthsInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index d04ea566edf..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.monthsInYear(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation.js deleted file mode 100644 index c19e1d7a05b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.monthsInYear(arg); - - assert.sameValue( - result, - 12, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-critical-unknown-annotation.js deleted file mode 100644 index f7de7fc9360..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthsInYear(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-date-with-utc-offset.js deleted file mode 100644 index 95018bc29d9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.monthsInYear(arg); - - assert.sameValue( - result, - 12, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.monthsInYear(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-invalid.js deleted file mode 100644 index 811a6e00cb3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.monthsInYear(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-calendar.js deleted file mode 100644 index 9ec5f1eb753..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthsInYear(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-time-zone.js deleted file mode 100644 index d411ff9c962..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthsInYear(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-separators.js deleted file mode 100644 index aa8a24f7be9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.monthsInYear(arg); - - assert.sameValue( - result, - 12, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-zone-annotation.js deleted file mode 100644 index baa576f82cf..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.monthsInYear(arg); - - assert.sameValue( - result, - 12, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-unknown-annotation.js deleted file mode 100644 index 118150626ed..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.monthsInYear(arg); - - assert.sameValue( - result, - 12, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-with-utc-designator.js deleted file mode 100644 index 6525702930c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthsInYear(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string.js deleted file mode 100644 index 9a8748d8771..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: An ISO 8601 date string should be converted as input -info: | - a. Perform ? ToTemporalDate(temporalDateLike). - 5. Return 12𝔽. -features: [Temporal] ----*/ - -let cal = new Temporal.Calendar("iso8601"); - -assert.sameValue(cal.monthsInYear("3456-12-20"), 12); -assert.sameValue(cal.monthsInYear("+000998-01-28"), 12); -assert.sameValue(cal.monthsInYear("3456-12-20T03:04:05+00:00[UTC]"), 12); -assert.sameValue(cal.monthsInYear("+000998-01-28T03:04:05+00:00[UTC]"), 12); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-wrong-type.js deleted file mode 100644 index 9e785c1fdee..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.monthsInYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.monthsInYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-convert.js deleted file mode 100644 index a5050bb0f2b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.monthsInYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-slots.js deleted file mode 100644 index c3d93941dee..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.monthsInYear(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index f2d34fd60b2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.monthsInYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 26d4bd540bd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.monthsInYear(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 11bfe119b2f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.monthsInYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index b6ae9f5e509..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.monthsInYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/basic.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/basic.js deleted file mode 100644 index 9edcee17457..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/basic.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Basic tests for monthsInYear(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 12; -assert.sameValue(iso.monthsInYear(new Temporal.PlainDate(1994, 11, 5)), res, "PlainDate"); -assert.sameValue(iso.monthsInYear(new Temporal.PlainDateTime(1994, 11, 5, 8, 15, 30)), res, "PlainDateTime"); -assert.sameValue(iso.monthsInYear(new Temporal.PlainYearMonth(1994, 11)), res, "PlainYearMonth"); -assert.sameValue(iso.monthsInYear({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.monthsInYear("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.monthsInYear({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/branding.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/branding.js deleted file mode 100644 index 8db18504436..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const monthsInYear = Temporal.Calendar.prototype.monthsInYear; - -assert.sameValue(typeof monthsInYear, "function"); - -const args = [new Temporal.PlainDate(2021, 3, 4)]; - -assert.throws(TypeError, () => monthsInYear.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => monthsInYear.apply(null, args), "null"); -assert.throws(TypeError, () => monthsInYear.apply(true, args), "true"); -assert.throws(TypeError, () => monthsInYear.apply("", args), "empty string"); -assert.throws(TypeError, () => monthsInYear.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => monthsInYear.apply(1, args), "1"); -assert.throws(TypeError, () => monthsInYear.apply({}, args), "plain object"); -assert.throws(TypeError, () => monthsInYear.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => monthsInYear.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/builtin.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/builtin.js deleted file mode 100644 index bb572670642..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: > - Tests that Temporal.Calendar.prototype.monthsInYear - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.monthsInYear), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.monthsInYear), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.monthsInYear), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.monthsInYear.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 838aff96f6f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.monthsInYear({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/calendar-fields-iterable.js deleted file mode 100644 index 79b6eb0ac22..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/calendar-fields-iterable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.monthsinyear step 4: - 4. Perform ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.monthsInYear({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/calendar-temporal-object.js deleted file mode 100644 index 3d6418662b0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.monthsinyear step 4: - 4. Perform ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.monthsInYear({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/infinity-throws-rangeerror.js deleted file mode 100644 index eac600f4670..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.monthsinyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.monthsInYear({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.monthsInYear({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/length.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/length.js deleted file mode 100644 index ac6057351de..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Temporal.Calendar.prototype.monthsInYear.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.monthsInYear, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/name.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/name.js deleted file mode 100644 index ce9468d16f3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Temporal.Calendar.prototype.monthsInYear.name is "monthsInYear". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.monthsInYear, "name", { - value: "monthsInYear", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/not-a-constructor.js deleted file mode 100644 index 9e9a64d9646..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: > - Temporal.Calendar.prototype.monthsInYear does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.monthsInYear(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.monthsInYear), false, - "isConstructor(Temporal.Calendar.prototype.monthsInYear)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/prop-desc.js deleted file mode 100644 index c6b47d059df..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: The "monthsInYear" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.monthsInYear, - "function", - "`typeof Calendar.prototype.monthsInYear` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "monthsInYear", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/year-zero.js deleted file mode 100644 index 6e3e0b960e5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthsinyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.monthsInYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/prop-desc.js deleted file mode 100644 index bf03d384cae..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/prop-desc.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-calendar-prototype -description: The "prototype" property of Temporal.Calendar -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue(typeof Temporal.Calendar.prototype, "object"); -assert.notSameValue(Temporal.Calendar.prototype, null); - -verifyProperty(Temporal.Calendar, "prototype", { - writable: false, - enumerable: false, - configurable: false, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/toJSON/branding.js b/test/built-ins/Temporal/Calendar/prototype/toJSON/branding.js deleted file mode 100644 index 38b3dcb2dd1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toJSON/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tojson -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toJSON = Temporal.Calendar.prototype.toJSON; - -assert.sameValue(typeof toJSON, "function"); - -assert.throws(TypeError, () => toJSON.call(undefined), "undefined"); -assert.throws(TypeError, () => toJSON.call(null), "null"); -assert.throws(TypeError, () => toJSON.call(true), "true"); -assert.throws(TypeError, () => toJSON.call(""), "empty string"); -assert.throws(TypeError, () => toJSON.call(Symbol()), "symbol"); -assert.throws(TypeError, () => toJSON.call(1), "1"); -assert.throws(TypeError, () => toJSON.call({}), "plain object"); -assert.throws(TypeError, () => toJSON.call(Temporal.Calendar), "Temporal.Calendar"); -assert.throws(TypeError, () => toJSON.call(Temporal.Calendar.prototype), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/toJSON/builtin.js b/test/built-ins/Temporal/Calendar/prototype/toJSON/builtin.js deleted file mode 100644 index f2ab05afa82..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toJSON/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tojson -description: > - Tests that Temporal.Calendar.prototype.toJSON - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.toJSON), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.toJSON), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.toJSON), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.toJSON.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/toJSON/length.js b/test/built-ins/Temporal/Calendar/prototype/toJSON/length.js deleted file mode 100644 index d616b4205f9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toJSON/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tojson -description: Temporal.Calendar.prototype.toJSON.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.toJSON, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/toJSON/name.js b/test/built-ins/Temporal/Calendar/prototype/toJSON/name.js deleted file mode 100644 index 7ad399501c8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toJSON/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tojson -description: Temporal.Calendar.prototype.toJSON.name is "toJSON". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.toJSON, "name", { - value: "toJSON", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/toJSON/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/toJSON/not-a-constructor.js deleted file mode 100644 index b8b839f23b4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toJSON/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tojson -description: > - Temporal.Calendar.prototype.toJSON does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.toJSON(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.toJSON), false, - "isConstructor(Temporal.Calendar.prototype.toJSON)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/toJSON/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/toJSON/prop-desc.js deleted file mode 100644 index e1b676ad6ad..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toJSON/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tojson -description: The "toJSON" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.toJSON, - "function", - "`typeof Calendar.prototype.toJSON` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "toJSON", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/toJSON/returns-identifier-slot.js b/test/built-ins/Temporal/Calendar/prototype/toJSON/returns-identifier-slot.js deleted file mode 100644 index 2bcca910d26..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toJSON/returns-identifier-slot.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tojson -description: toJSON() returns the internal slot value -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; - -const calendar = new Temporal.Calendar("iso8601"); -TemporalHelpers.observeProperty(actual, calendar, Symbol.toPrimitive, undefined); -TemporalHelpers.observeProperty(actual, calendar, "id", "bogus"); -TemporalHelpers.observeProperty(actual, calendar, "toString", function () { - actual.push("call calendar.toString"); - return "gregory"; -}); - -const result = calendar.toJSON(); -assert.sameValue(result, "iso8601", "toJSON gets the internal slot value"); -assert.compareArray(actual, [], "should not invoke any observable operations"); diff --git a/test/built-ins/Temporal/Calendar/prototype/toString/branding.js b/test/built-ins/Temporal/Calendar/prototype/toString/branding.js deleted file mode 100644 index 21449e54112..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toString/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tostring -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toString = Temporal.Calendar.prototype.toString; - -assert.sameValue(typeof toString, "function"); - -assert.throws(TypeError, () => toString.call(undefined), "undefined"); -assert.throws(TypeError, () => toString.call(null), "null"); -assert.throws(TypeError, () => toString.call(true), "true"); -assert.throws(TypeError, () => toString.call(""), "empty string"); -assert.throws(TypeError, () => toString.call(Symbol()), "symbol"); -assert.throws(TypeError, () => toString.call(1), "1"); -assert.throws(TypeError, () => toString.call({}), "plain object"); -assert.throws(TypeError, () => toString.call(Temporal.Calendar), "Temporal.Calendar"); -assert.throws(TypeError, () => toString.call(Temporal.Calendar.prototype), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/toString/builtin.js b/test/built-ins/Temporal/Calendar/prototype/toString/builtin.js deleted file mode 100644 index d2a6ca26eed..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toString/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tostring -description: > - Tests that Temporal.Calendar.prototype.toString - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.toString), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.toString), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.toString), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.toString.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/toString/length.js b/test/built-ins/Temporal/Calendar/prototype/toString/length.js deleted file mode 100644 index 2e14f87b003..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toString/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tostring -description: Temporal.Calendar.prototype.toString.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.toString, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/toString/name.js b/test/built-ins/Temporal/Calendar/prototype/toString/name.js deleted file mode 100644 index 86904315dbf..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toString/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tostring -description: Temporal.Calendar.prototype.toString.name is "toString". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.toString, "name", { - value: "toString", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/toString/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/toString/not-a-constructor.js deleted file mode 100644 index 04bb7e013f5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toString/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tostring -description: > - Temporal.Calendar.prototype.toString does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.toString(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.toString), false, - "isConstructor(Temporal.Calendar.prototype.toString)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/toString/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/toString/prop-desc.js deleted file mode 100644 index 20f371881ea..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toString/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.tostring -description: The "toString" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.toString, - "function", - "`typeof Calendar.prototype.toString` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "toString", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/toStringTag/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/toStringTag/prop-desc.js deleted file mode 100644 index a1a6b83b463..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/toStringTag/prop-desc.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype-@@tostringtag -description: The @@toStringTag property of Temporal.Calendar -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype, Symbol.toStringTag, { - value: "Temporal.Calendar", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 545eecf6359..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.weekOfYear(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 24233a730a4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.weekOfYear(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-constructor-in-calendar-fields.js deleted file mode 100644 index a788ec42f4f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.weekOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-duplicate-calendar-fields.js deleted file mode 100644 index 3d51dd9f8fe..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.weekOfYear(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-leap-second.js deleted file mode 100644 index 6d9e9695245..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.weekOfYear(arg); -assert.sameValue( - result1, - 52, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.weekOfYear(arg); -assert.sameValue( - result2, - 52, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-number.js deleted file mode 100644 index 538df916a88..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.weekOfYear(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-plaindate.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-plaindate.js deleted file mode 100644 index 5f9f4da0d49..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-plaindate.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Temporal.Calendar.prototype.weekOfYear will take Temporal.PlainDate object - and return the week of year of that date. -info: | - 4. Let temporalDate be ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ToISOWeekOfYear(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])). -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -// The following week numbers are taken from the table "Examples of contemporary -// dates around New Year's Day" from -// https://en.wikipedia.org/wiki/ISO_week_date#Relation_with_the_Gregorian_calendar - -let d = new Temporal.PlainDate(1977, 1, 1); -assert.sameValue(cal.weekOfYear(d), 53, "1977-01-01 is in w53"); - -d = new Temporal.PlainDate(1977, 1, 2); -assert.sameValue(cal.weekOfYear(d), 53, "1977-01-02 is in w53"); - -d = new Temporal.PlainDate(1977, 12, 31); -assert.sameValue(cal.weekOfYear(d), 52, "1977-12-31 is in w52"); - -d = new Temporal.PlainDate(1978, 1, 1); -assert.sameValue(cal.weekOfYear(d), 52, "1978-01-01 is in w52"); - -d = new Temporal.PlainDate(1978, 1, 2); -assert.sameValue(cal.weekOfYear(d), 1, "1978-01-02 is in w01"); - -d = new Temporal.PlainDate(1978, 12, 31); -assert.sameValue(cal.weekOfYear(d), 52, "1978-12-31 is in w52"); - -d = new Temporal.PlainDate(1979, 1, 1); -assert.sameValue(cal.weekOfYear(d), 1, "1979-01-01 is in w01"); - -d = new Temporal.PlainDate(1979, 12, 30); -assert.sameValue(cal.weekOfYear(d), 52, "1979-12-30 is in w52"); - -d = new Temporal.PlainDate(1979, 12, 31); -assert.sameValue(cal.weekOfYear(d), 1, "1979-12-31 is in w01"); - -d = new Temporal.PlainDate(1980, 1, 1); -assert.sameValue(cal.weekOfYear(d), 1, "1980-01-01 is in w01"); - -d = new Temporal.PlainDate(1980, 12, 28); -assert.sameValue(cal.weekOfYear(d), 52, "1980-12-28 is in w52"); - -d = new Temporal.PlainDate(1980, 12, 29); -assert.sameValue(cal.weekOfYear(d), 1, "1980-12-29 is in w01"); - -d = new Temporal.PlainDate(1980, 12, 30); -assert.sameValue(cal.weekOfYear(d), 1, "1980-12-30 is in w01"); - -d = new Temporal.PlainDate(1980, 12, 31); -assert.sameValue(cal.weekOfYear(d), 1, "1980-12-31 is in w01"); - -d = new Temporal.PlainDate(1981, 1, 1); -assert.sameValue(cal.weekOfYear(d), 1, "1981-01-01 is in w01"); - -d = new Temporal.PlainDate(1981, 12, 31); -assert.sameValue(cal.weekOfYear(d), 53, "1981-12-31 is in w53"); - -d = new Temporal.PlainDate(1982, 1, 1); -assert.sameValue(cal.weekOfYear(d), 53, "1982-01-01 is in w53"); - -d = new Temporal.PlainDate(1982, 1, 2); -assert.sameValue(cal.weekOfYear(d), 53, "1982-01-02 is in w53"); - -d = new Temporal.PlainDate(1982, 1, 3); -assert.sameValue(cal.weekOfYear(d), 53, "1982-01-03 is in w53"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-plaindatetime.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-plaindatetime.js deleted file mode 100644 index e7546bb7119..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-plaindatetime.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Temporal.Calendar.prototype.weekOfYear will take Temporal.PlainDateTime object - and return the week of year of that date. -info: | - 4. Let temporalDate be ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ToISOWeekOfYear(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])). -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -// The following week numbers are taken from the table "Examples of contemporary -// dates around New Year's Day" from -// https://en.wikipedia.org/wiki/ISO_week_date#Relation_with_the_Gregorian_calendar - -let dt = new Temporal.PlainDateTime(1977, 1, 1, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 53, "1977-01-01 is in w53"); - -dt = new Temporal.PlainDateTime(1977, 1, 2, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 53, "1977-01-02 is in w53"); - -dt = new Temporal.PlainDateTime(1977, 12, 31, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 52, "1977-12-31 is in w52"); - -dt = new Temporal.PlainDateTime(1978, 1, 1, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 52, "1978-01-01 is in w52"); - -dt = new Temporal.PlainDateTime(1978, 1, 2, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 1, "1978-01-02 is in w01"); - -dt = new Temporal.PlainDateTime(1978, 12, 31, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 52, "1978-12-31 is in w52"); - -dt = new Temporal.PlainDateTime(1979, 1, 1, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 1, "1979-01-01 is in w01"); - -dt = new Temporal.PlainDateTime(1979, 12, 30, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 52, "1979-12-30 is in w52"); - -dt = new Temporal.PlainDateTime(1979, 12, 31, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 1, "1979-12-31 is in w01"); - -dt = new Temporal.PlainDateTime(1980, 1, 1, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 1, "1980-01-01 is in w01"); - -dt = new Temporal.PlainDateTime(1980, 12, 28, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 52, "1980-12-28 is in w52"); - -dt = new Temporal.PlainDateTime(1980, 12, 29, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 1, "1980-12-29 is in w01"); - -dt = new Temporal.PlainDateTime(1980, 12, 30, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 1, "1980-12-30 is in w01"); - -dt = new Temporal.PlainDateTime(1980, 12, 31, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 1, "1980-12-31 is in w01"); - -dt = new Temporal.PlainDateTime(1981, 1, 1, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 1, "1981-01-01 is in w01"); - -dt = new Temporal.PlainDateTime(1981, 12, 31, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 53, "1981-12-31 is in w53"); - -dt = new Temporal.PlainDateTime(1982, 1, 1, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 53, "1982-01-01 is in w53"); - -dt = new Temporal.PlainDateTime(1982, 1, 2, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 53, "1982-01-02 is in w53"); - -dt = new Temporal.PlainDateTime(1982, 1, 3, 9, 8); -assert.sameValue(cal.weekOfYear(dt), 53, "1982-01-03 is in w53"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 7458eed38fa..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.weekOfYear(arg); -assert.sameValue(result, 47, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 33e0ecf68d1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.weekOfYear(arg); - assert.sameValue(result, 47, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 330cdb114a9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.weekOfYear(arg); -assert.sameValue( - result, - 47, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-number.js deleted file mode 100644 index fa14a87025c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.weekOfYear(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-string.js deleted file mode 100644 index 553543a140e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.weekOfYear(arg); -assert.sameValue(result, 47, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 0ffb5492a60..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.weekOfYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.weekOfYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index f7cc984a481..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.weekOfYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-proto-in-calendar-fields.js deleted file mode 100644 index 56a0915d048..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.weekOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 0587d163db1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.weekOfYear(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation.js deleted file mode 100644 index d56595ab721..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.weekOfYear(arg); - - assert.sameValue( - result, - 18, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 3912c159072..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.weekOfYear(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-date-with-utc-offset.js deleted file mode 100644 index e96547c23f8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.weekOfYear(arg); - - assert.sameValue( - result, - 18, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.weekOfYear(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-invalid.js deleted file mode 100644 index 7b8e721b7e3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.weekOfYear(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-calendar.js deleted file mode 100644 index f5261c6cbb2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.weekOfYear(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-time-zone.js deleted file mode 100644 index 7619b36d054..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.weekOfYear(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-separators.js deleted file mode 100644 index 5ab5184233e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.weekOfYear(arg); - - assert.sameValue( - result, - 18, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-zone-annotation.js deleted file mode 100644 index 1149499fc1f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.weekOfYear(arg); - - assert.sameValue( - result, - 18, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-unknown-annotation.js deleted file mode 100644 index 951d276a1c8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.weekOfYear(arg); - - assert.sameValue( - result, - 18, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-with-utc-designator.js deleted file mode 100644 index 65513108298..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.weekOfYear(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string.js deleted file mode 100644 index f031d046900..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-string.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Temporal.Calendar.prototype.weekOfYear will take an ISO 8601 date string and - return the week of year of that date. -info: | - 4. Let temporalDate be ? ToTemporalDate(temporalDateLike). - 5. Return 𝔽(! ToISOWeekOfYear(temporalDate.[[ISOYear]], temporalDate.[[ISOMonth]], temporalDate.[[ISODay]])). -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -// The following week numbers are taken from the table "Examples of contemporary -// dates around New Year's Day" from -// https://en.wikipedia.org/wiki/ISO_week_date#Relation_with_the_Gregorian_calendar - -assert.sameValue(cal.weekOfYear("1977-01-01"), 53, "1977-01-01 is in w53"); -assert.sameValue(cal.weekOfYear("1977-01-02"), 53, "1977-01-02 is in w53"); -assert.sameValue(cal.weekOfYear("1977-12-31"), 52, "1977-12-31 is in w52"); -assert.sameValue(cal.weekOfYear("1978-01-01"), 52, "1978-01-01 is in w52"); -assert.sameValue(cal.weekOfYear("1978-01-02"), 1, "1978-01-02 is in w01"); -assert.sameValue(cal.weekOfYear("1978-12-31"), 52, "1978-12-31 is in w52"); -assert.sameValue(cal.weekOfYear("1979-01-01"), 1, "1979-01-01 is in w01"); -assert.sameValue(cal.weekOfYear("1979-12-30"), 52, "1979-12-30 is in w52"); -assert.sameValue(cal.weekOfYear("1979-12-31"), 1, "1979-12-31 is in w01"); -assert.sameValue(cal.weekOfYear("1980-01-01"), 1, "1980-01-01 is in w01"); -assert.sameValue(cal.weekOfYear("1980-12-28"), 52, "1980-12-28 is in w52"); -assert.sameValue(cal.weekOfYear("1980-12-29"), 1, "1980-12-29 is in w01"); -assert.sameValue(cal.weekOfYear("1980-12-30"), 1, "1980-12-30 is in w01"); -assert.sameValue(cal.weekOfYear("1980-12-31"), 1, "1980-12-31 is in w01"); -assert.sameValue(cal.weekOfYear("1981-01-01"), 1, "1981-01-01 is in w01"); -assert.sameValue(cal.weekOfYear("1981-12-31"), 53, "1981-12-31 is in w53"); -assert.sameValue(cal.weekOfYear("1982-01-01"), 53, "1982-01-01 is in w53"); -assert.sameValue(cal.weekOfYear("1982-01-02"), 53, "1982-01-02 is in w53"); -assert.sameValue(cal.weekOfYear("1982-01-03"), 53, "1982-01-03 is in w53"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-wrong-type.js deleted file mode 100644 index bf623233e7e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.weekOfYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.weekOfYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-convert.js deleted file mode 100644 index 1a092531400..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.weekOfYear(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-slots.js deleted file mode 100644 index e1853507030..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.weekOfYear(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 6e0a16ce7f3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.weekOfYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index a8d981c370e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.weekOfYear(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 7904e987a7a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.weekOfYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 37c24885ad1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.weekOfYear(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/basic.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/basic.js deleted file mode 100644 index 9dd388e959b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/basic.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Basic tests for weekOfYear(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 44; -assert.sameValue(iso.weekOfYear(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.weekOfYear(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.weekOfYear({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.weekOfYear("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.weekOfYear({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/branding.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/branding.js deleted file mode 100644 index dc217eaa7b1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const weekOfYear = Temporal.Calendar.prototype.weekOfYear; - -assert.sameValue(typeof weekOfYear, "function"); - -const args = [new Temporal.PlainDate(2021, 7, 20)]; - -assert.throws(TypeError, () => weekOfYear.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => weekOfYear.apply(null, args), "null"); -assert.throws(TypeError, () => weekOfYear.apply(true, args), "true"); -assert.throws(TypeError, () => weekOfYear.apply("", args), "empty string"); -assert.throws(TypeError, () => weekOfYear.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => weekOfYear.apply(1, args), "1"); -assert.throws(TypeError, () => weekOfYear.apply({}, args), "plain object"); -assert.throws(TypeError, () => weekOfYear.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => weekOfYear.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/builtin.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/builtin.js deleted file mode 100644 index 8234ce5a752..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Tests that Temporal.Calendar.prototype.weekOfYear - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.weekOfYear), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.weekOfYear), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.weekOfYear), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.weekOfYear.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index c75c1d52145..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.weekOfYear({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-fields-iterable.js deleted file mode 100644 index 2c485c5b0a9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-fields-iterable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.weekofyear step 4: - 4. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.weekOfYear({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-temporal-object.js deleted file mode 100644 index 8dbfb76c93b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.weekofyear step 4: - 4. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.weekOfYear({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/cross-year.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/cross-year.js deleted file mode 100644 index 609c076fb7c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/cross-year.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: weekOfYear() crossing year boundaries. -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -assert.sameValue(iso.weekOfYear(Temporal.PlainDate.from("2019-12-31")), 1, "week 1 from next year"); -assert.sameValue(iso.weekOfYear(Temporal.PlainDate.from("2021-01-01")), 53, "week 1 from next year"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/custom-calendar-weekofyear.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/custom-calendar-weekofyear.js deleted file mode 100644 index c9871143617..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/custom-calendar-weekofyear.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Temporal.Calendar.prototype.weekOfYear returns undefined for all - custom calendars where weekOfYear() returns undefined. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - weekOfYear() { - return undefined; - } -} - -const calendar = new CustomCalendar(); -const customCalendarDate = { month: 1, day: 1, year: 2024, calendar}; -assert.sameValue(calendar.weekOfYear({...customCalendarDate}), undefined); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/infinity-throws-rangeerror.js deleted file mode 100644 index 6a65cf5befd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.weekofyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.weekOfYear({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.weekOfYear({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/length.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/length.js deleted file mode 100644 index f1f2b5f2c63..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Temporal.Calendar.prototype.weekOfYear.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.weekOfYear, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/name.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/name.js deleted file mode 100644 index f7828b8bcb8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Temporal.Calendar.prototype.weekOfYear.name is "weekOfYear". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.weekOfYear, "name", { - value: "weekOfYear", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/not-a-constructor.js deleted file mode 100644 index 3d1d944a4b8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Temporal.Calendar.prototype.weekOfYear does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.weekOfYear(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.weekOfYear), false, - "isConstructor(Temporal.Calendar.prototype.weekOfYear)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/prop-desc.js deleted file mode 100644 index c0c9c672151..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: The "weekOfYear" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.weekOfYear, - "function", - "`typeof Calendar.prototype.weekOfYear` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "weekOfYear", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/year-zero.js deleted file mode 100644 index 0a2cdc66e27..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.weekOfYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 2825650865b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.year(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 9af0d868591..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.year(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-constructor-in-calendar-fields.js deleted file mode 100644 index e75b31aad3f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.year -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.year(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-duplicate-calendar-fields.js deleted file mode 100644 index f32d15c2907..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.year -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.year(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-leap-second.js deleted file mode 100644 index 7520460dedb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.year(arg); -assert.sameValue( - result1, - 2016, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.year(arg); -assert.sameValue( - result2, - 2016, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-number.js deleted file mode 100644 index 3b824b599af..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.year(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index a5b6f52676a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.year(arg); -assert.sameValue(result, 1976, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 7f27c234084..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.year(arg); - assert.sameValue(result, 1976, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 8f8d5ef5861..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.year(arg); -assert.sameValue( - result, - 1976, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-number.js deleted file mode 100644 index 7ec6061ba06..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.year(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-string.js deleted file mode 100644 index 178a13dfd19..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.year(arg); -assert.sameValue(result, 1976, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index c6af001a5f3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.year(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.year(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index ac7684893e8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.year(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-proto-in-calendar-fields.js deleted file mode 100644 index fadb95c3212..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.year -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.year(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index b6d34e38fe0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.year(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation.js deleted file mode 100644 index 422ec49498f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.year(arg); - - assert.sameValue( - result, - 2000, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 0d5e92f9fac..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.year(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-date-with-utc-offset.js deleted file mode 100644 index 981f5939f00..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.year(arg); - - assert.sameValue( - result, - 2000, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.year(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-invalid.js deleted file mode 100644 index e186a2321f8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.year(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-calendar.js deleted file mode 100644 index da117a163ed..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.year(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-time-zone.js deleted file mode 100644 index 5716b9abca4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.year(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-separators.js deleted file mode 100644 index 7e2aa42d8d8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.year(arg); - - assert.sameValue( - result, - 2000, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-zone-annotation.js deleted file mode 100644 index 574421e7d4f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.year(arg); - - assert.sameValue( - result, - 2000, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-unknown-annotation.js deleted file mode 100644 index e6ab34eeeeb..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.year(arg); - - assert.sameValue( - result, - 2000, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-string-with-utc-designator.js deleted file mode 100644 index 5d8a8c91c72..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.year(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-wrong-type.js deleted file mode 100644 index 8bed19608a3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.year(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.year(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-convert.js deleted file mode 100644 index 1d5119c99ed..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.year(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-slots.js deleted file mode 100644 index 5436a91b260..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.year(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 841eb842ac4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.year(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 85e3b99f8d5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.year(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index c1f22aa861c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.year(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 69ff998d533..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.year(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/basic.js b/test/built-ins/Temporal/Calendar/prototype/year/basic.js deleted file mode 100644 index 1d03e3cd77d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/basic.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Basic tests for year(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 1994; -assert.sameValue(iso.year(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.year(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.year(Temporal.PlainYearMonth.from("1994-11")), res, "PlainYearMonth"); -assert.sameValue(iso.year({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.year("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.year({ month: 5 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/branding.js b/test/built-ins/Temporal/Calendar/prototype/year/branding.js deleted file mode 100644 index 6515d67d5a7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const year = Temporal.Calendar.prototype.year; - -assert.sameValue(typeof year, "function"); - -const args = [new Temporal.PlainDate(2000, 1, 1)]; - -assert.throws(TypeError, () => year.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => year.apply(null, args), "null"); -assert.throws(TypeError, () => year.apply(true, args), "true"); -assert.throws(TypeError, () => year.apply("", args), "empty string"); -assert.throws(TypeError, () => year.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => year.apply(1, args), "1"); -assert.throws(TypeError, () => year.apply({}, args), "plain object"); -assert.throws(TypeError, () => year.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => year.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/builtin.js b/test/built-ins/Temporal/Calendar/prototype/year/builtin.js deleted file mode 100644 index 29e854ef1b9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Tests that Temporal.Calendar.prototype.year - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.year), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.year), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.year), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.year.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/year/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 31549636a44..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.year({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/year/calendar-fields-iterable.js deleted file mode 100644 index 191ade08570..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/calendar-fields-iterable.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.year step 4: - 4. Return ? ISOYear(_dateOrDateTime_). - sec-temporal-isoyear step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.year({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/year/calendar-temporal-object.js deleted file mode 100644 index 25d1dd033a7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/calendar-temporal-object.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.dayofweek -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.year step 4: - 4. Return ? ISOYear(_dateOrDateTime_). - sec-temporal-isoyear step 1.a: - a. Set _dateOrDateTime_ to ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.year({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/date-time.js b/test/built-ins/Temporal/Calendar/prototype/year/date-time.js deleted file mode 100644 index d6dd30afe65..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/date-time.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Temporal.Calendar.prototype.year will take PlainDateTime and return - the value of the year. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return ! ISOYear(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let dateTime = new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13) -assert.sameValue(cal.year(dateTime), 1997, 'cal.year(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13)) must return 1997'); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/date.js b/test/built-ins/Temporal/Calendar/prototype/year/date.js deleted file mode 100644 index 857d22b3a89..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/date.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Temporal.Calendar.prototype.year will take PlainDate and return - the value of the year. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return ! ISOYear(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let date = new Temporal.PlainDate(2021, 7, 15); -assert.sameValue(cal.year(date), 2021, 'cal.year(new Temporal.PlainDate(2021, 7, 15)) must return 2021'); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/year/infinity-throws-rangeerror.js deleted file mode 100644 index 4a10ff281ef..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.year -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.year({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.year({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/length.js b/test/built-ins/Temporal/Calendar/prototype/year/length.js deleted file mode 100644 index 4135ce8f6a0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Temporal.Calendar.prototype.year.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.year, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/name.js b/test/built-ins/Temporal/Calendar/prototype/year/name.js deleted file mode 100644 index a04a30a552b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Temporal.Calendar.prototype.year.name is "year". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.year, "name", { - value: "year", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/year/not-a-constructor.js deleted file mode 100644 index bd02ea43db3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Temporal.Calendar.prototype.year does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.year(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.year), false, - "isConstructor(Temporal.Calendar.prototype.year)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/year/prop-desc.js deleted file mode 100644 index 67b9dc227da..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: The "year" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.year, - "function", - "`typeof Calendar.prototype.year` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "year", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/string.js b/test/built-ins/Temporal/Calendar/prototype/year/string.js deleted file mode 100644 index 43acaf0ab2d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/string.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Temporal.Calendar.prototype.year will take ISO8601 string and return - the value of the year. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return ! ISOYear(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.sameValue(cal.year("2019-03-15"), 2019, 'cal.year("2019-03-15") must return 2019'); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/throw-range-error-ToTemporalDate.js b/test/built-ins/Temporal/Calendar/prototype/year/throw-range-error-ToTemporalDate.js deleted file mode 100644 index 6231abe2662..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/throw-range-error-ToTemporalDate.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Temporal.Calendar.prototype.year throws RangeError on - ToTemporalDate when temporalDateLike is invalid string. -info: | - 4. If Type(temporalDateLike) is not Object or temporalDateLike - does not have an [[InitializedTemporalDate]] or - [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). -features: [Temporal, arrow-function] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => cal.year("invalid string"), - 'cal.year("invalid string") throws a RangeError exception'); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/year-month.js b/test/built-ins/Temporal/Calendar/prototype/year/year-month.js deleted file mode 100644 index 24f2f8c697c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/year-month.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: > - Temporal.Calendar.prototype.year will take PlainYearMonth and return - the value of the year. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then - a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). - 5. Return ! ISOYear(temporalDateLike). -features: [Temporal] ----*/ -let cal = new Temporal.Calendar("iso8601"); - -let yearMonth = new Temporal.PlainYearMonth(1999, 6); -assert.sameValue(cal.year(yearMonth), 1999, 'cal.year(new Temporal.PlainYearMonth(1999, 6)) must return 1999'); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/year/year-zero.js deleted file mode 100644 index dc7f72566ae..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/year/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.year -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.year(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/basic.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/basic.js deleted file mode 100644 index 2624bc7b651..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/basic.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Temporal.Calendar.prototype.yearMonthFromFields return correctly with valid data. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISOYearMonthFromFields(fields, options). - 7. Return ? CreateTemporalYearMonth(result.[[Year]], result.[[Month]], calendar, result.[[ReferenceISODay]]). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601") - -let result = cal.yearMonthFromFields({ year: 2021, month: 7 }); -TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "year 2021, month 7"); -result = cal.yearMonthFromFields({ year: 2021, month: 12 }); -TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "year 2021, month 12"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M07" }); -TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "year 2021, monthCode M07"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M12" }); -TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "year 2021, monthCode M12"); - -["constrain", "reject"].forEach((overflow) => { - const opt = { overflow }; - result = cal.yearMonthFromFields({ year: 2021, month: 7 }, opt); - TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", `year 2021, month 7, overflow ${overflow}`); - result = cal.yearMonthFromFields({ year: 2021, month: 12 }, opt); - TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", `year 2021, month 12, overflow ${overflow}`); - result = cal.yearMonthFromFields({ year: 2021, monthCode: "M07" }, opt); - TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", `year 2021, monthCode M07, overflow ${overflow}`); - result = cal.yearMonthFromFields({ year: 2021, monthCode: "M12" }, opt); - TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", `year 2021, monthCode M12, overflow ${overflow}`); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/branding.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/branding.js deleted file mode 100644 index 8fdd4c91bb6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const yearMonthFromFields = Temporal.Calendar.prototype.yearMonthFromFields; - -assert.sameValue(typeof yearMonthFromFields, "function"); - -const args = [{ year: 2021, month: 1 }]; - -assert.throws(TypeError, () => yearMonthFromFields.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => yearMonthFromFields.apply(null, args), "null"); -assert.throws(TypeError, () => yearMonthFromFields.apply(true, args), "true"); -assert.throws(TypeError, () => yearMonthFromFields.apply("", args), "empty string"); -assert.throws(TypeError, () => yearMonthFromFields.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => yearMonthFromFields.apply(1, args), "1"); -assert.throws(TypeError, () => yearMonthFromFields.apply({}, args), "plain object"); -assert.throws(TypeError, () => yearMonthFromFields.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => yearMonthFromFields.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/builtin.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/builtin.js deleted file mode 100644 index 1e13c4bf666..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: > - Tests that Temporal.Calendar.prototype.yearMonthFromFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.yearMonthFromFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.yearMonthFromFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.yearMonthFromFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.yearMonthFromFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/fields-missing-properties.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/fields-missing-properties.js deleted file mode 100644 index c63d8f39e6c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/fields-missing-properties.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Temporal.Calendar.prototype.yearMonthFromFields will throw TypeError with incorrect input data type. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISOYearMonthFromFields(fields, options). - 7. Return ? CreateTemporalYearMonth(result.[[Year]], result.[[Month]], calendar, result.[[ReferenceISODay]]). -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601") - -assert.throws(TypeError, () => cal.yearMonthFromFields({}), "at least one correctly spelled property is required"); -assert.throws(TypeError, () => cal.yearMonthFromFields({ month: 1 }), "year is required"); -assert.throws(TypeError, () => cal.yearMonthFromFields({ year: 2021 }), "month or monthCode is required"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/fields-not-object.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/fields-not-object.js deleted file mode 100644 index e04972b2dde..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/fields-not-object.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Throw a TypeError if the fields is not an object -features: [Symbol, Temporal] ----*/ - -const tests = [undefined, null, true, false, "string", Symbol("sym"), Math.PI, Infinity, NaN, 42n]; -const iso = Temporal.Calendar.from("iso8601"); -for (const fields of tests) { - assert.throws(TypeError, () => iso.yearMonthFromFields(fields, {})); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/infinity-throws-rangeerror.js deleted file mode 100644 index 374fd7fec1f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/infinity-throws-rangeerror.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.yearmonthfromfields -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month"].forEach((prop) => { - ["constrain", "reject"].forEach((overflow) => { - assert.throws(RangeError, () => instance.yearMonthFromFields({ ...base, [prop]: inf }, { overflow }), `${prop} property cannot be ${inf} (overflow ${overflow}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.yearMonthFromFields({ ...base, [prop]: obj }, { overflow })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/length.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/length.js deleted file mode 100644 index d97ce84ca54..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Temporal.Calendar.prototype.yearMonthFromFields.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.yearMonthFromFields, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/missing-properties.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/missing-properties.js deleted file mode 100644 index d8fb8e2b9ed..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/missing-properties.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Errors due to missing properties on fields object are thrown in the correct order -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let getMonth = false; -let getMonthCode = false; -const missingYearAndMonth = { - get month() { - getMonth = true; - }, - get monthCode() { - getMonthCode = true; - }, -}; -assert.throws(TypeError, () => instance.yearMonthFromFields(missingYearAndMonth), "year should be checked after fetching but before resolving the month"); -assert(getMonth, "year is fetched after month"); -assert(getMonthCode, "year is fetched after monthCode"); - -assert.throws(TypeError, () => instance.yearMonthFromFields({ year: 2000 }), "month should be resolved last"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/monthcode-invalid.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/monthcode-invalid.js deleted file mode 100644 index 0b01bf85a75..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/monthcode-invalid.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Throw RangeError for an out-of-range, conflicting, or ill-formed monthCode -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISOYearMonthFromFields(fields, options). - 7. Return ? CreateTemporalYearMonth(result.[[Year]], result.[[Month]], calendar, result.[[ReferenceISODay]]). -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -["m1", "M1", "m01"].forEach((monthCode) => { - assert.throws(RangeError, () => cal.yearMonthFromFields({ year: 2021, monthCode }), - `monthCode '${monthCode}' is not well-formed`); -}); - -assert.throws(RangeError, () => cal.yearMonthFromFields({ year: 2021, month: 12, monthCode: "M11" }), - "monthCode and month conflict"); - -["M00", "M19", "M99", "M13"].forEach((monthCode) => { - assert.throws(RangeError, () => cal.yearMonthFromFields({ year: 2021, monthCode }), - `monthCode '${monthCode}' is not valid for year 2021`); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/name.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/name.js deleted file mode 100644 index 803572242c4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Temporal.Calendar.prototype.yearMonthFromFields.name is "yearMonthFromFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.yearMonthFromFields, "name", { - value: "yearMonthFromFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/not-a-constructor.js deleted file mode 100644 index 7b7646f4c0d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: > - Temporal.Calendar.prototype.yearMonthFromFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.yearMonthFromFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.yearMonthFromFields), false, - "isConstructor(Temporal.Calendar.prototype.yearMonthFromFields)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/one-of-era-erayear-undefined.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/one-of-era-erayear-undefined.js deleted file mode 100644 index 9cb06acd19c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/one-of-era-erayear-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearMonthFromFields -description: Does not throw a RangeError if only one of era/eraYear fields is present -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const base = { year: 2000, month: 5, day: 2, era: 'ce' }; -const instance = new Temporal.Calendar('iso8601'); -TemporalHelpers.assertPlainYearMonth(instance.yearMonthFromFields({ ...base }), 2000, 5, 'M05'); - -const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 }; -TemporalHelpers.assertPlainYearMonth(instance.yearMonthFromFields({ ...base }), 2000, 5, 'M05'); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-not-object.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-not-object.js deleted file mode 100644 index 0246e70bbcc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-not-object.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Throw a TypeError if options is not an object or undefined -info: | - 5. Set options to ? GetOptionsObject(options). -features: [Symbol, Temporal] ----*/ - -const tests = [null, true, false, "string", Symbol("sym"), Math.PI, Infinity, NaN, 42n]; -const iso = new Temporal.Calendar("iso8601"); -for (const options of tests) { - assert.throws(TypeError, () => iso.yearMonthFromFields({ year: 2021, month: 7 }, options), - "options is not object"); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-object.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-object.js deleted file mode 100644 index 3895a59b4cc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-object.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Empty or a function object may be used as options -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const result1 = instance.yearMonthFromFields({ year: 2000, monthCode: "M05" }, {}); -TemporalHelpers.assertPlainYearMonth( - result1, 2000, 5, "M05", - "options may be an empty plain object" -); - -const result2 = instance.yearMonthFromFields({ year: 2000, monthCode: "M05" }, () => {}); -TemporalHelpers.assertPlainYearMonth( - result2, 2000, 5, "M05", - "options may be a function object" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-wrong-type.js deleted file mode 100644 index 625fcec62a5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/options-wrong-type.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: TypeError thrown when options argument is a primitive -features: [BigInt, Symbol, Temporal] ----*/ - -const badOptions = [ - null, - true, - "some string", - Symbol(), - 1, - 2n, -]; - -const instance = new Temporal.Calendar("iso8601"); -for (const value of badOptions) { - assert.throws(TypeError, () => instance.yearMonthFromFields({ year: 2000, monthCode: "M05" }, value), - `TypeError on wrong options type ${typeof value}`); -}; diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/order-of-operations.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/order-of-operations.js deleted file mode 100644 index 49a21495518..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/order-of-operations.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Properties on objects passed to yearMonthFromFields() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get fields.month", - "get fields.month.valueOf", - "call fields.month.valueOf", - "get fields.monthCode", - "get fields.monthCode.toString", - "call fields.monthCode.toString", - "get fields.year", - "get fields.year.valueOf", - "call fields.year.valueOf", - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; -const actual = []; - -const instance = new Temporal.Calendar("iso8601"); - -const fields = TemporalHelpers.propertyBagObserver(actual, { - year: 1.7, - month: 1.7, - monthCode: "M01", -}, "fields"); - -const options = TemporalHelpers.propertyBagObserver(actual, { - overflow: "reject", -}, "options"); - -const result = instance.yearMonthFromFields(fields, options); -TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01", "yearMonth result"); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot should store a string"); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-constrain.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-constrain.js deleted file mode 100644 index 6384d42a285..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-constrain.js +++ /dev/null @@ -1,91 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Temporal.Calendar.prototype.yearMonthFromFields will return correctly with data and overflow set to 'constrain'. -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISOYearMonthFromFields(fields, options). - 7. Return ? CreateTemporalYearMonth(result.[[Year]], result.[[Month]], calendar, result.[[ReferenceISODay]]). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601") -const opt = { overflow: "constrain" }; - -let result = cal.yearMonthFromFields({ year: 2021, month: 1 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 1, "M01", "month 1 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 2 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 2, "M02", "month 2 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 3 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 3, "M03", "month 3 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 4 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 4, "M04", "month 4 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 5 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 5, "M05", "month 5 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 6 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 6, "M06", "month 6 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 7 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "month 7 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 8 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 8, "M08", "month 8 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 9 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 9, "M09", "month 9 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 10 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 10, "M10", "month 10 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 11 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 11, "M11", "month 11 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, month: 12 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "month 12 with overflow constrain"); - -assert.throws( - RangeError, - () => cal.yearMonthFromFields({ year: 2021, month: -99999 }, opt), - "negative month -99999 is out of range even with overflow constrain" -) -assert.throws( - RangeError, - () => cal.yearMonthFromFields({ year: 2021, month: -1 }, opt), - "negative month -1 is out of range even with overflow constrain" -) -assert.throws( - RangeError, - () => cal.yearMonthFromFields({ year: 2021, month: 0 }, opt), - "month zero is out of range even with overflow constrain" -) - -result = cal.yearMonthFromFields({ year: 2021, month: 13 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "month 13 is constrained to 12"); -result = cal.yearMonthFromFields({ year: 2021, month: 99999 }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "month 99999 is constrained to 12"); - -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M01" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 1, "M01", "monthCode M01 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M02" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 2, "M02", "monthCode M02 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M03" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 3, "M03", "monthCode M03 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M04" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 4, "M04", "monthCode M04 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M05" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 5, "M05", "monthCode M05 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M06" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 6, "M06", "monthCode M06 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M07" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "monthCode M07 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M08" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 8, "M08", "monthCode M08 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M09" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 9, "M09", "monthCode M09 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M10" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 10, "M10", "monthCode M10 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M11" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 11, "M11", "monthCode M11 with overflow constrain"); -result = cal.yearMonthFromFields({ year: 2021, monthCode: "M12" }, opt); -TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "monthCode M12 with overflow constrain"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-invalid-string.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-invalid-string.js deleted file mode 100644 index 77c14141097..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-invalid-string.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: RangeError thrown when overflow option not one of the allowed string values -info: | - sec-getoption step 10: - 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal-isoyearmonthfromfields step 2: - 2. Let _overflow_ be ? ToTemporalOverflow(_options_). - sec-temporal.calendar.prototype.yearmonthfromfields step 6: - 6. Let _result_ be ? ISOYearMonthFromFields(_fields_, _options_). -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const badOverflows = ["", "CONSTRAIN", "balance", "other string", "constra\u0131n", "reject\0"]; -for (const overflow of badOverflows) { - assert.throws( - RangeError, - () => calendar.yearMonthFromFields({ year: 2000, month: 5 }, { overflow }), - `invalid overflow ("${overflow}")` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-reject.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-reject.js deleted file mode 100644 index d0d475d9e7b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-reject.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Throw RangeError for input data out of range with overflow reject -info: | - 1. Let calendar be the this value. - 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). - 3. Assert: calendar.[[Identifier]] is "iso8601". - 4. If Type(fields) is not Object, throw a TypeError exception. - 5. Set options to ? GetOptionsObject(options). - 6. Let result be ? ISOYearMonthFromFields(fields, options). - 7. Return ? CreateTemporalYearMonth(result.[[Year]], result.[[Month]], calendar, result.[[ReferenceISODay]]). -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -[-1, 0, 13, 9995].forEach((month) => { - assert.throws( - RangeError, - () => cal.yearMonthFromFields({year: 2021, month, day: 5}, { overflow: "reject" }), - `Month ${month} is out of range for 2021 with overflow: reject` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-undefined.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-undefined.js deleted file mode 100644 index 1f89b28aa47..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-undefined.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Fallback value for overflow option -info: | - sec-getoption step 3: - 3. If _value_ is *undefined*, return _fallback_. - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal-isoyearmonthfromfields step 2: - 2. Let _overflow_ be ? ToTemporalOverflow(_options_). - sec-temporal.calendar.prototype.yearmonthfromfields step 6: - 6. Let _result_ be ? ISOYearMonthFromFields(_fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); - -const explicit = calendar.yearMonthFromFields({ year: 2000, month: 15 }, { overflow: undefined }); -TemporalHelpers.assertPlainYearMonth(explicit, 2000, 12, "M12", "default overflow is constrain"); -const implicit = calendar.yearMonthFromFields({ year: 2000, month: 15 }, {}); -TemporalHelpers.assertPlainYearMonth(implicit, 2000, 12, "M12", "default overflow is constrain"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-wrong-type.js deleted file mode 100644 index 745b8cd7b2a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/overflow-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Type conversions for overflow option -info: | - sec-getoption step 9.a: - a. Set _value_ to ? ToString(_value_). - sec-temporal-totemporaloverflow step 1: - 1. Return ? GetOption(_normalizedOptions_, *"overflow"*, « String », « *"constrain"*, *"reject"* », *"constrain"*). - sec-temporal-isoyearmonthfromfields step 2: - 2. Let _overflow_ be ? ToTemporalOverflow(_options_). - sec-temporal.calendar.prototype.yearmonthfromfields step 6: - 6. Let _result_ be ? ISOYearMonthFromFields(_fields_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -TemporalHelpers.checkStringOptionWrongType("overflow", "constrain", - (overflow) => calendar.yearMonthFromFields({ year: 2000, month: 5 }, { overflow }), - (result, descr) => TemporalHelpers.assertPlainYearMonth(result, 2000, 5, "M05", descr), -); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/prop-desc.js deleted file mode 100644 index 3eedbcef62b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: The "yearMonthFromFields" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.yearMonthFromFields, - "function", - "`typeof Calendar.prototype.yearMonthFromFields` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "yearMonthFromFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/reference-day.js b/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/reference-day.js deleted file mode 100644 index 2d6fca72691..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearMonthFromFields/reference-day.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Reference ISO day is chosen to be the first of the calendar month -info: | - 6.d. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, *1*𝔽). - e. Let _result_ be ? CalendarDateToISO(_calendar_.[[Identifier]], _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -const result1 = cal.yearMonthFromFields({ year: 2023, monthCode: "M01", day: 13 }); -TemporalHelpers.assertPlainYearMonth( - result1, - 2023, 1, "M01", - "reference day is 1 even if day is given", - /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 -); - -const result2 = cal.yearMonthFromFields({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "constrain" }); -TemporalHelpers.assertPlainYearMonth( - result2, - 2021, 2, "M02", - "reference day is 1 even if day is out of range (overflow constrain)", - /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 -); - -const result3 = cal.yearMonthFromFields({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "reject" }); -TemporalHelpers.assertPlainYearMonth( - result3, - 2021, 2, "M02", - "reference day is 1 even if day is out of range (overflow reject)", - /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 -); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 12d789751ca..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.yearOfWeek(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index d67a6248eb7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.yearOfWeek(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-constructor-in-calendar-fields.js deleted file mode 100644 index f4003679520..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.yearOfWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-duplicate-calendar-fields.js deleted file mode 100644 index 1c2b345ac79..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.yearOfWeek(arg)); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-leap-second.js deleted file mode 100644 index 762f4f4b7ef..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.yearOfWeek(arg); -assert.sameValue( - result1, - 2016, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.yearOfWeek(arg); -assert.sameValue( - result2, - 2016, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-number.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-number.js deleted file mode 100644 index ae2823d1a54..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.yearOfWeek(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 1cd2b10757f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.yearOfWeek(arg); -assert.sameValue(result, 1976, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index bd8661a00f5..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.yearOfWeek(arg); - assert.sameValue(result, 1976, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 5a2044e8f9b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.yearOfWeek(arg); -assert.sameValue( - result, - 1976, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-number.js deleted file mode 100644 index d833eaaf7c4..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.yearOfWeek(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-string.js deleted file mode 100644 index bf85edd3ab2..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.yearOfWeek(arg); -assert.sameValue(result, 1976, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 04d7a210cbc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.yearOfWeek(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.yearOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index b142817d28c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.yearOfWeek(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-proto-in-calendar-fields.js deleted file mode 100644 index 48a03876cd7..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.yearOfWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index b379ca83736..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.yearOfWeek(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-calendar-annotation.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-calendar-annotation.js deleted file mode 100644 index ec348378430..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.yearOfWeek(arg); - - assert.sameValue( - result, - 2000, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 41d6e9944e3..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.yearOfWeek(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-date-with-utc-offset.js deleted file mode 100644 index 34e6935613b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.yearOfWeek(arg); - - assert.sameValue( - result, - 2000, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.yearOfWeek(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-invalid.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-invalid.js deleted file mode 100644 index 63655935dbf..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.yearOfWeek(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-multiple-calendar.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-multiple-calendar.js deleted file mode 100644 index 364a43c6d0a..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.yearOfWeek(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-multiple-time-zone.js deleted file mode 100644 index 13e9ab2efb0..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.yearOfWeek(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-time-separators.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-time-separators.js deleted file mode 100644 index 0157f0409e9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.yearOfWeek(arg); - - assert.sameValue( - result, - 2000, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-time-zone-annotation.js deleted file mode 100644 index 0349b0f5695..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.yearOfWeek(arg); - - assert.sameValue( - result, - 2000, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-unknown-annotation.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-unknown-annotation.js deleted file mode 100644 index eca37cb6190..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.yearOfWeek(arg); - - assert.sameValue( - result, - 2000, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-with-utc-designator.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-with-utc-designator.js deleted file mode 100644 index 515475e9690..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.yearOfWeek(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string.js deleted file mode 100644 index 2d5f3c8b6cd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-string.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Temporal.Calendar.prototype.yearOfWeek will take an ISO 8601 date string and - return the ISO week calendar year of that date. -features: [Temporal] ----*/ - -const cal = new Temporal.Calendar("iso8601"); - -// The following week calendar years are taken from the table "Examples of -// contemporary dates around New Year's Day" from -// https://en.wikipedia.org/wiki/ISO_week_date#Relation_with_the_Gregorian_calendar - -assert.sameValue(cal.yearOfWeek("1977-01-01"), 1976, "1977-01-01 is in yearOfWeek 1976"); -assert.sameValue(cal.yearOfWeek("1977-01-02"), 1976, "1977-01-02 is in yearOfWeek 1976"); -assert.sameValue(cal.yearOfWeek("1977-12-31"), 1977, "1977-12-31 is in yearOfWeek 1977"); -assert.sameValue(cal.yearOfWeek("1978-01-01"), 1977, "1978-01-01 is in yearOfWeek 1977"); -assert.sameValue(cal.yearOfWeek("1978-01-02"), 1978, "1978-01-02 is in yearOfWeek 1978"); -assert.sameValue(cal.yearOfWeek("1978-12-31"), 1978, "1978-12-31 is in yearOfWeek 1978"); -assert.sameValue(cal.yearOfWeek("1979-01-01"), 1979, "1979-01-01 is in yearOfWeek 1979"); -assert.sameValue(cal.yearOfWeek("1979-12-30"), 1979, "1979-12-30 is in yearOfWeek 1979"); -assert.sameValue(cal.yearOfWeek("1979-12-31"), 1980, "1979-12-31 is in yearOfWeek 1980"); -assert.sameValue(cal.yearOfWeek("1980-01-01"), 1980, "1980-01-01 is in yearOfWeek 1980"); -assert.sameValue(cal.yearOfWeek("1980-12-28"), 1980, "1980-12-28 is in yearOfWeek 1980"); -assert.sameValue(cal.yearOfWeek("1980-12-29"), 1981, "1980-12-29 is in yearOfWeek 1981"); -assert.sameValue(cal.yearOfWeek("1980-12-30"), 1981, "1980-12-30 is in yearOfWeek 1981"); -assert.sameValue(cal.yearOfWeek("1980-12-31"), 1981, "1980-12-31 is in yearOfWeek 1981"); -assert.sameValue(cal.yearOfWeek("1981-01-01"), 1981, "1981-01-01 is in yearOfWeek 1981"); -assert.sameValue(cal.yearOfWeek("1981-12-31"), 1981, "1981-12-31 is in yearOfWeek 1981"); -assert.sameValue(cal.yearOfWeek("1982-01-01"), 1981, "1982-01-01 is in yearOfWeek 1981"); -assert.sameValue(cal.yearOfWeek("1982-01-02"), 1981, "1982-01-02 is in yearOfWeek 1981"); -assert.sameValue(cal.yearOfWeek("1982-01-03"), 1981, "1982-01-03 is in yearOfWeek 1981"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-wrong-type.js deleted file mode 100644 index 9181113b59d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.yearOfWeek(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.yearOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-convert.js deleted file mode 100644 index 1f6a4f70ed1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.yearOfWeek(arg)); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-slots.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-slots.js deleted file mode 100644 index eee4172af72..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.yearOfWeek(arg); -assert.compareArray(actual, []); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 363f1fcd1c6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.yearOfWeek(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 61e5cb52c4d..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.yearOfWeek(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index a8453dbd8e8..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.yearOfWeek(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 5a9e07dfcd9..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.yearOfWeek(datetime)); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/basic.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/basic.js deleted file mode 100644 index 536a99eb377..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/basic.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Basic tests for yearOfWeek(). -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -const res = 1994; -assert.sameValue(iso.yearOfWeek(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.yearOfWeek(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.yearOfWeek({ year: 1994, month: 11, day: 5 }), res, "property bag"); -assert.sameValue(iso.yearOfWeek("1994-11-05"), res, "string"); -assert.throws(TypeError, () => iso.yearOfWeek({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/branding.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/branding.js deleted file mode 100644 index 563fdef47ed..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const yearOfWeek = Temporal.Calendar.prototype.yearOfWeek; - -assert.sameValue(typeof yearOfWeek, "function"); - -const args = [new Temporal.PlainDate(2021, 7, 20)]; - -assert.throws(TypeError, () => yearOfWeek.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => yearOfWeek.apply(null, args), "null"); -assert.throws(TypeError, () => yearOfWeek.apply(true, args), "true"); -assert.throws(TypeError, () => yearOfWeek.apply("", args), "empty string"); -assert.throws(TypeError, () => yearOfWeek.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => yearOfWeek.apply(1, args), "1"); -assert.throws(TypeError, () => yearOfWeek.apply({}, args), "plain object"); -assert.throws(TypeError, () => yearOfWeek.apply(Temporal.Calendar, args), "Temporal.Calendar"); -assert.throws(TypeError, () => yearOfWeek.apply(Temporal.Calendar.prototype, args), "Temporal.Calendar.prototype"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/builtin.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/builtin.js deleted file mode 100644 index a9a38d31658..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Tests that Temporal.Calendar.prototype.yearOfWeek - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.yearOfWeek), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.yearOfWeek), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.yearOfWeek), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.yearOfWeek.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 667ce85a5bd..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.yearOfWeek({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/calendar-fields-iterable.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/calendar-fields-iterable.js deleted file mode 100644 index b1a82dbd049..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/calendar-fields-iterable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.calendar.prototype.yearofweek step 4: - 4. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToListOfType(_fieldsArray_, « String »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -calendar1.yearOfWeek({ year: 2000, month: 5, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/calendar-temporal-object.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/calendar-temporal-object.js deleted file mode 100644 index a906e9bd2cc..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.calendar.prototype.yearofweek step 4: - 4. Let _date_ be ? ToTemporalDate(_dateOrDateTime_). - sec-temporal-totemporaldate step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const calendar = new Temporal.Calendar("iso8601"); - calendar.yearOfWeek({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/cross-year.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/cross-year.js deleted file mode 100644 index 499660dd526..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/cross-year.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearOfWeek -description: yearOfWeek() where the result is different from the calendar year -features: [Temporal] ----*/ - -const iso = Temporal.Calendar.from("iso8601"); -assert.sameValue(iso.yearOfWeek(Temporal.PlainDate.from("2019-12-31")), 2020, "next year"); -assert.sameValue(iso.yearOfWeek(Temporal.PlainDate.from("2021-01-01")), 2020, "previous year"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/custom-calendar-weekofyear.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/custom-calendar-weekofyear.js deleted file mode 100644 index 0440497eb9b..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/custom-calendar-weekofyear.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Temporal.Calendar.prototype.yearOfWeek returns undefined for all - custom calendars where yearOfWeek() returns undefined. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearOfWeek() { - return undefined; - } -} - -const calendar = new CustomCalendar(); -const customCalendarDate = { month: 1, day: 1, year: 2024, calendar}; -assert.sameValue(calendar.yearOfWeek({...customCalendarDate}), undefined); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/infinity-throws-rangeerror.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/infinity-throws-rangeerror.js deleted file mode 100644 index a5dd132338e..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.yearofweek -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); -const base = { year: 2000, month: 5, day: 2 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day"].forEach((prop) => { - assert.throws(RangeError, () => instance.yearOfWeek({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.yearOfWeek({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/length.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/length.js deleted file mode 100644 index a50b2c2eeb1..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Temporal.Calendar.prototype.yearOfWeek.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.yearOfWeek, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/name.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/name.js deleted file mode 100644 index 779bf5a496f..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Temporal.Calendar.prototype.yearOfWeek.name is "yearOfWeek". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.yearOfWeek, "name", { - value: "yearOfWeek", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/not-a-constructor.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/not-a-constructor.js deleted file mode 100644 index 133a3bd7af6..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Temporal.Calendar.prototype.yearOfWeek does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.yearOfWeek(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.yearOfWeek), false, - "isConstructor(Temporal.Calendar.prototype.yearOfWeek)"); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/prop-desc.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/prop-desc.js deleted file mode 100644 index d0bb2aad442..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: The "yearOfWeek" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.yearOfWeek, - "function", - "`typeof Calendar.prototype.yearOfWeek` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "yearOfWeek", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/year-zero.js b/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/year-zero.js deleted file mode 100644 index 32cf9a9013c..00000000000 --- a/test/built-ins/Temporal/Calendar/prototype/yearOfWeek/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.yearOfWeek(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/Calendar/subclass.js b/test/built-ins/Temporal/Calendar/subclass.js deleted file mode 100644 index e127b01212e..00000000000 --- a/test/built-ins/Temporal/Calendar/subclass.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar -description: Test for Temporal.Calendar subclassing. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { -} - -const instance = new CustomCalendar("iso8601"); -assert.sameValue(instance.toString(), "iso8601"); -assert.sameValue(Object.getPrototypeOf(instance), CustomCalendar.prototype, "Instance of CustomCalendar"); -assert(instance instanceof CustomCalendar, "Instance of CustomCalendar"); -assert(instance instanceof Temporal.Calendar, "Instance of Temporal.Calendar"); diff --git a/test/built-ins/Temporal/Duration/compare/calendar-dateadd-called-with-options-undefined.js b/test/built-ins/Temporal/Duration/compare/calendar-dateadd-called-with-options-undefined.js deleted file mode 100644 index 6ce8be530db..00000000000 --- a/test/built-ins/Temporal/Duration/compare/calendar-dateadd-called-with-options-undefined.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: > - BuiltinTimeZoneGetInstantFor calls Calendar.dateAdd with undefined as the - options value -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddUndefinedOptions(); -const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9); -const relativeTo = new Temporal.ZonedDateTime(0n, timeZone, calendar); - -const duration1 = new Temporal.Duration(0, 0, 1); -const duration2 = new Temporal.Duration(0, 0, 1, 1); -Temporal.Duration.compare(duration1, duration2, { relativeTo }); -assert.sameValue(calendar.dateAddCallCount, 2); -// one call for each duration argument to add it to relativeTo diff --git a/test/built-ins/Temporal/Duration/compare/calendar-dateadd-called-with-plaindate-instance.js b/test/built-ins/Temporal/Duration/compare/calendar-dateadd-called-with-plaindate-instance.js deleted file mode 100644 index 9747810b3c8..00000000000 --- a/test/built-ins/Temporal/Duration/compare/calendar-dateadd-called-with-plaindate-instance.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: > - relativeTo parameters that are not ZonedDateTime or undefined, are always - converted to PlainDate for observable calendar calls -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddPlainDateInstance(); -const relativeTo = new Temporal.PlainDate(2000, 1, 1, calendar); -calendar.specificPlainDate = relativeTo; -Temporal.Duration.compare(new Temporal.Duration(1, 1, 1, 1), new Temporal.Duration(1, 1, 1), { relativeTo }); -assert(calendar.dateAddCallCount > 0, "assertions in calendar.dateAdd() should have been tested"); diff --git a/test/built-ins/Temporal/Duration/compare/calendar-fields-iterable.js b/test/built-ins/Temporal/Duration/compare/calendar-fields-iterable.js deleted file mode 100644 index 5beaa79ee93..00000000000 --- a/test/built-ins/Temporal/Duration/compare/calendar-fields-iterable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.duration.compare step 4: - 4. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). - sec-temporal-torelativetemporalobject step 4.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const duration1 = new Temporal.Duration(1); -const duration2 = new Temporal.Duration(0, 12); -Temporal.Duration.compare(duration1, duration2, { relativeTo: { year: 2000, month: 1, day: 1, calendar } }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Duration/compare/constructor-in-calendar-fields.js b/test/built-ins/Temporal/Duration/compare/constructor-in-calendar-fields.js deleted file mode 100644 index db3d5834e3e..00000000000 --- a/test/built-ins/Temporal/Duration/compare/constructor-in-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.compare -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; -const duration1 = new Temporal.Duration(1); -const duration2 = new Temporal.Duration(0, 12); - -assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo})); diff --git a/test/built-ins/Temporal/Duration/compare/duplicate-calendar-fields.js b/test/built-ins/Temporal/Duration/compare/duplicate-calendar-fields.js deleted file mode 100644 index 827376b0340..00000000000 --- a/test/built-ins/Temporal/Duration/compare/duplicate-calendar-fields.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.compare -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(0, 12); - - assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo})); -} diff --git a/test/built-ins/Temporal/Duration/compare/instances-identical.js b/test/built-ins/Temporal/Duration/compare/instances-identical.js index 70b6a068c6d..5fb04708a03 100644 --- a/test/built-ins/Temporal/Duration/compare/instances-identical.js +++ b/test/built-ins/Temporal/Duration/compare/instances-identical.js @@ -3,10 +3,7 @@ /*--- esid: sec-temporal.duration.compare -description: > - Shortcut return with no observable user code calls when two Temporal.Duration - have identical internal slots -includes: [temporalHelpers.js] +description: Return when two Temporal.Durations have identical internal slots features: [Temporal] ---*/ @@ -22,23 +19,9 @@ assert.sameValue( "relativeTo is not required if two distinct Duration instances are identical" ); -const calendar = TemporalHelpers.calendarThrowEverything(); -const relativeTo = new Temporal.PlainDate(2000, 1, 1, calendar); -assert.sameValue( - Temporal.Duration.compare(dateDuration1, dateDuration2, { relativeTo }), - 0, - "no calendar methods are called if two distinct Duration instances are identical" -); - const dateDuration3 = new Temporal.Duration(5, 5, 5, 5, 4, 65, 5, 5, 5, 5); assert.throws( RangeError, () => Temporal.Duration.compare(dateDuration1, dateDuration3), "relativeTo is required if two Duration instances are the same length but not identical" ); - -assert.throws( - Test262Error, - () => Temporal.Duration.compare(dateDuration1, dateDuration3, { relativeTo }), - "calendar methods are called if two Duration instances are the same length but not identical" -); diff --git a/test/built-ins/Temporal/Duration/compare/order-of-operations.js b/test/built-ins/Temporal/Duration/compare/order-of-operations.js index 1928bda4449..ada4887dd73 100644 --- a/test/built-ins/Temporal/Duration/compare/order-of-operations.js +++ b/test/built-ins/Temporal/Duration/compare/order-of-operations.js @@ -88,30 +88,6 @@ actual.splice(0); // clear const baseExpectedOpsWithRelativeTo = expected.concat([ // ToRelativeTemporalObject "get options.relativeTo.calendar", - "has options.relativeTo.calendar.dateAdd", - "has options.relativeTo.calendar.dateFromFields", - "has options.relativeTo.calendar.dateUntil", - "has options.relativeTo.calendar.day", - "has options.relativeTo.calendar.dayOfWeek", - "has options.relativeTo.calendar.dayOfYear", - "has options.relativeTo.calendar.daysInMonth", - "has options.relativeTo.calendar.daysInWeek", - "has options.relativeTo.calendar.daysInYear", - "has options.relativeTo.calendar.fields", - "has options.relativeTo.calendar.id", - "has options.relativeTo.calendar.inLeapYear", - "has options.relativeTo.calendar.mergeFields", - "has options.relativeTo.calendar.month", - "has options.relativeTo.calendar.monthCode", - "has options.relativeTo.calendar.monthDayFromFields", - "has options.relativeTo.calendar.monthsInYear", - "has options.relativeTo.calendar.weekOfYear", - "has options.relativeTo.calendar.year", - "has options.relativeTo.calendar.yearMonthFromFields", - "has options.relativeTo.calendar.yearOfWeek", - "get options.relativeTo.calendar.dateFromFields", - "get options.relativeTo.calendar.fields", - "call options.relativeTo.calendar.fields", "get options.relativeTo.day", "get options.relativeTo.day.valueOf", "call options.relativeTo.day.valueOf", @@ -136,9 +112,6 @@ const expectedOpsForPlainRelativeTo = baseExpectedOpsWithRelativeTo.concat([ "get options.relativeTo.year", "get options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf", - "call options.relativeTo.calendar.dateFromFields", - // lookup in Duration.compare - "get options.relativeTo.calendar.dateAdd", ]); const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { @@ -146,8 +119,8 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { month: 5, monthCode: "M05", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), -}, "options.relativeTo"); + calendar: "iso8601", +}, "options.relativeTo", ["calendar"]); function createOptionsObserver(relativeTo = undefined) { return TemporalHelpers.propertyBagObserver(actual, { relativeTo }, "options"); @@ -177,22 +150,6 @@ Temporal.Duration.compare( assert.compareArray(actual, expectedOpsForPlainRelativeTo, "order of operations with PlainDate relativeTo and no calendar units"); actual.splice(0); // clear -// code path through UnbalanceDurationRelative that balances higher units down -// to days: -const expectedOpsForPlainDayBalancing = expectedOpsForPlainRelativeTo.concat( - [ - "call options.relativeTo.calendar.dateAdd", // UnbalanceDateDurationRelative on 1st argument - "call options.relativeTo.calendar.dateAdd", // UnbalanceDateDurationRelative on 2nd argument - ] -); -Temporal.Duration.compare( - createDurationPropertyBagObserver("one", 1, 1, 1), - createDurationPropertyBagObserver("two", 1, 1, 1, 1), - createOptionsObserver(plainRelativeTo) -); -assert.compareArray(actual, expectedOpsForPlainDayBalancing, "order of operations with PlainDate relativeTo and calendar units"); -actual.splice(0); // clear - const expectedOpsForZonedRelativeTo = baseExpectedOpsWithRelativeTo.concat([ // ToRelativeTemporalObject, continued "get options.relativeTo.hour.valueOf", @@ -225,16 +182,6 @@ const expectedOpsForZonedRelativeTo = baseExpectedOpsWithRelativeTo.concat([ "get options.relativeTo.year", "get options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf", - "call options.relativeTo.calendar.dateFromFields", - "has options.relativeTo.timeZone.getOffsetNanosecondsFor", - "has options.relativeTo.timeZone.getPossibleInstantsFor", - "has options.relativeTo.timeZone.id", - "get options.relativeTo.timeZone.getOffsetNanosecondsFor", - "get options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // lookup in Duration.compare - "get options.relativeTo.calendar.dateAdd", ]); const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { @@ -249,9 +196,9 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "options.relativeTo.timeZone"), -}, "options.relativeTo"); + calendar: "iso8601", + timeZone: "UTC", +}, "options.relativeTo", ["calendar", "timeZone"]); // order of observable operations with zoned relativeTo and without calendar units except days Temporal.Duration.compare( @@ -261,13 +208,7 @@ Temporal.Duration.compare( ); assert.compareArray( actual, - expectedOpsForZonedRelativeTo.concat([ - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // AddDaysToZonedDateTime on first argument - "call options.relativeTo.timeZone.getPossibleInstantsFor", - // AddDaysToZonedDateTime on second argument - "call options.relativeTo.timeZone.getPossibleInstantsFor", - ]), + expectedOpsForZonedRelativeTo, "order of operations with ZonedDateTime relativeTo and no calendar units except days" ); actual.splice(0); // clear @@ -293,15 +234,7 @@ Temporal.Duration.compare( ); assert.compareArray( actual, - expectedOpsForZonedRelativeTo.concat([ - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // AddZonedDateTime on first argument - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - // AddZonedDateTime on second argument - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - ]), + expectedOpsForZonedRelativeTo, "order of operations with ZonedDateTime relativeTo and calendar units" ); actual.splice(0); // clear diff --git a/test/built-ins/Temporal/Duration/compare/proto-in-calendar-fields.js b/test/built-ins/Temporal/Duration/compare/proto-in-calendar-fields.js deleted file mode 100644 index 3f0c4634e6d..00000000000 --- a/test/built-ins/Temporal/Duration/compare/proto-in-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.compare -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; -const duration1 = new Temporal.Duration(1); -const duration2 = new Temporal.Duration(0, 12); - -assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo})); diff --git a/test/built-ins/Temporal/Duration/compare/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/Duration/compare/read-time-fields-before-datefromfields.js deleted file mode 100644 index b2b9f805e6d..00000000000 --- a/test/built-ins/Temporal/Duration/compare/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.duration.compare step 4: - 4. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). - sec-temporal-torelativetemporalobject step 4.g: - g. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInvalidGettersTime(); -const duration1 = new Temporal.Duration(1); -const duration2 = new Temporal.Duration(0, 12); -Temporal.Duration.compare(duration1, duration2, { relativeTo: { year: 2000, month: 1, day: 1, calendar } }); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-hour.js b/test/built-ins/Temporal/Duration/compare/relativeto-hour.js index 876d865cdf5..149885e1db8 100644 --- a/test/built-ins/Temporal/Duration/compare/relativeto-hour.js +++ b/test/built-ins/Temporal/Duration/compare/relativeto-hour.js @@ -4,7 +4,6 @@ /*--- esid: sec-temporal.duration.compare description: relativeTo with hours. -includes: [temporalHelpers.js] features: [Temporal] ---*/ @@ -23,19 +22,3 @@ assert.sameValue(Temporal.Duration.compare(oneDay, hours24, { relativeTo: "2019- assert.sameValue(Temporal.Duration.compare(oneDay, hours24, { relativeTo: { year: 2019, month: 11, day: 3 } }), 0, "casts relativeTo to PlainDate from object"); - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); -assert.sameValue( - Temporal.Duration.compare(oneDay, hours24, { relativeTo: new Temporal.ZonedDateTime(0n, timeZone) }), - 0, - 'relativeTo does not affect days if ZonedDateTime, and duration encompasses no DST change'); -assert.sameValue( - Temporal.Duration.compare(oneDay, hours24, { relativeTo: new Temporal.ZonedDateTime(972802800_000_000_000n, timeZone) }), - 1, - 'relativeTo does affect days if ZonedDateTime, and duration encompasses DST change'); -assert.sameValue( - Temporal.Duration.compare(oneDay, hours24, { - relativeTo: { year: 2000, month: 10, day: 29, timeZone } - }), - 1, - 'casts relativeTo to ZonedDateTime from object'); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-ambiguous-wall-clock-time.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-ambiguous-wall-clock-time.js deleted file mode 100644 index 7b7a2b438ee..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-ambiguous-wall-clock-time.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: > - Correct time zone calls are made when converting a ZonedDateTime-like - relativeTo property bag denoting an ambiguous wall-clock time -includes: [temporalHelpers.js, compareArray.js] -features: [Temporal] ----*/ - -const actual = []; - -const duration1 = new Temporal.Duration(0, 0, 0, 1); -const duration2 = new Temporal.Duration(0, 0, 0, 2); - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const dstTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone), - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone), -}); -const calendar = TemporalHelpers.calendarObserver(actual, "calendar"); - -let relativeTo = { year: 2000, month: 4, day: 2, hour: 2, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo}); - -const expected = [ - // GetTemporalCalendarSlotValueWithISODefault - "has calendar.dateAdd", - "has calendar.dateFromFields", - "has calendar.dateUntil", - "has calendar.day", - "has calendar.dayOfWeek", - "has calendar.dayOfYear", - "has calendar.daysInMonth", - "has calendar.daysInWeek", - "has calendar.daysInYear", - "has calendar.fields", - "has calendar.id", - "has calendar.inLeapYear", - "has calendar.mergeFields", - "has calendar.month", - "has calendar.monthCode", - "has calendar.monthDayFromFields", - "has calendar.monthsInYear", - "has calendar.weekOfYear", - "has calendar.year", - "has calendar.yearMonthFromFields", - "has calendar.yearOfWeek", - // lookup - "get calendar.dateFromFields", - "get calendar.fields", - // CalendarFields - "call calendar.fields", - // InterpretTemporalDateTimeFields - "call calendar.dateFromFields", - // ToTemporalTimeZoneSlotValue - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - // lookup - "get timeZone.getOffsetNanosecondsFor", - "get timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", -]; - -const expectedSpringForward = expected.concat([ - // DisambiguatePossibleInstants - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getPossibleInstantsFor", -]); -assert.compareArray( - actual.slice(0, expectedSpringForward.length), // ignore operations after ToRelativeTemporalObject - expectedSpringForward, - "order of operations converting property bag at skipped wall-clock time" -); -actual.splice(0); // clear - -relativeTo = { year: 2000, month: 10, day: 29, hour: 1, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo}); - -assert.compareArray( - actual.slice(0, expected.length), // ignore operations after ToRelativeTemporalObject - expected, - "order of operations converting property bag at repeated wall-clock time" -); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 278e8054a64..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: > - Calling the method with a relativeTo property bag with a builtin calendar - causes no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const timeZone = "UTC"; -const relativeTo = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, timeZone, calendar: "iso8601" }; -const duration1 = new Temporal.Duration(0, 0, 1); -const duration2 = new Temporal.Duration(0, 0, 0, 7); -Temporal.Duration.compare(duration1, duration2, { relativeTo }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-calendar-string.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-calendar-string.js deleted file mode 100644 index a5d0e671fd7..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-calendar-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: > - Builtin dateFromFields method is not observably called when the property bag - has a string-valued calendar property -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - -const relativeTo = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -Temporal.Duration.compare(new Temporal.Duration(), new Temporal.Duration(), { relativeTo }); - -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 3c983ae0caf..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.compare -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); -const relativeTo = { year: 2000, month: 5, day: 2, timeZone, calendar: nonBuiltinISOCalendar }; - -Temporal.Duration.compare(new Temporal.Duration(1), new Temporal.Duration(2), { relativeTo }); - -assert.sameValue(timeZone.calls, 6, "getPossibleInstantsFor should have been called 6 times"); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-invalid-offset-string.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-invalid-offset-string.js index c1dfe588e1d..42deeb54db5 100644 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-invalid-offset-string.js +++ b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-invalid-offset-string.js @@ -7,7 +7,6 @@ description: relativeTo property bag with offset property is rejected if offset features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); const d1 = new Temporal.Duration(0, 1, 0, 280); const d2 = new Temporal.Duration(0, 1, 0, 281); @@ -21,7 +20,7 @@ const badOffsets = [ 1000n, // must be a string ]; badOffsets.forEach((offset) => { - const relativeTo = { year: 2021, month: 10, day: 28, offset, timeZone }; + const relativeTo = { year: 2021, month: 10, day: 28, offset, timeZone: "UTC" }; assert.throws( typeof(offset) === 'string' ? RangeError : TypeError, () => Temporal.Duration.compare(d1, d2, { relativeTo }), diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-backward-offset-shift.js deleted file mode 100644 index 90639e19d9a..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.compare -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; -const duration1 = new Temporal.Duration(1); -const duration2 = new Temporal.Duration(2); - -assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo}), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-forward-offset-shift.js deleted file mode 100644 index a67d4936a36..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.compare -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; -const duration1 = new Temporal.Duration(1); -const duration2 = new Temporal.Duration(2); - -assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, {relativeTo: relativeTo}), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 4c87850b729..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(1, 1); - assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, { relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } })); -}); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index ffdd92f1834..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.compare -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => { - const timeZone = new Temporal.TimeZone("UTC"); - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(1, 1); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.Duration.compare(duration1, duration2, { relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 651ac2bcf3b..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(1, 1); - assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, { relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } })); -}); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index d9c89b348a2..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(1, 1); - assert.throws(TypeError, () => Temporal.Duration.compare(duration1, duration2, { relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } })); -}); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string-datetime.js index ba6be7a21a0..4b4d01fea5a 100644 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.duration.compare -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string.js index 99bd588523f..d1c71a5f9b0 100644 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.duration.compare description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - // The following are all valid strings so should not throw: ["UTC", "+01:00"].forEach((timeZone) => { Temporal.Duration.compare(new Temporal.Duration(1), new Temporal.Duration(), { relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-wrong-type.js b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-wrong-type.js index d2e0ad6c776..56448bbd697 100644 --- a/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-wrong-type.js +++ b/test/built-ins/Temporal/Duration/compare/relativeto-propertybag-timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.duration.compare description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -28,8 +28,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 7c514caaca2..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const relativeTo = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(1, 1); - assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, { relativeTo })); -}); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 6fcd928847d..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.compare -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => { - const timeZone = new Temporal.TimeZone("UTC"); - const relativeTo = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(1, 1); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.Duration.compare(duration1, duration2, { relativeTo }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 1b540bcbb26..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const relativeTo = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(1, 1); - assert.throws(RangeError, () => Temporal.Duration.compare(duration1, duration2, { relativeTo })); -}); diff --git a/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 20050493e0e..00000000000 --- a/test/built-ins/Temporal/Duration/compare/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const relativeTo = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(1, 1); - assert.throws(TypeError, () => Temporal.Duration.compare(duration1, duration2, { relativeTo })); -}); diff --git a/test/built-ins/Temporal/Duration/compare/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/Duration/compare/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index c07fefa6c65..00000000000 --- a/test/built-ins/Temporal/Duration/compare/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.compare -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.duration.compare steps 4–6: - 4. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). - 5. Let _shift1_ be ! CalculateOffsetShift(_relativeTo_, _one_.[[Years]], [...], _one_.[[Nanoseconds]]). - 6. Let _shift2_ be ! CalculateOffsetShift(_relativeTo_, _two_.[[Years]], [...], _two_.[[Nanoseconds]]). - sec-temporal-torelativetemporalobject step 6.d: - d. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], [...], _result_.[[Nanosecond]], _offsetNs_, _timeZone_, *"compatible"*, *"reject"*). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-calculateoffsetshift step 4: - 4. Let _after_ be ? AddZonedDateTime(_relativeTo_.[[Nanoseconds]], _relativeTo_.[[TimeZone]], _relativeTo_.[[Calendar]], _y_, [...], _ns_). - sec-temporal-addzoneddatetime step 8: - 8. Let _intermediateInstant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _intermediateDateTime_, *"compatible"*). - sec-temporal-builtintimezonegetinstantfor step 1: - 1. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "2000-01-01T00:00:00", // called once on the input relativeTo object - "2001-01-01T00:00:00", // called once on relativeTo plus the first operand - "2001-02-01T00:00:00", // called once on relativeTo plus the second operand -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const duration1 = new Temporal.Duration(1); - const duration2 = new Temporal.Duration(0, 13); - Temporal.Duration.compare(duration1, duration2, { relativeTo: { year: 2000, month: 1, day: 1, timeZone } }); -}, expected); diff --git a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-options-undefined.js b/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-options-undefined.js deleted file mode 100644 index e6f94b61979..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-options-undefined.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - BuiltinTimeZoneGetInstantFor calls Calendar.dateAdd with undefined as the - options value -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddUndefinedOptions(); -const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9); -const relativeTo = new Temporal.ZonedDateTime(0n, timeZone, calendar); - -// Rounding with smallestUnit a calendar unit. -// The calls come from these paths: -// Duration.round() -> -// AddZonedDateTime -> calendar.dateAdd() -// DifferenceZonedDateTimeWithRounding -> RoundRelativeDuration -> NudgeToCalendarUnit -> -// AddDateTime -> calendar.dateAdd() (2x) - -const instance = new Temporal.Duration(1, 1, 1, 1, 1); -instance.round({ smallestUnit: "weeks", relativeTo }); -assert.sameValue(calendar.dateAddCallCount, 3, "rounding with calendar smallestUnit"); - -// Rounding with smallestUnit days only. -// The calls come from these paths: -// Duration.round() -> -// AddZonedDateTime -> calendar.dateAdd() -// DifferenceZonedDateTimeWithRounding -> -// RoundDuration -> MoveRelativeZonedDateTime -> AddZonedDateTime -> calendar.dateAdd() -// BalanceDateDurationRelative -> calendar.dateAdd() - -calendar.dateAddCallCount = 0; - -instance.round({ smallestUnit: "days", relativeTo }); -assert.sameValue(calendar.dateAddCallCount, 3, "rounding with days smallestUnit"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-plaindate-instance.js b/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-plaindate-instance.js deleted file mode 100644 index af6b6539feb..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateadd-called-with-plaindate-instance.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - relativeTo parameters that are not ZonedDateTime or undefined, are always - converted to PlainDate for observable calendar calls -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddPlainDateInstance(); -const instance = new Temporal.Duration(1, 1, 1, 1); -const relativeTo = new Temporal.PlainDate(2000, 1, 1, calendar); -calendar.specificPlainDate = relativeTo; -instance.round({ largestUnit: "days", relativeTo }); -assert(calendar.dateAddCallCount > 0, "assertions in calendar.dateAdd() should have been tested"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index 5221df4af8d..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,94 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - The options object passed to calendar.dateUntil has a largestUnit property - with its value in the singular form -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -// Check with smallestUnit nanoseconds but roundingIncrement > 1; each call -// should result in one call to dateUntil() originating from -// AdjustRoundedDurationDays, with largestUnit equal to the largest unit in -// the duration higher than "day". -// Additionally one call in BalanceDateDurationRelative with the same -// largestUnit. -// Other calls have largestUnit: "day" so the difference is taken in ISO -// calendar space. - -const durations = [ - [1, 0, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999], - [0, 1, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999], - [0, 0, 1, 0, 0, 0, 0, 0, 0, 86399_999_999_999], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999], - [0, 0, 0, 0, 0, 0, 0, 0, 0, 86399_999_999_999], -].map((args) => new Temporal.Duration(...args)); - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit, index) => { - const duration = durations[index]; - const relativeTo = new Temporal.ZonedDateTime(0n, "UTC", calendar); - duration.round({ largestUnit, roundingIncrement: 2, roundingMode: 'ceil', relativeTo }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); - -// Check the path that converts months to years and vice versa in -// BalanceDurationRelative and UnbalanceDurationRelative. - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const duration = new Temporal.Duration(5, 60); - const relativeTo = new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 0, 0, 0, calendar); - duration.round({ largestUnit, relativeTo }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); - -// Check the paths that call dateUntil() in RoundDuration. These paths do not -// call dateUntil() in AdjustRoundedDurationDays. Note that there is no -// largestUnit: "month" call in BalanceDurationRelative, because the durations -// have rounded down to 0. - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const duration = new Temporal.Duration(0, 1, 0, 0, 1, 1, 1, 1, 1, 1); - const relativeTo = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - duration.round({ largestUnit, smallestUnit: largestUnit, relativeTo }); - }, { - years: ["year"], - months: ["month"], - weeks: ["week", "week"], - days: [] - } -); diff --git a/test/built-ins/Temporal/Duration/prototype/round/calendar-fields-iterable.js b/test/built-ins/Temporal/Duration/prototype/round/calendar-fields-iterable.js deleted file mode 100644 index 3703596d710..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/calendar-fields-iterable.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.duration.prototype.round step 19: - 19. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). - sec-temporal-torelativetemporalobject step 4.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const duration = new Temporal.Duration(1, 1, 1, 1, 1, 1, 1); -duration.round({ smallestUnit: 'months', relativeTo: { year: 2000, month: 1, day: 1, calendar } }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/constructor-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/round/constructor-in-calendar-fields.js deleted file mode 100644 index 8d528e96b2c..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.round -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; -const instance = new Temporal.Duration(1, 0, 0, 0, 24); - -assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/round/date-and-time-durations-opposite-signs.js b/test/built-ins/Temporal/Duration/prototype/round/date-and-time-durations-opposite-signs.js deleted file mode 100644 index 95c87a01f73..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/date-and-time-durations-opposite-signs.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.round -description: > - Rounding calculation can result in duration date and time components with - opposite signs -info: | - AdjustRoundedDurationDays ( years, months, weeks, days, norm, increment, unit, roundingMode, zonedRelativeTo, - calendarRec, timeZoneRec, precalculatedPlainDateTime ) - 11. Let _adjustedDateDuration_ be ? AddDuration(_years_, _months_, _weeks_, _days_, 0, 0, 0, 0, 0, 0, 0, 0, 0, - _direction_, 0, 0, 0, 0, 0, 0, *undefined*, _zonedRelativeTo_, _calendarRec_, _timeZoneRec_, - _precalculatedPlainDateTime_). - 12. Let _roundRecord_ be ! RoundDuration(0, 0, 0, 0, _oneDayLess_, _increment_, _unit_, _roundingMode_). - 13. Return ? CombineDateAndNormalizedTimeDuration(_adjustedDateDuration_, - _roundRecord_.[[NormalizedDuration]].[[NormalizedTime]]). -features: [Temporal] ----*/ - -// Based on a test case by André Bargull - -const calendar = new class extends Temporal.Calendar { - dateUntil(one, two, options) { - return super.dateUntil(one, two, options).negated(); - } -}("iso8601"); - -const relativeTo = new Temporal.ZonedDateTime(0n, "UTC", calendar); - -let d = new Temporal.Duration(1, 0, 0, 10, 25); - -assert.throws(RangeError, () => d.round({ - smallestUnit: "nanoseconds", - roundingIncrement: 5, - relativeTo, -})); diff --git a/test/built-ins/Temporal/Duration/prototype/round/dateuntil-field.js b/test/built-ins/Temporal/Duration/prototype/round/dateuntil-field.js deleted file mode 100644 index 39c2c2e9056..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/dateuntil-field.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - When consulting calendar.dateUntil() to balance or unbalance a duration, no - properties are accessed on the result Duration -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; - -class CalendarDateUntilObservable extends Temporal.Calendar { - dateUntil(...args) { - actual.push("call dateUntil"); - const returnValue = super.dateUntil(...args); - TemporalHelpers.observeProperty(actual, returnValue, "years", Infinity); - TemporalHelpers.observeProperty(actual, returnValue, "months", Infinity); - TemporalHelpers.observeProperty(actual, returnValue, "weeks", Infinity); - TemporalHelpers.observeProperty(actual, returnValue, "days", Infinity); - return returnValue; - } -} - -const calendar = new CalendarDateUntilObservable("iso8601"); -const relativeTo = new Temporal.PlainDate(2018, 10, 12, calendar); - -const expected = [ - "call dateUntil", // DifferencePlainDateTimeWithRounding -> DifferenceISODateTime -]; - -const years = new Temporal.Duration(2); -const result = years.round({ largestUnit: "months", relativeTo }); -TemporalHelpers.assertDuration(result, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, "result"); -assert.compareArray(actual, expected, "operations"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/dst-balancing-result.js b/test/built-ins/Temporal/Duration/prototype/round/dst-balancing-result.js deleted file mode 100644 index b0f97a02742..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/dst-balancing-result.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.round -description: > - Balancing the resulting duration takes the time zone's UTC offset shifts - into account -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -// Based on a test case by Adam Shaw -{ - const duration = new Temporal.Duration(1, 0, 0, 0, 24); - const relativeTo = new Temporal.ZonedDateTime( - 941184000_000_000_000n /* = 1999-10-29T08Z */, - timeZone); /* = 1999-10-29T00-08 in local time */ - - const result = duration.round({ largestUnit: "years", relativeTo }); - TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 24, 0, 0, 0, 0, 0, - "24 hours does not balance to 1 day in 25-hour day"); -} - -{ - const duration = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 24, 0, 0, 0, 0, /* ns = */ 5); - const relativeTo = new Temporal.ZonedDateTime( - 972802800_000_000_000n /* = 2000-10-29T07Z */, - timeZone); /* = 2000-10-29T00-07 in local time */ - - const result = duration.round({ - largestUnit: "days", - smallestUnit: "minutes", - roundingMode: "expand", - roundingIncrement: 30, - relativeTo - }); - TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 24, 30, 0, 0, 0, 0, - "24 hours does not balance after rounding to 1 day in 25-hour day"); -} diff --git a/test/built-ins/Temporal/Duration/prototype/round/dst-rounding-result.js b/test/built-ins/Temporal/Duration/prototype/round/dst-rounding-result.js deleted file mode 100644 index 589ea340c9e..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/dst-rounding-result.js +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.round -description: > - Rounding the resulting duration takes the time zone's UTC offset shifts - into account -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -// Based on a test case by Adam Shaw - -{ - // Date part of duration lands on skipped DST hour, causing disambiguation - const duration = new Temporal.Duration(0, 1, 0, 15, 11, 30); - const relativeTo = new Temporal.ZonedDateTime( - 950868000_000_000_000n /* = 2000-02-18T10Z */, - timeZone); /* = 2000-02-18T02-08 in local time */ - - TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", relativeTo }), - 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, - "1 month 15 days 12 hours should be exactly 1.5 months, which rounds up to 2 months"); - TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", roundingMode: 'halfTrunc', relativeTo }), - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - "1 month 15 days 12 hours should be exactly 1.5 months, which rounds down to 1 month"); -} - -{ - // Month-only part of duration lands on skipped DST hour - const duration = new Temporal.Duration(0, 1, 0, 15, 0, 30); - const relativeTo = new Temporal.ZonedDateTime( - 951991200_000_000_000n /* = 2000-03-02T10Z */, - timeZone); /* = 2000-03-02T02-08 in local time */ - - TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", relativeTo }), - 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, - "1 month 15 days 00:30 should be exactly 1.5 months, which rounds up to 2 months"); - TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", roundingMode: 'halfTrunc', relativeTo }), - 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, - "1 month 15 days 00:30 should be exactly 1.5 months, which rounds down to 1 month"); -} - -{ - // Day rounding - // DST spring-forward hour skipped at 2000-04-02T02:00 (23 hour day) - // 11.5 hours is 0.5 - const duration = new Temporal.Duration(0, 0, 0, 0, 11, 30); - const instant = timeZone.getPossibleInstantsFor(Temporal.PlainDateTime.from("2000-04-02T00:00:00"))[0]; - const relativeTo = instant.toZonedDateTimeISO(timeZone); - - TemporalHelpers.assertDuration( - duration.round({ relativeTo, smallestUnit: "days" }), - 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, - ); - - TemporalHelpers.assertDuration( - duration.round({ relativeTo, smallestUnit: "days", roundingMode: "halfTrunc" }), - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - ); -} diff --git a/test/built-ins/Temporal/Duration/prototype/round/duplicate-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/round/duplicate-calendar-fields.js deleted file mode 100644 index a7446eee495..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.round -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; - const instance = new Temporal.Duration(1, 0, 0, 0, 24); - - assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo })); -} diff --git a/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js b/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js index 47dfd67327b..8bfcb7393a8 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js +++ b/test/built-ins/Temporal/Duration/prototype/round/order-of-operations.js @@ -48,30 +48,6 @@ const expectedOpsForPlainRelativeTo = [ "call options.largestUnit.toString", "get options.relativeTo", "get options.relativeTo.calendar", - "has options.relativeTo.calendar.dateAdd", - "has options.relativeTo.calendar.dateFromFields", - "has options.relativeTo.calendar.dateUntil", - "has options.relativeTo.calendar.day", - "has options.relativeTo.calendar.dayOfWeek", - "has options.relativeTo.calendar.dayOfYear", - "has options.relativeTo.calendar.daysInMonth", - "has options.relativeTo.calendar.daysInWeek", - "has options.relativeTo.calendar.daysInYear", - "has options.relativeTo.calendar.fields", - "has options.relativeTo.calendar.id", - "has options.relativeTo.calendar.inLeapYear", - "has options.relativeTo.calendar.mergeFields", - "has options.relativeTo.calendar.month", - "has options.relativeTo.calendar.monthCode", - "has options.relativeTo.calendar.monthDayFromFields", - "has options.relativeTo.calendar.monthsInYear", - "has options.relativeTo.calendar.weekOfYear", - "has options.relativeTo.calendar.year", - "has options.relativeTo.calendar.yearMonthFromFields", - "has options.relativeTo.calendar.yearOfWeek", - "get options.relativeTo.calendar.dateFromFields", - "get options.relativeTo.calendar.fields", - "call options.relativeTo.calendar.fields", "get options.relativeTo.day", "get options.relativeTo.day.valueOf", "call options.relativeTo.day.valueOf", @@ -92,7 +68,6 @@ const expectedOpsForPlainRelativeTo = [ "get options.relativeTo.year", "get options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf", - "call options.relativeTo.calendar.dateFromFields", "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", @@ -102,9 +77,6 @@ const expectedOpsForPlainRelativeTo = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", - // lookup in Duration.p.round - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", ]; const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { @@ -112,143 +84,20 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { month: 5, monthCode: "M05", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), -}, "options.relativeTo"); + calendar: "iso8601", +}, "options.relativeTo", ["calendar"]); // basic order of observable operations, without rounding: instance.round(createOptionsObserver({ relativeTo: plainRelativeTo })); assert.compareArray(actual, expectedOpsForPlainRelativeTo, "order of operations for PlainDate relativeTo"); actual.splice(0); // clear -// code path through RoundDuration that rounds to the nearest year, with minimal calendar calls: -const expectedMinimalOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([ - // initial AddDate in Duration.p.round 39.c not called because no calendar units - "call options.relativeTo.calendar.dateUntil", // DifferencePlainDateTimeWithRounding → DifferenceISODateTime - "call options.relativeTo.calendar.dateAdd", -]); -const instanceMinimal = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 100); -instanceMinimal.round(createOptionsObserver({ smallestUnit: "years", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedMinimalOpsForYearRounding, "order of operations with years = 0 and smallestUnit = years"); -actual.splice(0); // clear - -// code path through Duration.prototype.round that rounds to the nearest year: -const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // 39.c - "call options.relativeTo.calendar.dateUntil", // DifferencePlainDateTimeWithRounding → DifferenceISODateTime - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", -]); -const instanceYears = new Temporal.Duration(1, 12, 0, 0, /* hours = */ 2400); -instanceYears.round(createOptionsObserver({ smallestUnit: "years", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); -actual.splice(0); // clear - -// code path through Duration.prototype.round that rounds to the nearest month: -const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // 39.c - "call options.relativeTo.calendar.dateUntil", // DifferencePlainDateTimeWithRounding → DifferenceISODateTime - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", -]); -const instance2 = new Temporal.Duration(1, 0, 0, 62); -instance2.round(createOptionsObserver({ largestUnit: "months", smallestUnit: "months", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with largestUnit = smallestUnit = months"); -actual.splice(0); // clear - -// code path through Duration.prototype.round that rounds to the nearest week: -const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // 39.c - "call options.relativeTo.calendar.dateUntil", // DifferencePlainDateTimeWithRounding → DifferenceISODateTime - // RoundRelativeDuration - "call options.relativeTo.calendar.dateUntil", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", -]); -const instance3 = new Temporal.Duration(1, 1, 0, 15); -instance3.round(createOptionsObserver({ largestUnit: "weeks", smallestUnit: "weeks", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with largestUnit = smallestUnit = weeks"); -actual.splice(0); // clear - -// code path through Duration.prototype.round that rounds to the nearest day: -const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // 39.c -]); -const instance4 = new Temporal.Duration(1, 1, 1) -instance4.round(createOptionsObserver({ largestUnit: "days", smallestUnit: "days", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForDayRounding, "order of operations with largestUnit = smallestUnit = days"); -actual.splice(0); // clear - -// code path through BalanceDateDurationRelative balancing from days up to years: -const expectedOpsForDayToYearBalancing = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateUntil", // DifferencePlainDateTimeWithRounding → DifferenceISODateTime - "call options.relativeTo.calendar.dateAdd", -]); -const instance5 = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 396 * 24); -instance5.round(createOptionsObserver({ largestUnit: "years", smallestUnit: "days", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForDayToYearBalancing, "order of operations with largestUnit = years, smallestUnit = days"); -actual.splice(0); // clear - -// code path through Duration.prototype.round balancing from months up to years: -const expectedOpsForMonthToYearBalancing = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // 39.c - "call options.relativeTo.calendar.dateUntil", // DifferencePlainDateTimeWithRounding → DifferenceISODateTime - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", -]); -const instance6 = new Temporal.Duration(0, 12); -instance6.round(createOptionsObserver({ largestUnit: "years", smallestUnit: "months", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForMonthToYearBalancing, "order of operations with largestUnit = years, smallestUnit = months"); -actual.splice(0); // clear - -const expectedOpsForDayToMonthBalancing = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateUntil", // DifferencePlainDateTimeWithRounding → DifferenceISODateTime -]); -const instance7 = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 32 * 24); -instance7.round(createOptionsObserver({ largestUnit: "months", smallestUnit: "days", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForDayToMonthBalancing, "order of operations with largestUnit = months, smallestUnit = days"); -actual.splice(0); // clear - -const expectedOpsForDayToWeekBalancing = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateUntil", // DifferencePlainDateTimeWithRounding → DifferenceISODateTime -]); -const instance8 = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 8 * 24); -instance8.round(createOptionsObserver({ largestUnit: "weeks", smallestUnit: "days", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForDayToWeekBalancing, "order of operations with largestUnit = weeks, smallestUnit = days"); -actual.splice(0); // clear - const expectedOpsForZonedRelativeTo = [ "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", "get options.relativeTo", "get options.relativeTo.calendar", - "has options.relativeTo.calendar.dateAdd", - "has options.relativeTo.calendar.dateFromFields", - "has options.relativeTo.calendar.dateUntil", - "has options.relativeTo.calendar.day", - "has options.relativeTo.calendar.dayOfWeek", - "has options.relativeTo.calendar.dayOfYear", - "has options.relativeTo.calendar.daysInMonth", - "has options.relativeTo.calendar.daysInWeek", - "has options.relativeTo.calendar.daysInYear", - "has options.relativeTo.calendar.fields", - "has options.relativeTo.calendar.id", - "has options.relativeTo.calendar.inLeapYear", - "has options.relativeTo.calendar.mergeFields", - "has options.relativeTo.calendar.month", - "has options.relativeTo.calendar.monthCode", - "has options.relativeTo.calendar.monthDayFromFields", - "has options.relativeTo.calendar.monthsInYear", - "has options.relativeTo.calendar.weekOfYear", - "has options.relativeTo.calendar.year", - "has options.relativeTo.calendar.yearMonthFromFields", - "has options.relativeTo.calendar.yearOfWeek", - "get options.relativeTo.calendar.dateFromFields", - "get options.relativeTo.calendar.fields", - "call options.relativeTo.calendar.fields", "get options.relativeTo.day", "get options.relativeTo.day.valueOf", "call options.relativeTo.day.valueOf", @@ -283,15 +132,6 @@ const expectedOpsForZonedRelativeTo = [ "get options.relativeTo.year", "get options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf", - "call options.relativeTo.calendar.dateFromFields", - "has options.relativeTo.timeZone.getOffsetNanosecondsFor", - "has options.relativeTo.timeZone.getPossibleInstantsFor", - "has options.relativeTo.timeZone.id", - "get options.relativeTo.timeZone.getOffsetNanosecondsFor", - "get options.relativeTo.timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", @@ -315,126 +155,11 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "options.relativeTo.timeZone"), -}, "options.relativeTo"); + calendar: "iso8601", + timeZone: "UTC", +}, "options.relativeTo", ["calendar", "timeZone"]); // basic order of operations with ZonedDateTime relativeTo: instance.round(createOptionsObserver({ relativeTo: zonedRelativeTo })); -assert.compareArray(actual, expectedOpsForZonedRelativeTo.concat([ - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", -]), "order of operations for ZonedDateTime relativeTo"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest year with minimal calendar operations: -const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ - // ToTemporalDate - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // lookup in Duration.p.round - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", - // DifferenceZonedDateTimeWithRounding → DifferenceZonedDateTime - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 5 - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 12.c - "call options.relativeTo.calendar.dateUntil", // 13.f - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getPossibleInstantsFor", -]); -instance.round(createOptionsObserver({ smallestUnit: "years", relativeTo: zonedRelativeTo })); -assert.compareArray( - actual, - expectedOpsForMinimalYearRoundingZoned, - "order of operations with years = 0, smallestUnit = years and ZonedDateTime relativeTo" -); -actual.splice(0); // clear - -// code path through Duration.p.round that rounds to the nearest year: -const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ - // ToTemporalDate - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // lookup in Duration.p.round - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", - // AddZonedDateTime - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - // DifferenceZonedDateTimeWithRounding → DifferenceZonedDateTime - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 5 - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 12.c - "call options.relativeTo.calendar.dateUntil", // 13.f - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getPossibleInstantsFor", -]); -instanceYears.round(createOptionsObserver({ smallestUnit: "years", relativeTo: zonedRelativeTo })); -assert.compareArray( - actual, - expectedOpsForYearRoundingZoned, - "order of operations with smallestUnit = years and ZonedDateTime relativeTo" -); -actual.splice(0); // clear - -// code path that hits the special weeks/years case in BalanceDateDurationRelative -const expectedOpsForYearsWeeksSpecialCase = expectedOpsForZonedRelativeTo.concat([ - // ToTemporalDate - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // lookup in Duration.p.round - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", - // No user code calls in UnbalanceDateDurationRelative - // RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor - // DifferenceZonedDateTimeWithRounding → DifferenceZonedDateTime - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 5 - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 12.c - "call options.relativeTo.calendar.dateUntil", // 13.f - // RoundRelativeDuration - "call options.relativeTo.calendar.dateUntil", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getPossibleInstantsFor", -]); -new Temporal.Duration(0, 1, 1).round(createOptionsObserver({ largestUnit: "years", smallestUnit: "weeks", relativeTo: zonedRelativeTo })); -assert.compareArray( - actual, - expectedOpsForYearsWeeksSpecialCase, - "order of operations with largestUnit = years, smallestUnit = weeks, and ZonedDateTime relativeTo" -); -actual.splice(0); // clear - -// code path that skips user code calls in BalanceDateDurationRelative due to -// special case for largestUnit months and smallestUnit weeks -const expectedOpsForMonthsWeeksSpecialCase = expectedOpsForZonedRelativeTo.concat([ - // ToTemporalDate - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // lookup in Duration.p.round - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", - // RoundDuration → MoveRelativeZonedDateTime → AddZonedDateTime - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor - // DifferenceZonedDateTimeWithRounding → DifferenceZonedDateTime - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 5 - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 12.c - "call options.relativeTo.calendar.dateUntil", // 13.f - // RoundRelativeDuration - "call options.relativeTo.calendar.dateUntil", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getPossibleInstantsFor", -]); -new Temporal.Duration(0, 1, 1).round(createOptionsObserver({ largestUnit: "months", smallestUnit: "weeks", relativeTo: zonedRelativeTo })); -assert.compareArray( - actual, - expectedOpsForMonthsWeeksSpecialCase, - "order of operations with largestUnit = months, smallestUnit = weeks, and ZonedDateTime relativeTo" -); +assert.compareArray(actual, expectedOpsForZonedRelativeTo, "order of operations for ZonedDateTime relativeTo"); actual.splice(0); // clear diff --git a/test/built-ins/Temporal/Duration/prototype/round/out-of-range-when-adjusting-rounded-days.js b/test/built-ins/Temporal/Duration/prototype/round/out-of-range-when-adjusting-rounded-days.js deleted file mode 100644 index e88abfd374d..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/out-of-range-when-adjusting-rounded-days.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - When adjusting the rounded days after rounding relative to a ZonedDateTime, - the duration may go out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -// Based on a test case by André Bargull - -const d = new Temporal.Duration(0, 0, 0, /* days = */ 1, 0, 0, /* s = */ Number.MAX_SAFE_INTEGER - 86400, 0, 0, /* ns = */ 999_999_999); - -const timeZone = new Temporal.TimeZone("UTC"); -TemporalHelpers.substituteMethod(timeZone, 'getPossibleInstantsFor', [ - TemporalHelpers.SUBSTITUTE_SKIP, - [new Temporal.Instant(1n)], -]); - -const relativeTo = new Temporal.ZonedDateTime(0n, timeZone); - -assert.throws(RangeError, () => d.round({ - largestUnit: 'nanoseconds', - roundingIncrement: 2, - relativeTo -})); diff --git a/test/built-ins/Temporal/Duration/prototype/round/proto-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/round/proto-in-calendar-fields.js deleted file mode 100644 index c7a1c3dc253..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.round -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; -const instance = new Temporal.Duration(1, 0, 0, 0, 24); - -assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/round/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/Duration/prototype/round/read-time-fields-before-datefromfields.js deleted file mode 100644 index e5c67cb3865..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.duration.prototype.round step 19: - 19. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). - sec-temporal-torelativetemporalobject step 4.g: - g. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInvalidGettersTime(); -const duration = new Temporal.Duration(1, 1, 1, 1, 1, 1, 1); -duration.round({ smallestUnit: 'months', relativeTo: { year: 2000, month: 1, day: 1, calendar } }); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-ambiguous-wall-clock-time.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-ambiguous-wall-clock-time.js deleted file mode 100644 index 28eec3d3921..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-ambiguous-wall-clock-time.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - Correct time zone calls are made when converting a ZonedDateTime-like - relativeTo property bag denoting an ambiguous wall-clock time -includes: [temporalHelpers.js, compareArray.js] -features: [Temporal] ----*/ - -const actual = []; - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const dstTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone), - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone), -}); -const calendar = TemporalHelpers.calendarObserver(actual, "calendar"); - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); - -let relativeTo = { year: 2000, month: 4, day: 2, hour: 2, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.round({ largestUnit: "years", relativeTo }); - -const expected = [ - // GetTemporalCalendarSlotValueWithISODefault - "has calendar.dateAdd", - "has calendar.dateFromFields", - "has calendar.dateUntil", - "has calendar.day", - "has calendar.dayOfWeek", - "has calendar.dayOfYear", - "has calendar.daysInMonth", - "has calendar.daysInWeek", - "has calendar.daysInYear", - "has calendar.fields", - "has calendar.id", - "has calendar.inLeapYear", - "has calendar.mergeFields", - "has calendar.month", - "has calendar.monthCode", - "has calendar.monthDayFromFields", - "has calendar.monthsInYear", - "has calendar.weekOfYear", - "has calendar.year", - "has calendar.yearMonthFromFields", - "has calendar.yearOfWeek", - // lookup - "get calendar.dateFromFields", - "get calendar.fields", - // CalendarFields - "call calendar.fields", - // InterpretTemporalDateTimeFields - "call calendar.dateFromFields", - // ToTemporalTimeZoneSlotValue - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - // lookup - "get timeZone.getOffsetNanosecondsFor", - "get timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", -]; - -const expectedSpringForward = expected.concat([ - // DisambiguatePossibleInstants - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getPossibleInstantsFor", -]); -assert.compareArray( - actual.slice(0, expectedSpringForward.length), // ignore operations after ToRelativeTemporalObject - expectedSpringForward, - "order of operations converting property bag at skipped wall-clock time" -); -actual.splice(0); // clear - -relativeTo = { year: 2000, month: 10, day: 29, hour: 1, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.round({ largestUnit: "years", relativeTo }); - -assert.compareArray( - actual.slice(0, expected.length), // ignore operations after ToRelativeTemporalObject - expected, - "order of operations converting property bag at repeated wall-clock time" -); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 59da2e57c57..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - Calling the method with a relativeTo property bag with a builtin calendar - causes no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const timeZone = "UTC"; -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -const relativeTo = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, timeZone, calendar: "iso8601" }; -instance.round({ largestUnit: "years", relativeTo }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index c1fbe47f8be..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -const relativeTo = { year: 2000, month: 5, day: 2, calendar }; -instance.round({ largestUnit: "years", relativeTo }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-string.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-string.js deleted file mode 100644 index 070e4ad7649..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-string.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - Builtin dateFromFields method is not observably called when the property bag - has a string-valued calendar property -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -const relativeTo = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.round({ largestUnit: "years", relativeTo }); - -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-wrong-type.js index ee0b727846d..ffd97063464 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.Duration(1, 0, 0, 0, 24); const primitiveTests = [ @@ -31,8 +31,7 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], + [{}, "object"], [Temporal.PlainDate, "Temporal.PlainDate, object"], [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], [Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"], diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 1ef0125cb28..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); -const relativeTo = { year: 2000, month: 5, day: 2, timeZone, calendar: nonBuiltinISOCalendar }; - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -instance.round({ largestUnit: "years", relativeTo }); - -assert.sameValue(timeZone.calls, 6, "getPossibleInstantsFor should have been called 6 times"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-invalid-offset-string.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-invalid-offset-string.js index 92729decd6a..ee038cd8b46 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-invalid-offset-string.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-invalid-offset-string.js @@ -7,7 +7,7 @@ description: relativeTo property bag with offset property is rejected if offset features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.Duration(1, 0, 0, 0, 24); const badOffsets = [ diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-backward-offset-shift.js deleted file mode 100644 index d6ab9ddbb80..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-forward-offset-shift.js deleted file mode 100644 index 4acceb03ae2..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index d9d531dd244..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - assert.throws(RangeError, () => duration.round({ smallestUnit: "seconds", relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index c83410b166f..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => duration.round({ smallestUnit: "seconds", relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index f4c610700dc..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - assert.throws(RangeError, () => duration.round({ smallestUnit: "seconds", relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 0e5ba948ba1..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - assert.throws(TypeError, () => duration.round({ smallestUnit: "seconds", relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string-datetime.js index 2507e1ac716..9e19c63dca6 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.duration.prototype.round -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string.js index 2061506da38..a279c3cdea7 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-string.js @@ -4,27 +4,9 @@ /*--- esid: sec-temporal.duration.prototype.round description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.Duration(1); // The following are all valid strings so should not throw: @@ -32,6 +14,3 @@ const instance = new Temporal.Duration(1); ["UTC", "+01:00"].forEach((timeZone) => { instance.round({ largestUnit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-wrong-type.js index 57490a501f6..01faba8a82e 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-wrong-type.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.duration.prototype.round description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-wrong-type.js index d4b7af3f679..22fc458dec2 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-wrong-type.js +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone('UTC'); +const timeZone = "UTC"; const instance = new Temporal.Duration(1, 0, 0, 0, 24); const primitiveTests = [ diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-convert.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-convert.js deleted file mode 100644 index 1113fd34e6b..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Duration(0, 0, 0, 365); - -assert.throws(Test262Error, () => instance.round({ relativeTo: arg, largestUnit: "years" })); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 35e0abbba7a..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => duration.round({ smallestUnit: "seconds", relativeTo: datetime })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 190f5f7fca3..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => duration.round({ smallestUnit: "seconds", relativeTo: datetime }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 668a81869bd..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => duration.round({ smallestUnit: "seconds", relativeTo: datetime })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index f6642348d36..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => duration.round({ smallestUnit: "seconds", relativeTo: datetime })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/round/rounding-is-noop.js b/test/built-ins/Temporal/Duration/prototype/round/rounding-is-noop.js index a87149badbe..94591004dd2 100644 --- a/test/built-ins/Temporal/Duration/prototype/round/rounding-is-noop.js +++ b/test/built-ins/Temporal/Duration/prototype/round/rounding-is-noop.js @@ -4,16 +4,13 @@ /*--- esid: sec-temporal.duration.prototype.round description: > - No calendar or time zone methods are called under circumstances where rounding - is a no-op + Circumstances where rounding is a no-op, return a new but equal duration includes: [temporalHelpers.js] features: [Temporal] ---*/ -const calendar = TemporalHelpers.calendarThrowEverything(); -const timeZone = TemporalHelpers.timeZoneThrowEverything(); -const plainRelativeTo = new Temporal.PlainDate(2000, 1, 1, calendar); -const zonedRelativeTo = new Temporal.ZonedDateTime(0n, timeZone, calendar); +const plainRelativeTo = new Temporal.PlainDate(2000, 1, 1, "iso8601"); +const zonedRelativeTo = new Temporal.ZonedDateTime(0n, "UTC", "iso8601"); const d = new Temporal.Duration(0, 0, 0, 0, 23, 59, 59, 999, 999, 997); @@ -38,49 +35,3 @@ for (const [duration, options, descr] of noopRoundingOperations) { assert.notSameValue(negResult, negDuration, "rounding result should be a new object (negative)"); TemporalHelpers.assertDurationsEqual(negResult, negDuration, `rounding should be a no-op with ${descr} (negative)`); } - -// These operations are not no-op rounding operations, but still should not call -// any calendar methods: -const roundingOperationsNotCallingCalendarMethods = [ - [d, { smallestUnit: "microseconds" }, "round to 1 µs"], - [d, { smallestUnit: "nanoseconds", roundingIncrement: 2 }, "round to 2 ns"], - [new Temporal.Duration(0, 0, 0, 0, 24), { largestUnit: "days" }, "upwards balancing requested"], - [d, { largestUnit: "minutes" }, "downwards balancing requested"], - [new Temporal.Duration(0, 0, 0, 0, 1, 120), { smallestUnit: "nanoseconds" }, "time units could overflow"], - [new Temporal.Duration(0, 0, 0, 1, 24), { smallestUnit: "nanoseconds" }, "hours-to-days conversion could occur"], -]; -for (const [duration, options, descr] of roundingOperationsNotCallingCalendarMethods) { - const result = duration.round(options); - let equal = true; - for (const prop of ['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds']) { - if (result[prop] !== duration[prop]) { - equal = false; - break; - } - } - assert(!equal, `round result ${result} should be different from ${duration} with ${descr}`); - - const negDuration = duration.negated(); - const negResult = negDuration.round(options); - equal = true; - for (const prop of ['years', 'months', 'weeks', 'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds']) { - if (negResult[prop] !== negDuration[prop]) { - equal = false; - break; - } - } - assert(!equal, `round result ${negResult} should be different from ${negDuration} with ${descr} (negative)`); -} - -// These operations should not be short-circuited because they have to call -// calendar methods: -const roundingOperationsCallingCalendarMethods = [ - [new Temporal.Duration(0, 0, 1), { smallestUnit: "nanoseconds", relativeTo: plainRelativeTo }, "calendar units present"], - [d, { largestUnit: "days", relativeTo: zonedRelativeTo }, "largestUnit days with zoned relativeTo"], - [new Temporal.Duration(0, 0, 0, 1), { smallestUnit: "nanoseconds", relativeTo: zonedRelativeTo }, "hours-to-days conversion could occur with zoned relativeTo"], -]; - -for (const [duration, options, descr] of roundingOperationsCallingCalendarMethods) { - assert.throws(Test262Error, () => duration.round(options), `rounding should not be a no-op with ${descr}`); - assert.throws(Test262Error, () => duration.negated().round(options), `rounding should not be a no-op with ${descr} (negative)`); -} diff --git a/test/built-ins/Temporal/Duration/prototype/round/throws-in-balance-duration-when-sign-mismatched-with-zoned-date-time.js b/test/built-ins/Temporal/Duration/prototype/round/throws-in-balance-duration-when-sign-mismatched-with-zoned-date-time.js deleted file mode 100644 index 40a83323fd7..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/throws-in-balance-duration-when-sign-mismatched-with-zoned-date-time.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - BalanceDuration throws when the duration signs don't match. -info: | - BalanceDuration ( days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds, - largestUnit [ , relativeTo ] ) - - ... - 4. If largestUnit is one of "year", "month", "week", or "day", then - a. Let result be ? NanosecondsToDays(nanoseconds, relativeTo). - b. Set days to result.[[Days]]. - c. Set nanoseconds to result.[[Nanoseconds]]. - ... - 15. Return ? CreateTimeDurationRecord(days, hours × sign, minutes × sign, seconds × sign, - milliseconds × sign, microseconds × sign, nanoseconds × sign). -features: [Temporal] ----*/ - -let duration = Temporal.Duration.from({ - hours: -(24 * 1), - nanoseconds: -1, -}); - -let tz = new class extends Temporal.TimeZone { - #getPossibleInstantsFor = 0; - - getPossibleInstantsFor(dt) { - this.#getPossibleInstantsFor++; - - if (this.#getPossibleInstantsFor === 1) { - return [new Temporal.Instant(-86400_000_000_000n - 2n)] - } - return super.getPossibleInstantsFor(dt); - } -}("UTC"); - -let zdt = new Temporal.ZonedDateTime(0n, tz, "iso8601"); - -let options = { - relativeTo: zdt, - largestUnit: "days", -}; - -assert.throws(RangeError, () => duration.round(options)); diff --git a/test/built-ins/Temporal/Duration/prototype/round/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/Duration/prototype/round/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index c88af71cebc..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.duration.prototype.round steps 19, 21, and 24: - 19. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). - 21. Let _roundResult_ be ? RoundDuration(_unbalanceResult_.[[Years]], [...], _unbalanceResult_.[[Days]], _duration_.[[Hours]], [...], _duration_.[[Nanoseconds]], _roundingIncrement_, _smallestUnit_, _roundingMode_, _relativeTo_). - 24. If _relativeTo_ has an [[InitializedTemporalZonedDateTime]] internal slot, then - a. Set _relativeTo_ to ? MoveRelativeZonedDateTime(_relativeTo_, _balanceResult_.[[Years]], _balanceResult_.[[Months]], _balanceResult_.[[Weeks]], 0). - sec-temporal-torelativetemporalobject step 6.d: - d. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], [...], _result_.[[Nanosecond]], _offsetNs_, _timeZone_, *"compatible"*, *"reject"*). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-roundduration step 5.c–d: - c. If _zonedRelativeTo_ is not *undefined*, then - i. Let _intermediate_ be ? MoveRelativeZonedDateTime(_zonedRelativeTo_, _years_, _months_, _weeks_, _days_). - d. Let _result_ be ? NanosecondsToDays(_nanoseconds_, _intermediate_). - sec-temporal-moverelativezoneddatetime step 1: - 1. Let _intermediateNs_ be ? AddZonedDateTime(_zonedDateTime_.[[Nanoseconds]], _zonedDateTime_.[[TimeZone]], _zonedDateTime_.[[Calendar]], _years_, _months_, _weeks_, _days_, 0, 0, 0, 0, 0, 0). - sec-temporal-nanosecondstodays step 13: - 13. Let _intermediateNs_ be ? AddZonedDateTime(_startNs_, _relativeTo_.[[TimeZone]], _relativeTo_.[[Calendar]], 0, 0, 0, _days_, 0, 0, 0, 0, 0, 0). - sec-temporal-addzoneddatetime step 8: - 8. Let _intermediateInstant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _intermediateDateTime_, *"compatible"*). - sec-temporal-builtintimezonegetinstantfor step 1: - 1. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "2000-01-01T00:00:00", // called once on the input relativeTo object - "2001-02-09T00:00:00", // called once adding the duration to relativeTo - "2001-02-09T00:00:00", // called once on relativeTo plus years, months, weeks, days from the receiver - "2001-02-01T00:00:00", // called to find the lower bound for months rounding - "2001-03-01T00:00:00", // called to find the upper bound for months rounding -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const duration = new Temporal.Duration(1, 1, 1, 1, 1, 1, 1); - duration.round({ smallestUnit: 'months', relativeTo: { year: 2000, month: 1, day: 1, timeZone } }); -}, expected); diff --git a/test/built-ins/Temporal/Duration/prototype/round/zero-day-length.js b/test/built-ins/Temporal/Duration/prototype/round/zero-day-length.js deleted file mode 100644 index ed7f281bca4..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/zero-day-length.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: A malicious time zone resulting a day length of zero is handled correctly -info: | - Based on a test by André Bargull. - - RoundDuration step 6: - d. Let _result_ be ? NanosecondsToDays(_nanoseconds_, _intermediate_). - e. Set _days_ to _days_ + _result_.[[Days]] + _result_.[[Nanoseconds]] / _result_.[[DayLength]]. - - NanosecondsToDays steps 19-23: - 19. If _days_ < 0 and _sign_ = 1, throw a *RangeError* exception. - 20. If _days_ > 0 and _sign_ = -1, throw a *RangeError* exception. - 21. If _nanoseconds_ < 0, then - a. Assert: sign is -1. - 22. If _nanoseconds_ > 0 and _sign_ = -1, throw a *RangeError* exception. - 23. Assert: The inequality abs(_nanoseconds_) < abs(_dayLengthNs_) holds. -features: [Temporal] ----*/ - -const instance = new Temporal.Duration(0, 0, 0, 0, -24, 0, 0, 0, 0, -1); - -const tz = new class extends Temporal.TimeZone { - #getPossibleInstantsForCalls = 0; - - getPossibleInstantsFor(dt) { - this.#getPossibleInstantsForCalls++; - - if (this.#getPossibleInstantsForCalls <= 2) { - return [new Temporal.Instant(-86400_000_000_000n - 2n)] - } - return super.getPossibleInstantsFor(dt); - } -}("UTC"); - -const relativeTo = new Temporal.ZonedDateTime(0n, tz, "iso8601"); -assert.throws(RangeError, () => instance.round({ relativeTo, smallestUnit: "days" })); diff --git a/test/built-ins/Temporal/Duration/prototype/round/zero-year-month-week-length.js b/test/built-ins/Temporal/Duration/prototype/round/zero-year-month-week-length.js deleted file mode 100644 index a9c4a1c3208..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/round/zero-year-month-week-length.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.round -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const instance = new Temporal.Duration(1, 0, 0, 0, 0, 0, 0, 0, 0, 1); -const relativeTo = new Temporal.ZonedDateTime(0n, "UTC", cal); - -assert.throws(RangeError, () => instance.round({ relativeTo, smallestUnit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => instance.round({ relativeTo, smallestUnit: "months" }), "zero month length handled correctly"); -assert.throws(RangeError, () => instance.round({ relativeTo, smallestUnit: "weeks" }), "zero week length handled correctly"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/calendar-dateadd-called-with-options-undefined.js b/test/built-ins/Temporal/Duration/prototype/total/calendar-dateadd-called-with-options-undefined.js deleted file mode 100644 index e5e173f65a2..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/calendar-dateadd-called-with-options-undefined.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - BuiltinTimeZoneGetInstantFor calls Calendar.dateAdd with undefined as the - options value -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddUndefinedOptions(); -const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9); -const relativeTo = new Temporal.ZonedDateTime(0n, timeZone, calendar); - -// Total of a calendar unit where larger calendar units have to be converted -// down, to cover the path that goes through UnbalanceDateDurationRelative -// The calls come from the path: -// Duration.total() -> AddZonedDateTime -> calendar.dateAdd() - -const instance1 = new Temporal.Duration(1, 1, 1, 1, 1); -instance1.total({ unit: "days", relativeTo }); -assert.sameValue(calendar.dateAddCallCount, 1, "converting larger calendar units down"); - -// Total of a calendar unit where smaller calendar units have to be converted -// up, to cover the path that goes through MoveRelativeZonedDateTime -// The calls come from these paths: -// Duration.total() -> -// AddZonedDateTime -> calendar.dateAdd() -// DifferenceZonedDateTimeWithRounding -> RoundRelativeDuration -> NudgeToCalendarUnit -> -// AddDateTime -> calendar.dateAdd() (2x) - -calendar.dateAddCallCount = 0; - -const instance2 = new Temporal.Duration(0, 0, 1, 1); -instance2.total({ unit: "weeks", relativeTo }); -assert.sameValue(calendar.dateAddCallCount, 3, "converting smaller calendar units up"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/calendar-dateadd-called-with-plaindate-instance.js b/test/built-ins/Temporal/Duration/prototype/total/calendar-dateadd-called-with-plaindate-instance.js deleted file mode 100644 index 00755d30687..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/calendar-dateadd-called-with-plaindate-instance.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - relativeTo parameters that are not ZonedDateTime or undefined, are always - converted to PlainDate for observable calendar calls -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddPlainDateInstance(); -const instance = new Temporal.Duration(1, 1, 1, 1); -const relativeTo = new Temporal.PlainDate(2000, 1, 1, calendar); -calendar.specificPlainDate = relativeTo; -instance.total({ unit: "days", relativeTo }); -assert(calendar.dateAddCallCount > 0, "assertions in calendar.dateAdd() should have been tested"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/Duration/prototype/total/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index 2c185bb6387..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - The options object passed to calendar.dateUntil has a largestUnit property - with its value in the singular form -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -// Check the paths that go through NanosecondsToDays: only one call in -// RoundDuration when the unit is a calendar unit. The others all -// have largestUnit: "day" so the difference is taken in ISO calendar space. - -const duration = new Temporal.Duration(0, 1, 1, 1, 1, 1, 1, 1, 1, 1); - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, unit) => { - const relativeTo = new Temporal.ZonedDateTime(0n, "UTC", calendar); - duration.total({ unit, relativeTo }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week", "week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); diff --git a/test/built-ins/Temporal/Duration/prototype/total/calendar-fields-iterable.js b/test/built-ins/Temporal/Duration/prototype/total/calendar-fields-iterable.js deleted file mode 100644 index 0bd730fca5a..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/calendar-fields-iterable.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.duration.prototype.total step 4: - 4. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). - sec-temporal-torelativetemporalobject step 4.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const duration = new Temporal.Duration(1, 1, 1, 1, 1, 1, 1); -duration.total({ unit: 'seconds', relativeTo: { year: 2000, month: 1, day: 1, calendar } }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/calendar-temporal-object.js b/test/built-ins/Temporal/Duration/prototype/total/calendar-temporal-object.js index 22b3939e177..4bb953ca5ac 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/calendar-temporal-object.js +++ b/test/built-ins/Temporal/Duration/prototype/total/calendar-temporal-object.js @@ -3,7 +3,9 @@ /*--- esid: sec-temporal.duration.prototype.total -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots +description: > + Fast path for converting other Temporal objects to calendar ID by reading + internal slots info: | sec-temporal.duration.prototype.total step 4: 4. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). diff --git a/test/built-ins/Temporal/Duration/prototype/total/constructor-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/total/constructor-in-calendar-fields.js deleted file mode 100644 index 1ee7fee5bc4..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.total -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; -const instance = new Temporal.Duration(1, 0, 0, 0, 24); - -assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/total/dateuntil-field.js b/test/built-ins/Temporal/Duration/prototype/total/dateuntil-field.js deleted file mode 100644 index 1e20152bbfe..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/dateuntil-field.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - When consulting calendar.dateUntil() to calculate the number of months in a - year, the months property is not accessed on the result Duration -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; - -class CalendarDateUntilObservable extends Temporal.Calendar { - dateUntil(...args) { - actual.push("call dateUntil"); - const returnValue = super.dateUntil(...args); - TemporalHelpers.observeProperty(actual, returnValue, "months", Infinity); - return returnValue; - } -} - -const calendar = new CalendarDateUntilObservable("iso8601"); -const relativeTo = new Temporal.PlainDate(2018, 10, 12, calendar); - -const expected = [ - "call dateUntil", -]; - -const years = new Temporal.Duration(2); -const result = years.total({ unit: "months", relativeTo }); -assert.sameValue(result, 24, "result"); -assert.compareArray(actual, expected, "operations"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/dst-balancing-result.js b/test/built-ins/Temporal/Duration/prototype/total/dst-balancing-result.js deleted file mode 100644 index 132c68589cc..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/dst-balancing-result.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.total -description: > - Balancing the resulting duration takes the time zone's UTC offset shifts - into account -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// Based on a test case by Adam Shaw - -const duration = new Temporal.Duration(1, 0, 0, 0, 24); -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const relativeTo = new Temporal.ZonedDateTime( - 941184000_000_000_000n /* = 1999-10-29T08Z */, - timeZone); /* = 1999-10-29T00-08 in local time */ - -const result = duration.total({ unit: "days", relativeTo }); -assert.sameValue(result, 366.96, "24 hours does not balance to 1 day in 25-hour day"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js b/test/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js deleted file mode 100644 index d0d8773a0aa..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/dst-rounding-result.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.total -description: > - Rounding the resulting duration takes the time zone's UTC offset shifts - into account -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -// Based on a test case by Adam Shaw - -{ - // Date part of duration lands on skipped DST hour, causing disambiguation - const duration = new Temporal.Duration(0, 1, 0, 15, 11, 30); - const relativeTo = new Temporal.ZonedDateTime( - 950868000_000_000_000n /* = 2000-02-18T10Z */, - timeZone); /* = 2000-02-18T02-08 in local time */ - - assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5, - "1 month 15 days 11:30 should be exactly 1.5 months"); -} - -{ - // Month-only part of duration lands on skipped DST hour, should not cause - // disambiguation - const duration = new Temporal.Duration(0, 1, 0, 15, 0, 30); - const relativeTo = new Temporal.ZonedDateTime( - 951991200_000_000_000n /* = 2000-03-02T10Z */, - timeZone); /* = 2000-03-02T02-08 in local time */ - - assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5, - "1 month 15 days 00:30 should be exactly 1.5 months"); -} diff --git a/test/built-ins/Temporal/Duration/prototype/total/duplicate-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/total/duplicate-calendar-fields.js deleted file mode 100644 index 94eaed07fdc..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.total -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; - const instance = new Temporal.Duration(1, 0, 0, 0, 24); - - assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo })); -} diff --git a/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js b/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js index f2393ee742f..dca60bca6a9 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js +++ b/test/built-ins/Temporal/Duration/prototype/total/order-of-operations.js @@ -36,30 +36,6 @@ const expectedOpsForPlainRelativeTo = [ // ToRelativeTemporalObject "get options.relativeTo", "get options.relativeTo.calendar", - "has options.relativeTo.calendar.dateAdd", - "has options.relativeTo.calendar.dateFromFields", - "has options.relativeTo.calendar.dateUntil", - "has options.relativeTo.calendar.day", - "has options.relativeTo.calendar.dayOfWeek", - "has options.relativeTo.calendar.dayOfYear", - "has options.relativeTo.calendar.daysInMonth", - "has options.relativeTo.calendar.daysInWeek", - "has options.relativeTo.calendar.daysInYear", - "has options.relativeTo.calendar.fields", - "has options.relativeTo.calendar.id", - "has options.relativeTo.calendar.inLeapYear", - "has options.relativeTo.calendar.mergeFields", - "has options.relativeTo.calendar.month", - "has options.relativeTo.calendar.monthCode", - "has options.relativeTo.calendar.monthDayFromFields", - "has options.relativeTo.calendar.monthsInYear", - "has options.relativeTo.calendar.weekOfYear", - "has options.relativeTo.calendar.year", - "has options.relativeTo.calendar.yearMonthFromFields", - "has options.relativeTo.calendar.yearOfWeek", - "get options.relativeTo.calendar.dateFromFields", - "get options.relativeTo.calendar.fields", - "call options.relativeTo.calendar.fields", "get options.relativeTo.day", "get options.relativeTo.day.valueOf", "call options.relativeTo.day.valueOf", @@ -80,14 +56,10 @@ const expectedOpsForPlainRelativeTo = [ "get options.relativeTo.year", "get options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf", - "call options.relativeTo.calendar.dateFromFields", // GetTemporalUnit "get options.unit", "get options.unit.toString", "call options.unit.toString", - // lookup in Duration.p.total - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", ]; const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { @@ -95,104 +67,18 @@ const plainRelativeTo = TemporalHelpers.propertyBagObserver(actual, { month: 5, monthCode: "M05", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), -}, "options.relativeTo"); + calendar: "iso8601", +}, "options.relativeTo", ["calendar"]); // basic order of observable operations, without rounding: instance.total(createOptionsObserver({ unit: "nanoseconds", relativeTo: plainRelativeTo })); assert.compareArray(actual, expectedOpsForPlainRelativeTo, "order of operations for PlainDate relativeTo"); actual.splice(0); // clear -// code path through RoundDuration that rounds to the nearest year with minimal calendar calls: -const expectedOpsForMinimalYearRounding = expectedOpsForPlainRelativeTo.concat([ - // DifferencePlainDateTimeWithRounding -> DifferenceISODateTime - "call options.relativeTo.calendar.dateUntil", - "call options.relativeTo.calendar.dateAdd", -]); -instance.total(createOptionsObserver({ unit: "years", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForMinimalYearRounding, "order of operations with years = 0 and unit = years"); -actual.splice(0); // clear - -// code path through Duration.p.total that rounds to the nearest year: -const expectedOpsForYearRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // Duration.p.total 19.c - // DifferencePlainDateTimeWithRounding - "call options.relativeTo.calendar.dateUntil", // 5 - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", -]); -const instanceYears = new Temporal.Duration(1, 12, 0, 0, /* hours = */ 2400); -instanceYears.total(createOptionsObserver({ unit: "years", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with unit = years"); -actual.splice(0); // clear - -// code path through Duration.prototype.total that rounds to the nearest month: -const expectedOpsForMonthRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // Duration.p.total 19.c - // DifferencePlainDateTimeWithRounding - "call options.relativeTo.calendar.dateUntil", // 5 - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", -]); -const instance2 = new Temporal.Duration(1, 0, 0, 62); -instance2.total(createOptionsObserver({ unit: "months", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with unit = months"); -actual.splice(0); // clear - -// code path through Duration.prototype.total that rounds to the nearest week: -const expectedOpsForWeekRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // Duration.p.total 19.c - // DifferencePlainDateTimeWithRounding - "call options.relativeTo.calendar.dateUntil", // 5 - // RoundRelativeDuration - "call options.relativeTo.calendar.dateUntil", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", -]); -const instance3 = new Temporal.Duration(1, 1, 0, 15); -instance3.total(createOptionsObserver({ unit: "weeks", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with unit = weeks"); -actual.splice(0); // clear - -// code path through UnbalanceDateDurationRelative that rounds to the nearest day: -const expectedOpsForDayRounding = expectedOpsForPlainRelativeTo.concat([ - "call options.relativeTo.calendar.dateAdd", // 10 -]); -const instance4 = new Temporal.Duration(1, 1, 1) -instance4.total(createOptionsObserver({ unit: "days", relativeTo: plainRelativeTo })); -assert.compareArray(actual, expectedOpsForDayRounding, "order of operations with unit = days"); -actual.splice(0); // clear - const expectedOpsForZonedRelativeTo = [ // ToRelativeTemporalObject "get options.relativeTo", "get options.relativeTo.calendar", - "has options.relativeTo.calendar.dateAdd", - "has options.relativeTo.calendar.dateFromFields", - "has options.relativeTo.calendar.dateUntil", - "has options.relativeTo.calendar.day", - "has options.relativeTo.calendar.dayOfWeek", - "has options.relativeTo.calendar.dayOfYear", - "has options.relativeTo.calendar.daysInMonth", - "has options.relativeTo.calendar.daysInWeek", - "has options.relativeTo.calendar.daysInYear", - "has options.relativeTo.calendar.fields", - "has options.relativeTo.calendar.id", - "has options.relativeTo.calendar.inLeapYear", - "has options.relativeTo.calendar.mergeFields", - "has options.relativeTo.calendar.month", - "has options.relativeTo.calendar.monthCode", - "has options.relativeTo.calendar.monthDayFromFields", - "has options.relativeTo.calendar.monthsInYear", - "has options.relativeTo.calendar.weekOfYear", - "has options.relativeTo.calendar.year", - "has options.relativeTo.calendar.yearMonthFromFields", - "has options.relativeTo.calendar.yearOfWeek", - "get options.relativeTo.calendar.dateFromFields", - "get options.relativeTo.calendar.fields", - "call options.relativeTo.calendar.fields", "get options.relativeTo.day", "get options.relativeTo.day.valueOf", "call options.relativeTo.day.valueOf", @@ -227,15 +113,6 @@ const expectedOpsForZonedRelativeTo = [ "get options.relativeTo.year", "get options.relativeTo.year.valueOf", "call options.relativeTo.year.valueOf", - "call options.relativeTo.calendar.dateFromFields", - "has options.relativeTo.timeZone.getOffsetNanosecondsFor", - "has options.relativeTo.timeZone.getPossibleInstantsFor", - "has options.relativeTo.timeZone.id", - "get options.relativeTo.timeZone.getOffsetNanosecondsFor", - "get options.relativeTo.timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // GetTemporalUnit "get options.unit", "get options.unit.toString", @@ -254,123 +131,11 @@ const zonedRelativeTo = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "options.relativeTo.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "options.relativeTo.timeZone"), -}, "options.relativeTo"); + calendar: "iso8601", + timeZone: "UTC", +}, "options.relativeTo", ["calendar", "timeZone"]); // basic order of observable operations, without rounding: instance.total(createOptionsObserver({ unit: "nanoseconds", relativeTo: zonedRelativeTo })); -assert.compareArray(actual, expectedOpsForZonedRelativeTo.concat([ - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", -]), "order of operations for ZonedDateTime relativeTo"); -actual.splice(0); // clear - -// code path through Duration.p.total that rounds to the nearest year with -// minimal calendar operations: -const expectedOpsForMinimalYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ - // ToTemporalDate - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // lookup in Duration.p.total - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", - // DifferenceZonedDateTimeWithRounding → DifferenceZonedDateTime - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 5 - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 12.c - "call options.relativeTo.calendar.dateUntil", // 13.f - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getPossibleInstantsFor", -]); -instance.total(createOptionsObserver({ unit: "years", relativeTo: zonedRelativeTo })); -assert.compareArray( - actual, - expectedOpsForMinimalYearRoundingZoned, - "order of operations with years = 0, unit = years and ZonedDateTime relativeTo" -); -actual.splice(0); // clear - -// code path through Duration.p.total that rounds to years: -const expectedOpsForYearRoundingZoned = expectedOpsForZonedRelativeTo.concat([ - // ToTemporalDate - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // lookup in Duration.p.total - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", - // 18.c AddZonedDateTime - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor - // DifferenceZonedDateTimeWithRounding → DifferenceZonedDateTime - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 5 - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 12.c - "call options.relativeTo.calendar.dateUntil", // 13.f - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getPossibleInstantsFor", -]); -instanceYears.total(createOptionsObserver({ unit: "years", relativeTo: zonedRelativeTo })); -assert.compareArray( - actual, - expectedOpsForYearRoundingZoned, - "order of operations with unit = years and ZonedDateTime relativeTo" -); -actual.splice(0); // clear - -// code path through Duration.p.total that rounds to months: -const expectedOpsForMonthsRoundingZoned = expectedOpsForZonedRelativeTo.concat([ - // ToTemporalDate - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // lookup in Duration.p.total - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", - // 18.c AddZonedDateTime - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor - // DifferenceZonedDateTimeWithRounding → DifferenceZonedDateTime - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 5 - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 12.c - "call options.relativeTo.calendar.dateUntil", // 13.f - // RoundRelativeDuration - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getPossibleInstantsFor", -]); -new Temporal.Duration(0, 1, 1).total(createOptionsObserver({ unit: "months", relativeTo: zonedRelativeTo })); -assert.compareArray( - actual, - expectedOpsForMonthsRoundingZoned, - "order of operations with unit = months and ZonedDateTime relativeTo" -); +assert.compareArray(actual, expectedOpsForZonedRelativeTo, "order of operations for ZonedDateTime relativeTo"); actual.splice(0); // clear - -// code path through Duration.p.total that rounds to weeks: -const expectedOpsForWeeksRoundingZoned = expectedOpsForZonedRelativeTo.concat([ - // ToTemporalDate - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", - // lookup in Duration.p.total - "get options.relativeTo.calendar.dateAdd", - "get options.relativeTo.calendar.dateUntil", - // 18.c AddZonedDateTime - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 13. GetInstantFor - // DifferenceZonedDateTimeWithRounding → DifferenceZonedDateTime - "call options.relativeTo.timeZone.getOffsetNanosecondsFor", // 5 - "call options.relativeTo.timeZone.getPossibleInstantsFor", // 12.c - "call options.relativeTo.calendar.dateUntil", // 13.f - // RoundRelativeDuration - "call options.relativeTo.calendar.dateUntil", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.calendar.dateAdd", - "call options.relativeTo.timeZone.getPossibleInstantsFor", - "call options.relativeTo.timeZone.getPossibleInstantsFor", -]); -new Temporal.Duration(0, 0, 0, 1, 240).total(createOptionsObserver({ unit: "weeks", relativeTo: zonedRelativeTo })); -assert.compareArray( - actual, - expectedOpsForWeeksRoundingZoned, - "order of operations with unit = weeks and no calendar units" -); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-3.js b/test/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-3.js deleted file mode 100644 index 9dfb40d1d2c..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-3.js +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - RoundDuration computes in such a way as to avoid precision loss when the - computed day, week, month, and year lengths are very large numbers. -info: | - RoundDuration: - ... - 7. If _unit_ is one of *"year"*, *"month"*, *"week"*, or *"day"*, then - a. If _zonedRelativeTo_ is not *undefined*, then - ... - iii. Let _fractionalDays_ be _days_ + _result_.[[Days]] + DivideNormalizedTimeDuration(_result_.[[Remainder]], _result_.[[DayLength]]). - ... - 10. If _unit_ is *"year"*, then - ... - z. Let _fractionalYears_ be _years_ + _fractionalDays_ / abs(_oneYearDays_). - ... - 11. If _unit_ is *"month"*, then - ... - z. Let _fractionalMonths_ be _months_ + _fractionalDays_ / abs(_oneMonthDays_). - ... - 12. If _unit_ is *"week"*, then - ... - s. Let _fractionalWeeks_ be _weeks_ + _fractionalDays_ / abs(_oneWeekDays_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -// Return the next Number value in direction to +Infinity. -function nextUp(num) { - if (!Number.isFinite(num)) { - return num; - } - if (num === 0) { - return Number.MIN_VALUE; - } - - var f64 = new Float64Array([num]); - var u64 = new BigUint64Array(f64.buffer); - u64[0] += (num < 0 ? -1n : 1n); - return f64[0]; -} - -// Return the next Number value in direction to -Infinity. -function nextDown(num) { - if (!Number.isFinite(num)) { - return num; - } - if (num === 0) { - return -Number.MIN_VALUE; - } - - var f64 = new Float64Array([num]); - var u64 = new BigUint64Array(f64.buffer); - u64[0] += (num < 0 ? 1n : -1n); - return f64[0]; -} - -// Return bit pattern representation of Number as a Uint8Array of bytes. -function f64Repr(f) { - const buf = new ArrayBuffer(8); - new DataView(buf).setFloat64(0, f); - return new Uint8Array(buf); -} - -// ============ - -function createTimeZone() { - const tz = new Temporal.TimeZone("UTC"); - TemporalHelpers.substituteMethod(tz, "getPossibleInstantsFor", [ - TemporalHelpers.SUBSTITUTE_SKIP, - [new Temporal.Instant(-86400_0000_0000_000_000_000n)], - [new Temporal.Instant(86400_0000_0000_000_000_000n - 100_000_000n)], - ]); - return tz; -} - -function createRelativeTo() { - return new Temporal.ZonedDateTime(-86400_0000_0000_000_000_000n, createTimeZone()); -} - -const d = new Temporal.Duration(0, 0, 0, 0, 0, 0, 0, 0, 0, /* nanoseconds = */ 1); - -// NS_MAX_INSTANT = 86400 × 1e8 × 1e9 -// startEpochNs = -NS_MAX_INSTANT -// destEpochNs = -NS_MAX_INSTANT + 1 -// endEpochNs = NS_MAX_INSTANT - 1e8 -// progress = (destEpochNs - startEpochNs) / (endEpochNs - startEpochNs) -// = 1 / (2 × NS_MAX_INSTANT - 1e8) -// total = startDuration.years + progress = 0 + 1 / (2 × NS_MAX_INSTANT - 1e8) -// -// Calculated with Python's Decimal module to 50 decimal places -const expected = 5.7870370370370_705268347050756396228860247432848547e-23; -// This is float 5.7870370370370_6998177e-23 -// Note: if calculated using floating point arithmetic, this will give the less -// precise value 5.7870370370370_7115726e-23 - -// Check that we are not accidentally losing precision in our expected value: -assert.sameValue(expected, 5.7870370370370_6998177e-23, "the float representation of the result is 5.7870370370370_6998177e-23"); -assert.compareArray( - f64Repr(expected), - [0x3b, 0x51, 0x7d, 0x80, 0xc6, 0xf1, 0x14, 0xa8], - "the bit representation of the result is 0x3b517d80c6f114a8" -); -// The next Number in direction -Infinity is less precise. -assert.sameValue(nextDown(expected), 5.7870370370370_6880628e-23, "the next Number in direction -Infinity is less precise"); -// The next Number in direction +Infinity is less precise. -assert.sameValue(nextUp(expected), 5.7870370370370_7115727e-23, "the next Number in direction +Infinity is less precise"); - -assert.sameValue(d.total({ unit: "years", relativeTo: createRelativeTo() }), expected, "Correct division by large number in years total"); -assert.sameValue(d.total({ unit: "months", relativeTo: createRelativeTo() }), expected, "Correct division by large number in months total"); -assert.sameValue(d.total({ unit: "weeks", relativeTo: createRelativeTo() }), expected, "Correct division by large number in weeks total"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-4.js b/test/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-4.js deleted file mode 100644 index 02e4512c4a9..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/precision-exact-mathematical-values-4.js +++ /dev/null @@ -1,123 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - RoundDuration computes in such a way as to avoid precision loss when the - computed day, week, month, and year lengths are very large numbers. -info: | - RoundDuration: - ... - 7. If _unit_ is one of *"year"*, *"month"*, *"week"*, or *"day"*, then - a. If _zonedRelativeTo_ is not *undefined*, then - ... - iii. Let _fractionalDays_ be _days_ + _result_.[[Days]] + DivideNormalizedTimeDuration(_result_.[[Remainder]], _result_.[[DayLength]]). - ... - 10. If _unit_ is *"year"*, then - ... - z. Let _fractionalYears_ be _years_ + _fractionalDays_ / abs(_oneYearDays_). - ... - 11. If _unit_ is *"month"*, then - ... - z. Let _fractionalMonths_ be _months_ + _fractionalDays_ / abs(_oneMonthDays_). - ... - 12. If _unit_ is *"week"*, then - ... - s. Let _fractionalWeeks_ be _weeks_ + _fractionalDays_ / abs(_oneWeekDays_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -// Return the next Number value in direction to +Infinity. -function nextUp(num) { - if (!Number.isFinite(num)) { - return num; - } - if (num === 0) { - return Number.MIN_VALUE; - } - - var f64 = new Float64Array([num]); - var u64 = new BigUint64Array(f64.buffer); - u64[0] += (num < 0 ? -1n : 1n); - return f64[0]; -} - -// Return the next Number value in direction to -Infinity. -function nextDown(num) { - if (!Number.isFinite(num)) { - return num; - } - if (num === 0) { - return -Number.MIN_VALUE; - } - - var f64 = new Float64Array([num]); - var u64 = new BigUint64Array(f64.buffer); - u64[0] += (num < 0 ? 1n : -1n); - return f64[0]; -} - -// Return bit pattern representation of Number as a Uint8Array of bytes. -function f64Repr(f) { - const buf = new ArrayBuffer(8); - new DataView(buf).setFloat64(0, f); - return new Uint8Array(buf); -} - -// ============ -// Set up contrived custom time zone to give the denominator of the fraction its -// largest possible value - -function createTimeZone() { - const tz = new Temporal.TimeZone("UTC"); - TemporalHelpers.substituteMethod(tz, "getPossibleInstantsFor", [ - TemporalHelpers.SUBSTITUTE_SKIP, // Duration.total step 18.c AddZonedDateTime - TemporalHelpers.SUBSTITUTE_SKIP, // DifferenceZonedDateTimeWithRounding → DifferenceZonedDateTime → AddZonedDateTime - [new Temporal.Instant(-86400_0000_0000_000_000_000n)], - [new Temporal.Instant(86400_0000_0000_000_000_000n)], - ]); - return tz; -} - -function createRelativeTo() { - return new Temporal.ZonedDateTime(-86400_0000_0000_000_000_000n, createTimeZone()); -} - -// ============ - -// We will calculate the total years of a duration of 1 year, 0.009254648 s - -// NS_MAX_INSTANT = 86400 × 1e8 × 1e9 -// startEpochNs = -NS_MAX_INSTANT -// destEpochNs = -NS_MAX_INSTANT + 366 * 86400 * 1e9 + 9254648 -// endEpochNs = NS_MAX_INSTANT -// progress = (destEpochNs - startEpochNs) / (endEpochNs - startEpochNs) -// = (366 * 86400 * 1e9 + 9254648) / (2 × NS_MAX_INSTANT) -// total = startDuration.years + progress -// = 1 + (366 * 86400 * 1e9 + 9254648) / (2 × NS_MAX_INSTANT) -// -// Calculated with Python's Decimal module to 50 decimal places -const expected = 1.000001830000000_5355699074074074074074074074074074; -// This is float 1.000001830000000_64659 -// Note: if calculated using floating point arithmetic, this will give the less -// precise value 1.000001830000000_42454 - -// Check that we are not accidentally losing precision in our expected value: - -assert.sameValue(expected, 1.000001830000000_64659, "the float representation of the result is 1.00000183000000064659"); -assert.compareArray( - f64Repr(expected), - [0x3f, 0xf0, 0x00, 0x01, 0xeb, 0x3c, 0xa4, 0x79], - "the bit representation of the result is 0x3ff00001eb3ca479" -); -// The next Number in direction -Infinity is less precise. -assert.sameValue(nextDown(expected), 1.000001830000000_42455, "the next Number in direction -Infinity is less precise"); -// The next Number in direction +Infinity is less precise. -assert.sameValue(nextUp(expected), 1.000001830000000_86864, "the next Number in direction +Infinity is less precise"); - -// ============ - -const duration = new Temporal.Duration(/* years = */ 1, 0, 0, 0, 0, 0, 0, 9, 254, 648); -assert.sameValue(duration.total({ unit: "years", relativeTo: createRelativeTo() }), expected, "Correct division by large number in years total"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/proto-in-calendar-fields.js b/test/built-ins/Temporal/Duration/prototype/total/proto-in-calendar-fields.js deleted file mode 100644 index 5c75d3706cf..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.duration.prototype.total -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const relativeTo = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: 'Europe/Paris' }; -const instance = new Temporal.Duration(1, 0, 0, 0, 24); - -assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo })); diff --git a/test/built-ins/Temporal/Duration/prototype/total/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/Duration/prototype/total/read-time-fields-before-datefromfields.js deleted file mode 100644 index ae4f10bcbf4..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.duration.prototype.total step 4: - 4. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). - sec-temporal-torelativetemporalobject step 4.g: - g. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInvalidGettersTime(); -const duration = new Temporal.Duration(1, 1, 1, 1, 1, 1, 1); -duration.total({ unit: 'seconds', relativeTo: { year: 2000, month: 1, day: 1, calendar } }); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-ambiguous-wall-clock-time.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-ambiguous-wall-clock-time.js deleted file mode 100644 index 887f2dda4bc..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-ambiguous-wall-clock-time.js +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - Correct time zone calls are made when converting a ZonedDateTime-like - relativeTo property bag denoting an ambiguous wall-clock time -includes: [temporalHelpers.js, compareArray.js] -features: [Temporal] ----*/ - -const actual = []; - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const dstTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone), - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone), -}); -const calendar = TemporalHelpers.calendarObserver(actual, "calendar"); - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); - -let relativeTo = { year: 2000, month: 4, day: 2, hour: 2, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.total({ unit: "days", relativeTo }); - -const expected = [ - // GetTemporalCalendarSlotValueWithISODefault - "has calendar.dateAdd", - "has calendar.dateFromFields", - "has calendar.dateUntil", - "has calendar.day", - "has calendar.dayOfWeek", - "has calendar.dayOfYear", - "has calendar.daysInMonth", - "has calendar.daysInWeek", - "has calendar.daysInYear", - "has calendar.fields", - "has calendar.id", - "has calendar.inLeapYear", - "has calendar.mergeFields", - "has calendar.month", - "has calendar.monthCode", - "has calendar.monthDayFromFields", - "has calendar.monthsInYear", - "has calendar.weekOfYear", - "has calendar.year", - "has calendar.yearMonthFromFields", - "has calendar.yearOfWeek", - // lookup - "get calendar.dateFromFields", - "get calendar.fields", - // CalendarFields - "call calendar.fields", - // InterpretTemporalDateTimeFields - "call calendar.dateFromFields", - // ToTemporalTimeZoneSlotValue - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - // lookup - "get timeZone.getOffsetNanosecondsFor", - "get timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", -]; - -const expectedSpringForward = expected.concat([ - // DisambiguatePossibleInstants - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getPossibleInstantsFor", -]); -assert.compareArray( - actual.slice(0, expectedSpringForward.length), // ignore operations after ToRelativeTemporalObject - expectedSpringForward, - "order of operations converting property bag at skipped wall-clock time" -); -actual.splice(0); // clear - -relativeTo = { year: 2000, month: 10, day: 29, hour: 1, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.total({ unit: "days", relativeTo }); - -assert.compareArray( - actual.slice(0, expected.length), // ignore operations after ToRelativeTemporalObject - expected, - "order of operations converting property bag at repeated wall-clock time" -); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 5de36d92011..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - Calling the method with a relativeTo property bag with a builtin calendar - causes no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const timeZone = "UTC"; -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -const relativeTo = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, timeZone, calendar: "iso8601" }; -instance.total({ unit: "days", relativeTo }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index d35ab02078b..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -const relativeTo = { year: 2000, month: 5, day: 2, calendar }; -instance.total({ unit: "days", relativeTo }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-string.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-string.js deleted file mode 100644 index c2e5ce2ca82..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-string.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - Builtin dateFromFields method is not observably called when the property bag - has a string-valued calendar property -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -const relativeTo = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.total({ unit: "days", relativeTo }); - -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-wrong-type.js index aba5db54ef0..3e2b8a7a4a2 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.Duration(1, 0, 0, 0, 24); const primitiveTests = [ @@ -31,8 +31,7 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], + [{}, "object"], [Temporal.PlainDate, "Temporal.PlainDate, object"], [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], [Temporal.ZonedDateTime, "Temporal.ZonedDateTime, object"], diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index a5205f6ab76..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); -const relativeTo = { year: 2000, month: 5, day: 2, timeZone, calendar: nonBuiltinISOCalendar }; - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -instance.total({ unit: "days", relativeTo }); - -assert.sameValue(timeZone.calls, 10, "getPossibleInstantsFor should have been called 10 times"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-invalid-offset-string.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-invalid-offset-string.js index 50b44cb62a7..f5adc67f934 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-invalid-offset-string.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-invalid-offset-string.js @@ -7,7 +7,7 @@ description: relativeTo property bag with offset property is rejected if offset features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.Duration(1, 0, 0, 0, 24); const badOffsets = [ diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-backward-offset-shift.js deleted file mode 100644 index 96b2d429f9d..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-forward-offset-shift.js deleted file mode 100644 index 79d1465cd1e..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const relativeTo = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.Duration(1, 0, 0, 0, 24); -assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 216d9aadc8e..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - assert.throws(RangeError, () => duration.total({ unit: "seconds", relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 1c5475c2f05..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => duration.total({ unit: "seconds", relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index c23df85c171..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - assert.throws(RangeError, () => duration.total({ unit: "seconds", relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index dcd73d3525a..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - assert.throws(TypeError, () => duration.total({ unit: "seconds", relativeTo: { year: 2000, month: 5, day: 2, hour: 12, timeZone } })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string-datetime.js index a02c1498ce2..949623e702b 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.duration.prototype.total -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string.js index 4bd5209ab9e..9269225e568 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-string.js @@ -4,27 +4,9 @@ /*--- esid: sec-temporal.duration.prototype.total description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.Duration(1); // The following are all valid strings so should not throw: @@ -32,6 +14,3 @@ const instance = new Temporal.Duration(1); ["UTC", "+01:00"].forEach((timeZone) => { instance.total({ unit: "months", relativeTo: { year: 2000, month: 5, day: 2, timeZone } }); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-wrong-type.js index 86548389775..c4b29ed487e 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-wrong-type.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.duration.prototype.total description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-wrong-type.js index d90ba1dc141..29541d661ef 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-wrong-type.js +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone('UTC'); +const timeZone = "UTC"; const instance = new Temporal.Duration(1, 0, 0, 0, 24); const primitiveTests = [ diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 826dde446d6..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => duration.total({ unit: "seconds", relativeTo: datetime })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 8e561bf1c56..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => duration.total({ unit: "seconds", relativeTo: datetime }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 6747da914a2..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => duration.total({ unit: "seconds", relativeTo: datetime })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 2172e065077..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1, 2, 3, 4, 5, 6, 7, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => duration.total({ unit: "seconds", relativeTo: datetime })); -}); diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-with-fractional-days-different-sign.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-with-fractional-days-different-sign.js deleted file mode 100644 index b9730252be5..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/relativeto-zoneddatetime-with-fractional-days-different-sign.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - Relative to a ZonedDateTime with a fractional number of days and different sign. -features: [Temporal] ----*/ - -let duration = Temporal.Duration.from({ - weeks: 1, - days: 0, - hours: 1, -}); - -let cal = new class extends Temporal.Calendar { - #dateAdd = 0; - - dateAdd(date, duration, options) { - if (++this.#dateAdd === 1) { - duration = "-P1W"; - } - return super.dateAdd(date, duration, options); - } -}("iso8601"); - -let zdt = new Temporal.ZonedDateTime(0n, "UTC", cal); - -let result = duration.total({ - relativeTo: zdt, - unit: "days", -}); - -assert.sameValue(result, -7 + 1 / 24); diff --git a/test/built-ins/Temporal/Duration/prototype/total/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/Duration/prototype/total/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index bc13e0bd9d6..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.duration.prototype.total steps 4 and 10: - 4. Let _relativeTo_ be ? ToRelativeTemporalObject(_options_). - 10. Let _balanceResult_ be ? BalanceDuration(_unbalanceResult_.[[Days]], [...], _unbalanceResult_.[[Nanoseconds]], _unit_, _intermediate_). - sec-temporal-torelativetemporalobject step 6.d: - d. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], [...], _result_.[[Nanosecond]], _offsetNs_, _timeZone_, *"compatible"*, *"reject"*). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-addzoneddatetime step 8: - 8. Let _intermediateInstant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _intermediateDateTime_, *"compatible"*). - sec-temporal-builtintimezonegetinstantfor step 1: - 1. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "2000-01-01T00:00:00", // called once on the input relativeTo if ZonedDateTime - "2001-02-09T00:00:00", // called once on the intermediate ZonedDateTime with the calendar parts of the Duration added -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const duration = new Temporal.Duration(1, 1, 1, 1, 1, 1, 1); - duration.total({ unit: 'seconds', relativeTo: { year: 2000, month: 1, day: 1, timeZone } }); -}, expected); diff --git a/test/built-ins/Temporal/Duration/prototype/total/zero-day-length.js b/test/built-ins/Temporal/Duration/prototype/total/zero-day-length.js deleted file mode 100644 index 2790977b23d..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/zero-day-length.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: A malicious time zone resulting a day length of zero is handled correctly -info: | - Based on a test by André Bargull. - - RoundDuration step 6: - d. Let _result_ be ? NanosecondsToDays(_nanoseconds_, _intermediate_). - e. Set _days_ to _days_ + _result_.[[Days]] + _result_.[[Nanoseconds]] / _result_.[[DayLength]]. - - NanosecondsToDays steps 19-23: - 19. If _days_ < 0 and _sign_ = 1, throw a *RangeError* exception. - 20. If _days_ > 0 and _sign_ = -1, throw a *RangeError* exception. - 21. If _nanoseconds_ < 0, then - a. Assert: sign is -1. - 22. If _nanoseconds_ > 0 and _sign_ = -1, throw a *RangeError* exception. - 23. Assert: The inequality abs(_nanoseconds_) < abs(_dayLengthNs_) holds. -features: [Temporal] ----*/ - -const instance = new Temporal.Duration(0, 0, 0, 0, -24, 0, 0, 0, 0, -1); - -const tz = new class extends Temporal.TimeZone { - #getPossibleInstantsForCalls = 0; - - getPossibleInstantsFor(dt) { - this.#getPossibleInstantsForCalls++; - - if (this.#getPossibleInstantsForCalls <= 2) { - return [new Temporal.Instant(-86400_000_000_000n - 2n)] - } - return super.getPossibleInstantsFor(dt); - } -}("UTC"); - -const relativeTo = new Temporal.ZonedDateTime(0n, tz, "iso8601"); -assert.throws(RangeError, () => instance.total({ relativeTo, unit: "days" })); diff --git a/test/built-ins/Temporal/Duration/prototype/total/zero-year-month-week-length.js b/test/built-ins/Temporal/Duration/prototype/total/zero-year-month-week-length.js deleted file mode 100644 index 8f5ec24b9cd..00000000000 --- a/test/built-ins/Temporal/Duration/prototype/total/zero-year-month-week-length.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.duration.prototype.total -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const instance = new Temporal.Duration(1, 0, 0, 0, 0, 0, 0, 0, 0, 1); -const relativeTo = new Temporal.ZonedDateTime(0n, "UTC", cal); - -assert.throws(RangeError, () => instance.total({ relativeTo, unit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => instance.total({ relativeTo, unit: "months" }), "zero month length handled correctly"); -assert.throws(RangeError, () => instance.total({ relativeTo, unit: "weeks" }), "zero week length handled correctly"); diff --git a/test/built-ins/Temporal/Instant/from/timezone-custom.js b/test/built-ins/Temporal/Instant/from/timezone-custom.js index 6063d6f5c85..51dcadaf79b 100644 --- a/test/built-ins/Temporal/Instant/from/timezone-custom.js +++ b/test/built-ins/Temporal/Instant/from/timezone-custom.js @@ -7,13 +7,5 @@ description: Time zone annotation is ignored in input ISO string features: [Temporal] ---*/ -const dateTimeString = "1975-02-02T14:25:36.123456789"; - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - throw new Test262Error("should not get Temporal.TimeZone.from"); - }, -}); - -const instant = Temporal.Instant.from(dateTimeString + "+01:00[Custom/TimeZone]"); +const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456789+01:00[Invalid/TimeZone]"); assert.sameValue(instant.epochMilliseconds, 160579536123); diff --git a/test/built-ins/Temporal/Instant/prototype/since/order-of-operations.js b/test/built-ins/Temporal/Instant/prototype/since/order-of-operations.js index ab293f45f25..6065fa9a3c5 100644 --- a/test/built-ins/Temporal/Instant/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/Instant/prototype/since/order-of-operations.js @@ -11,23 +11,16 @@ features: [Temporal] const expected = [ "get other.toString", "call other.toString", - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; diff --git a/test/built-ins/Temporal/Instant/prototype/toString/options-undefined.js b/test/built-ins/Temporal/Instant/prototype/toString/options-undefined.js index 08dcbab63c6..9e225f32cbd 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/options-undefined.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/options-undefined.js @@ -3,36 +3,20 @@ /*--- esid: sec-temporal.instant.prototype.tostring -includes: [compareArray.js] description: Verify that undefined options are handled correctly. features: [Temporal] ---*/ -const actual = []; -const expected = []; - const instant = Temporal.Instant.from("1975-02-02T14:25:36.12345Z"); -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return function(identifier) { - actual.push("call Temporal.TimeZone.from"); - assert.sameValue(identifier, "UTC"); - }; - }, -}); - assert.sameValue( instant.toString(), "1975-02-02T14:25:36.12345Z", "default time zone is none, precision is auto, and rounding is trunc" ); -assert.compareArray(actual, expected); assert.sameValue( instant.toString(undefined), "1975-02-02T14:25:36.12345Z", "default time zone is none, precision is auto, and rounding is trunc" ); -assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/Instant/prototype/toString/order-of-operations.js index 238869e55c1..7c64f8cb48d 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/order-of-operations.js @@ -19,11 +19,6 @@ const expected = [ "get options.smallestUnit.toString", "call options.smallestUnit.toString", "get options.timeZone", - "has options.timeZone.getOffsetNanosecondsFor", - "has options.timeZone.getPossibleInstantsFor", - "has options.timeZone.id", - "get options.timeZone.getOffsetNanosecondsFor", - "call options.timeZone.getOffsetNanosecondsFor", ]; const actual = []; @@ -34,8 +29,8 @@ instance.toString( fractionalSecondDigits: "auto", roundingMode: "halfExpand", smallestUnit: "millisecond", - timeZone: TemporalHelpers.timeZoneObserver(actual, "options.timeZone"), - }, "options"), + timeZone: "UTC", + }, "options", ["timeZone"]), ); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index fbed542c45b..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.tostring -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - assert.throws(RangeError, () => instant.toString({ timeZone })); -}); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 46a1d3c174e..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.tostring -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => instant.toString({ timeZone }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index b27a293033c..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.tostring -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - assert.throws(RangeError, () => instant.toString({ timeZone })); -}); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 1c76fea6e2b..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.tostring -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - assert.throws(TypeError, () => instant.toString({ timeZone })); -}); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js index 1914167cf06..f2e4f933279 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-offset.js @@ -10,8 +10,7 @@ features: [BigInt, Temporal] const instant = new Temporal.Instant(0n); function test(timeZoneIdentifier, expected, description) { - const timeZone = new Temporal.TimeZone(timeZoneIdentifier); - assert.sameValue(instant.toString({ timeZone }), expected, description); + assert.sameValue(instant.toString({ timeZone: timeZoneIdentifier }), expected, description); } test("UTC", "1970-01-01T00:00:00+00:00", "offset of UTC is +00:00"); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-datetime.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-datetime.js index ebfdaeeb914..123f9cd5c13 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.instant.prototype.tostring -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string.js index 9c6346a65cd..9c7ba8d863b 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-string.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-string.js @@ -4,27 +4,9 @@ /*--- esid: sec-temporal.instant.prototype.tostring description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.Instant(0n); const result1 = instance.toString({ timeZone: "UTC" }); @@ -32,6 +14,3 @@ assert.sameValue(result1.substr(-6), "+00:00", "Time zone created from string 'U const result2 = instance.toString({ timeZone: "-01:30" }); assert.sameValue(result2.substr(-6), "-01:30", "Time zone created from string '-01:30'"); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone-wrong-type.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone-wrong-type.js index c7ed824feaa..7de86e0d7dd 100644 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone-wrong-type.js +++ b/test/built-ins/Temporal/Instant/prototype/toString/timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.instant.prototype.tostring description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/Instant/prototype/toString/timezone.js b/test/built-ins/Temporal/Instant/prototype/toString/timezone.js deleted file mode 100644 index 74edc124c62..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toString/timezone.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.tostring -description: > - Passing a TimeZone to options calls getOffsetNanosecondsFor, but not toString -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - "get timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", -]; - -const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456Z"); -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - toString: TemporalHelpers.toPrimitiveObserver(actual, "Custom/TimeZone", "name"), - getOffsetNanosecondsFor(instantArg) { - assert.sameValue(instantArg.epochNanoseconds, instant.epochNanoseconds); - return -8735135801679; - }, -}); - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return undefined; - }, -}); - -assert.sameValue(instant.toString({ timeZone }), "1975-02-02T12:00:00.987654321-02:26"); -assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/branding.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/branding.js index a5997e2f016..021dbb0d813 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/branding.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/branding.js @@ -11,7 +11,7 @@ const toZonedDateTimeISO = Temporal.Instant.prototype.toZonedDateTimeISO; assert.sameValue(typeof toZonedDateTimeISO, "function"); -const args = [{ timeZone: new Temporal.TimeZone("UTC") }]; +const args = [{ timeZone: "UTC" }]; assert.throws(TypeError, () => toZonedDateTimeISO.apply(undefined, args), "undefined"); assert.throws(TypeError, () => toZonedDateTimeISO.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/calendar-is-builtin.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/calendar-is-builtin.js index 662eaedb35c..47bad974a22 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/calendar-is-builtin.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/calendar-is-builtin.js @@ -10,4 +10,4 @@ features: [Temporal] const instance = new Temporal.Instant(0n); const result = instance.toZonedDateTimeISO("UTC"); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/plain-custom-timezone.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/plain-custom-timezone.js deleted file mode 100644 index 6ff5e691a66..00000000000 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/plain-custom-timezone.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.instant.prototype.tozoneddatetimeiso -description: TimeZone.getPlainDateTimeFor is not called -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", -]; - -const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456789Z"); -const calendar = Temporal.Calendar.from("iso8601"); -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getPlainDateTimeFor: Temporal.PlainDateTime.from("1963-07-02T12:00:00.987654321"), -}); - -const result = instant.toZonedDateTimeISO(timeZone); -assert.sameValue(result.epochNanoseconds, instant.epochNanoseconds); - -assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js index a8b7789e0b5..dfdf0041db8 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.instant.prototype.tozoneddatetimeiso -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string.js index 1c4d9b66c8c..687a6377915 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string.js @@ -4,33 +4,12 @@ /*--- esid: sec-temporal.instant.prototype.tozoneddatetimeiso description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.Instant(0n); ["UTC", "+01:30"].forEach((timeZone) => { const result = instance.toZonedDateTimeISO(timeZone); - assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); + assert.sameValue(result.timeZoneId, timeZone, `time zone slot should store string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-wrong-type.js b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-wrong-type.js index f6b83f9481d..fd1cafe7aed 100644 --- a/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-wrong-type.js +++ b/test/built-ins/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.instant.prototype.tozoneddatetimeiso description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/Instant/prototype/until/order-of-operations.js b/test/built-ins/Temporal/Instant/prototype/until/order-of-operations.js index 61b77fbcbb6..152672007be 100644 --- a/test/built-ins/Temporal/Instant/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/Instant/prototype/until/order-of-operations.js @@ -11,23 +11,16 @@ features: [Temporal] const expected = [ "get other.toString", "call other.toString", - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; diff --git a/test/built-ins/Temporal/Now/plainDateISO/return-value.js b/test/built-ins/Temporal/Now/plainDateISO/return-value.js index 511e51f7692..0ecd9f8d926 100644 --- a/test/built-ins/Temporal/Now/plainDateISO/return-value.js +++ b/test/built-ins/Temporal/Now/plainDateISO/return-value.js @@ -9,4 +9,4 @@ features: [Temporal] const d = Temporal.Now.plainDateISO(); assert(d instanceof Temporal.PlainDate); -assert.sameValue(d.getISOFields().calendar, "iso8601", "calendar slot should store a string"); +assert.sameValue(d.calendarId, "iso8601", "calendar string should be iso8601"); diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 8986a6dcbe9..00000000000 --- a/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaindateiso -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone)); -}); diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index d8d770d68de..00000000000 --- a/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindateiso -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => { - const timeZone = new Temporal.TimeZone("UTC"); - - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.Now.plainDateISO(timeZone), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index c69d1b46ec2..00000000000 --- a/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaindateiso -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(RangeError, () => Temporal.Now.plainDateISO(timeZone)); -}); diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 3f66b8492da..00000000000 --- a/test/built-ins/Temporal/Now/plainDateISO/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaindateiso -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(TypeError, () => Temporal.Now.plainDateISO(timeZone)); -}); diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js index 575cddb8e57..7f7f1a4ac4b 100644 --- a/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/plainDateISO/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.now.plaindateiso -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-string.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-string.js index 0062a04bac8..d9a452e2dfa 100644 --- a/test/built-ins/Temporal/Now/plainDateISO/timezone-string.js +++ b/test/built-ins/Temporal/Now/plainDateISO/timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.now.plaindateiso description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - // The following are all valid strings so should not throw: ["UTC", "+01:00"].forEach((timeZone) => { Temporal.Now.plainDateISO(timeZone); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/plainDateISO/timezone-wrong-type.js b/test/built-ins/Temporal/Now/plainDateISO/timezone-wrong-type.js index 92d84f597b6..2402b6c52a2 100644 --- a/test/built-ins/Temporal/Now/plainDateISO/timezone-wrong-type.js +++ b/test/built-ins/Temporal/Now/plainDateISO/timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.now.plaindateiso description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -28,8 +28,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/Now/plainDateISO/toPlainDate-override.js b/test/built-ins/Temporal/Now/plainDateISO/toPlainDate-override.js deleted file mode 100644 index 1aba85c4a78..00000000000 --- a/test/built-ins/Temporal/Now/plainDateISO/toPlainDate-override.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaindateiso -description: PlainDateTime.toPlainDate is not observably called -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - "get timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", -]; - -Object.defineProperty(Temporal.PlainDateTime.prototype, "toPlainDate", { - get() { - actual.push("get Temporal.PlainDateTime.prototype.toPlainDate"); - return function() { - actual.push("call Temporal.PlainDateTime.prototype.toPlainDate"); - }; - }, -}); - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - assert.sameValue(instant instanceof Temporal.Instant, true, "Instant"); - return 86399_999_999_999; - }, -}); - -const result = Temporal.Now.plainDateISO(timeZone); -assert.notSameValue(result, undefined); -assert.sameValue(result instanceof Temporal.PlainDate, true); - -assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/return-value-calendar.js b/test/built-ins/Temporal/Now/plainDateTimeISO/return-value-calendar.js index 073856d8ee0..bf1a35ea220 100644 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/return-value-calendar.js +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/return-value-calendar.js @@ -8,4 +8,4 @@ features: [Temporal] ---*/ const result = Temporal.Now.plainDateTimeISO(); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot should store a string"); +assert.sameValue(result.calendarId, "iso8601", "calendar string should be iso8601"); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/return-value.js b/test/built-ins/Temporal/Now/plainDateTimeISO/return-value.js deleted file mode 100644 index f1f31f2bb93..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/return-value.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: Return value describes the start of a day -features: [BigInt, Temporal] ----*/ -const timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor(instant) { - return -Number(instant.epochNanoseconds % 86400000000000n); - } -}; - -const result = Temporal.Now.plainDateTimeISO(timeZone); - -for (const property of ['hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond']) { - assert.sameValue(result[property], 0, 'The value of result[property] is expected to be 0'); -} diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined.js b/test/built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined.js index 6d719c2e91f..518a306effc 100644 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined.js +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/time-zone-undefined.js @@ -4,32 +4,17 @@ /*--- esid: sec-temporal.now.plaindatetimeiso description: Functions when time zone argument is omitted -includes: [compareArray.js] features: [Temporal] ---*/ -const actual = []; -const expected = []; - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return undefined; - }, -}); - const resultExplicit = Temporal.Now.plainDateTimeISO(undefined); assert( resultExplicit instanceof Temporal.PlainDateTime, 'The result of evaluating (resultExplicit instanceof Temporal.PlainDateTime) is expected to be true' ); -assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); - const resultImplicit = Temporal.Now.plainDateTimeISO(); assert( resultImplicit instanceof Temporal.PlainDateTime, 'The result of evaluating (resultImplicit instanceof Temporal.PlainDateTime) is expected to be true' ); - -assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-invocation.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-invocation.js deleted file mode 100644 index 03f3bd666e1..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-invocation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: Correctly invokes `getOffsetNanosecondsFor` method of TimeZone-like objects -features: [Temporal] ----*/ - -var calls = []; -var timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor: function() { - calls.push({ - args: arguments, - this: this - }); - return 0; - }, -}; - -Temporal.Now.plainDateTimeISO(timeZone); - -assert.sameValue(calls.length, 1, 'The value of calls.length is expected to be 1'); -assert.sameValue(calls[0].args.length, 1, 'The value of calls[0].args.length is expected to be 1'); -assert( - calls[0].args[0] instanceof Temporal.Instant, - 'The result of evaluating (calls[0].args[0] instanceof Temporal.Instant) is expected to be true' -); -assert.sameValue(calls[0].this, timeZone, 'The value of calls[0].this is expected to equal the value of timeZone'); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 4cbb76f2541..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal, arrow-function] -includes: [temporalHelpers.js] ----*/ -[3600000000000.5, NaN].forEach(wrongOffset => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws( - RangeError, - () => Temporal.Now.plainDateTimeISO(timeZone), - 'Temporal.Now.plainDateTimeISO(timeZone) throws a RangeError exception' - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-non-method.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-non-method.js deleted file mode 100644 index 9b46ca6c9d3..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-non-method.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: Rejects when `getOffsetNanosecondsFor` property is not a method -features: [Temporal] ----*/ - -var timeZone = { - getOffsetNanosecondsFor: 7 -}; - -assert.throws(TypeError, function() { - Temporal.Now.plainDateTimeISO(timeZone); -}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a TypeError exception'); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-not-a-number.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-not-a-number.js deleted file mode 100644 index 4fd510ca606..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-not-a-number.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: Rejects non-numeric nanosecond values reported by TimeZone-like object -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ -const invalidValues = [ - undefined, - null, - true, - '2020-01-01T12:45:36', - Symbol(), - 2n, - {}, - Temporal.PlainDateTime, - Temporal.PlainDateTime.prototype -]; - -for (const dateTime of invalidValues) { - let callCount = 0; - - const timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor(instant, calendar) { - callCount += 1; - return dateTime; - } - }; - - assert.throws( - TypeError, - () => Temporal.Now.plainDateTimeISO(timeZone), - 'Temporal.Now.plainDateTimeISO(timeZone) throws a TypeError exception' - ); - - assert.sameValue(callCount, 1, 'The value of callCount is expected to be 1'); -} diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index d49a82b949b..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => { - const timeZone = new Temporal.TimeZone("UTC"); - - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.Now.plainDateTimeISO(timeZone), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 7e2f9db70a9..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal, arrow-function] -includes: [temporalHelpers.js] ----*/ -[-86400000000001, 86400000000001, -Infinity, Infinity].forEach(wrongOffset => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws( - RangeError, - () => Temporal.Now.plainDateTimeISO(timeZone), - 'Temporal.Now.plainDateTimeISO(timeZone) throws a RangeError exception' - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-poisoned.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-poisoned.js deleted file mode 100644 index e1d4a73506c..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-poisoned.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: Forwards error when accessing `getOffsetNanosecondsFor` property throws -features: [Temporal] ----*/ - -var timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - get getOffsetNanosecondsFor() { - throw new Test262Error(); - } -}; - -assert.throws(Test262Error, function() { - Temporal.Now.plainDateTimeISO(timeZone); -}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a Test262Error exception'); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-throws.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-throws.js deleted file mode 100644 index 21b92652a65..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-throws.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 the V8 project authors. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: Forwards error when `getOffsetNanosecondsFor` throws -features: [Temporal] ----*/ - -var timeZone = { - id: 'Etc/Test', - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor() { - throw new Test262Error(); - } -}; - -assert.throws(Test262Error, function() { - Temporal.Now.plainDateTimeISO(timeZone); -}, 'Temporal.Now.plainDateTimeISO(timeZone) throws a Test262Error exception'); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 6c31922e856..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: TypeError thrown if time zone reports an offset that is not a Number -features: [BigInt, Symbol, Temporal, arrow-function] -includes: [temporalHelpers.js] ----*/ -[undefined, null, true, '+01:00', Symbol(), 3600000000000n, {}, { - valueOf() { - return 3600000000000; - } -}].forEach(wrongOffset => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws( - TypeError, - () => Temporal.Now.plainDateTimeISO(timeZone), - 'Temporal.Now.plainDateTimeISO(timeZone) throws a TypeError exception' - ); -}); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-object.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-object.js deleted file mode 100644 index 329207447e5..00000000000 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-object.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaindatetimeiso -description: Observable interactions with the provided timezone-like object -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Proxy, Temporal] ----*/ -const actual = []; - -const expected = [ - 'has timeZone.getOffsetNanosecondsFor', - 'has timeZone.getPossibleInstantsFor', - 'has timeZone.id', - 'get timeZone.getOffsetNanosecondsFor', - 'call timeZone.getOffsetNanosecondsFor' -]; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - assert.sameValue( - instant instanceof Temporal.Instant, - true, - 'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true' - ); - - return -Number(instant.epochNanoseconds % 86400000000000n); - } -}); - -Object.defineProperty(Temporal.TimeZone, 'from', { - get() { - actual.push('get Temporal.TimeZone.from'); - return undefined; - } -}); - -Temporal.Now.plainDateTimeISO(timeZone); -assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected'); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js index 4f39442ef39..2589fdb885c 100644 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.now.plaindatetimeiso -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string.js index 2cdab47af05..a4aebae5a52 100644 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string.js +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.now.plaindatetimeiso description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - // The following are all valid strings so should not throw: ["UTC", "+01:00"].forEach((timeZone) => { Temporal.Now.plainDateTimeISO(timeZone); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-wrong-type.js b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-wrong-type.js index ceefe1ca645..318d0cac466 100644 --- a/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-wrong-type.js +++ b/test/built-ins/Temporal/Now/plainDateTimeISO/timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.now.plaindatetimeiso description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -28,8 +28,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index e1e99140438..00000000000 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaintimeiso -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(RangeError, () => Temporal.Now.plainTimeISO(timeZone)); -}); diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index af58bfa9c00..00000000000 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.plaintimeiso -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => { - const timeZone = new Temporal.TimeZone("UTC"); - - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.Now.plainTimeISO(timeZone), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index e72e1cca10a..00000000000 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaintimeiso -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(RangeError, () => Temporal.Now.plainTimeISO(timeZone)); -}); diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index dc9e9957ae7..00000000000 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaintimeiso -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(TypeError, () => Temporal.Now.plainTimeISO(timeZone)); -}); diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js index 4c5f22ffbc1..d7665356ef2 100644 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.now.plaintimeiso -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string.js index a8fa8c37137..939f6afa0ab 100644 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone-string.js +++ b/test/built-ins/Temporal/Now/plainTimeISO/timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.now.plaintimeiso description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - // The following are all valid strings so should not throw: ["UTC", "+01:00"].forEach((timeZone) => { Temporal.Now.plainTimeISO(timeZone); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone-wrong-type.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone-wrong-type.js index 11458e6061f..80b975a3655 100644 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone-wrong-type.js +++ b/test/built-ins/Temporal/Now/plainTimeISO/timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.now.plaintimeiso description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -28,8 +28,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/Now/plainTimeISO/timezone.js b/test/built-ins/Temporal/Now/plainTimeISO/timezone.js deleted file mode 100644 index afdbe41bd82..00000000000 --- a/test/built-ins/Temporal/Now/plainTimeISO/timezone.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.now.plaintimeiso -description: The value returned by TimeZone.getOffsetNanosecondsFor affects the result -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - "get timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", -]; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - assert.sameValue(instant instanceof Temporal.Instant, true, "Instant"); - return -Number(instant.epochNanoseconds % 86400_000_000_000n); - }, -}); - -const result = Temporal.Now.plainTimeISO(timeZone); -assert.sameValue(result instanceof Temporal.PlainTime, true); -for (const property of ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"]) { - assert.sameValue(result[property], 0, property); -} - -assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/Now/plainTimeISO/toPlainTime-override.js b/test/built-ins/Temporal/Now/plainTimeISO/toPlainTime-override.js index 7411562060f..22a0390df2a 100644 --- a/test/built-ins/Temporal/Now/plainTimeISO/toPlainTime-override.js +++ b/test/built-ins/Temporal/Now/plainTimeISO/toPlainTime-override.js @@ -4,18 +4,12 @@ /*--- esid: sec-temporal.now.plaintimeiso description: PlainDateTime.toPlainTime is not observably called -includes: [compareArray.js, temporalHelpers.js] +includes: [compareArray.js] features: [Temporal] ---*/ const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - "get timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", -]; +const expected = []; Object.defineProperty(Temporal.PlainDateTime.prototype, "toPlainTime", { get() { @@ -26,17 +20,7 @@ Object.defineProperty(Temporal.PlainDateTime.prototype, "toPlainTime", { }, }); -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - assert.sameValue(instant instanceof Temporal.Instant, true, "Instant"); - return -Number(instant.epochNanoseconds % 86400_000_000_000n); - }, -}); - -const result = Temporal.Now.plainTimeISO(timeZone); +const result = Temporal.Now.plainTimeISO("UTC"); assert.sameValue(result instanceof Temporal.PlainTime, true); -for (const property of ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"]) { - assert.sameValue(result[property], 0, property); -} assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/return-value.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/return-value.js index 5e8bd4ceb2d..9802420c572 100644 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/return-value.js +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/return-value.js @@ -8,7 +8,6 @@ features: [Temporal] ---*/ const zdt = Temporal.Now.zonedDateTimeISO(); -const tz = Temporal.Now.timeZoneId(); assert(zdt instanceof Temporal.ZonedDateTime); -assert.sameValue(zdt.getISOFields().calendar, "iso8601", "calendar slot should store a string"); -assert.sameValue(zdt.getISOFields().timeZone, tz, "time zone slot should store a string"); +assert.sameValue(zdt.calendarId, "iso8601", "calendar string should be iso8601"); +assert.sameValue(zdt.timeZoneId, Temporal.Now.timeZoneId(), "time zone string should be the same as from Now"); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/time-zone-undefined.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/time-zone-undefined.js index ed290b5c0c3..4bed14e13e0 100644 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/time-zone-undefined.js +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/time-zone-undefined.js @@ -4,28 +4,13 @@ /*--- esid: sec-temporal.now.zoneddatetimeiso description: Functions when time zone argument is omitted -includes: [compareArray.js] features: [Temporal] ---*/ -const actual = []; -const expected = []; - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return undefined; - }, -}); - const systemTimeZone = Temporal.Now.timeZoneId(); const resultExplicit = Temporal.Now.zonedDateTimeISO(undefined); -assert.sameValue(resultExplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string"); - -assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called"); +assert.sameValue(resultExplicit.timeZoneId, systemTimeZone, "time zone string should be the system time zone"); const resultImplicit = Temporal.Now.zonedDateTimeISO(); -assert.sameValue(resultImplicit.getISOFields().timeZone, systemTimeZone, "time zone slot should store a string"); - -assert.compareArray(actual, expected, "Temporal.TimeZone.from should not be called"); +assert.sameValue(resultImplicit.timeZoneId, systemTimeZone, "time zone string should be the system time zone"); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-object.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-object.js deleted file mode 100644 index 36be882fbf6..00000000000 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-object.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.now.zoneddatetime -description: Observable interactions with the provided timezone-like object -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Proxy, Temporal] ----*/ -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", -]; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor(instant) { - assert.sameValue( - instant instanceof Temporal.Instant, - true, - 'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true' - ); - - return -Number(instant.epochNanoseconds % 86400000000000n); - } -}); - -Object.defineProperty(Temporal.TimeZone, 'from', { - get() { - actual.push('get Temporal.TimeZone.from'); - return undefined; - } -}); - -Temporal.Now.zonedDateTimeISO(timeZone); -assert.compareArray(actual, expected, 'order of observable operations'); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js index 4833b11bbda..dc4605029ce 100644 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.now.zoneddatetimeiso -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string.js index 9ec4d1b278f..1f74bb6ec15 100644 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string.js +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-string.js @@ -4,31 +4,10 @@ /*--- esid: sec-temporal.now.zoneddatetimeiso description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - ["UTC", "+01:30"].forEach((timeZone) => { const result = Temporal.Now.zonedDateTimeISO(timeZone); - assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`); + assert.sameValue(result.timeZoneId, timeZone, `Time zone created from string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-wrong-type.js b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-wrong-type.js index d3475fd48e3..318fad42851 100644 --- a/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-wrong-type.js +++ b/test/built-ins/Temporal/Now/zonedDateTimeISO/timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.now.zoneddatetimeiso description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -28,8 +28,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDate/basic.js b/test/built-ins/Temporal/PlainDate/basic.js index 36f65021b6b..9868ad38ea9 100644 --- a/test/built-ins/Temporal/PlainDate/basic.js +++ b/test/built-ins/Temporal/PlainDate/basic.js @@ -8,18 +8,6 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - -const calendar = new Temporal.Calendar("iso8601"); -const plainDateWithObject = new Temporal.PlainDate(2020, 12, 24, calendar); -TemporalHelpers.assertPlainDate(plainDateWithObject, 2020, 12, "M12", 24, "with object"); -assert.sameValue(plainDateWithObject.getCalendar(), calendar); - -const plainDateWithString = new Temporal.PlainDate(2020, 12, 24, "iso8601"); -TemporalHelpers.assertPlainDate(plainDateWithString, 2020, 12, "M12", 24, "with string"); -assert.sameValue(plainDateWithString.getISOFields().calendar, "iso8601", "calendar slot should store a string"); -assert.notSameValue(plainDateWithString.getCalendar(), calendar); +const plainDate = new Temporal.PlainDate(2020, 12, 24, "iso8601"); +TemporalHelpers.assertPlainDate(plainDate, 2020, 12, "M12", 24, "with string"); +assert.sameValue(plainDate.calendarId, "iso8601", "calendar string is iso8601"); diff --git a/test/built-ins/Temporal/PlainDate/calendar-iso-string.js b/test/built-ins/Temporal/PlainDate/calendar-iso-string.js new file mode 100644 index 00000000000..444815b189d --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/calendar-iso-string.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.constructor +description: An ISO string is not valid input for a constructor's calendar param +features: [Temporal] +---*/ + +assert.throws( + RangeError, + () => new Temporal.PlainDate(2000, 5, 2, "1997-12-04[u-ca=iso8601]"), + "An ISO string is not a valid calendar ID for constructor parameter" +); diff --git a/test/built-ins/Temporal/PlainDate/calendar-string.js b/test/built-ins/Temporal/PlainDate/calendar-string.js index 228b6e94897..c67c3e3f6c8 100644 --- a/test/built-ins/Temporal/PlainDate/calendar-string.js +++ b/test/built-ins/Temporal/PlainDate/calendar-string.js @@ -10,4 +10,4 @@ features: [Temporal] const arg = "iso8601"; const result = new Temporal.PlainDate(2000, 5, 2, arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/PlainDate/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/calendar-temporal-object.js deleted file mode 100644 index 57d527fb38b..00000000000 --- a/test/built-ins/Temporal/PlainDate/calendar-temporal-object.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const result = new Temporal.PlainDate(2000, 5, 2, arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/PlainDate/calendar-undefined.js b/test/built-ins/Temporal/PlainDate/calendar-undefined.js index bd0f7e5dd67..a8b135d318c 100644 --- a/test/built-ins/Temporal/PlainDate/calendar-undefined.js +++ b/test/built-ins/Temporal/PlainDate/calendar-undefined.js @@ -9,14 +9,8 @@ features: [Temporal] const args = [2020, 12, 24]; -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - const dateExplicit = new Temporal.PlainDate(...args, undefined); -assert.sameValue(dateExplicit.getISOFields().calendar, "iso8601", "calendar slot should store string"); +assert.sameValue(dateExplicit.calendarId, "iso8601", "calendar string is iso8601"); const dateImplicit = new Temporal.PlainDate(...args); -assert.sameValue(dateImplicit.getISOFields().calendar, "iso8601", "calendar slot should store string"); +assert.sameValue(dateImplicit.calendarId, "iso8601", "calendar string is iso8601"); diff --git a/test/built-ins/Temporal/PlainDate/calendar-wrong-type.js b/test/built-ins/Temporal/PlainDate/calendar-wrong-type.js index 294267ecba4..0555387dc04 100644 --- a/test/built-ins/Temporal/PlainDate/calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plaindate description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar + for Calendar features: [BigInt, Symbol, Temporal] ---*/ @@ -27,9 +27,8 @@ for (const [arg, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [arg, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDate/compare/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index c4d1fcdd408..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.compare -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18)); -Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDate/compare/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index c7820420f4e..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.compare -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const arg1 = { year: 2000, month: 5, day: 2, calendar }; -const arg2 = new Temporal.PlainDate(1976, 11, 18); - -Temporal.PlainDate.compare(arg1, arg2); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar (first argument)"); - -calendar.dateFromFieldsCallCount = 0; - -Temporal.PlainDate.compare(arg2, arg1); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar (first argument)"); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/compare/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 999aea9bc6d..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.compare -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18))); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/compare/argument-duplicate-calendar-fields.js deleted file mode 100644 index 067cb5aa6d4..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.compare -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - - assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18))); - assert.throws(RangeError, () => Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg)); -} diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-string.js index 0556a490be6..c400baee24a 100644 --- a/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-string.js @@ -4,19 +4,9 @@ /*--- esid: sec-temporal.plaindate.compare description: A calendar ID is valid input for Calendar -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - const calendar = "iso8601"; const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; @@ -26,5 +16,3 @@ assert.sameValue(result1, 0, `Calendar created from string "${arg}" (first argum const result2 = Temporal.PlainDate.compare(new Temporal.PlainDate(1976, 11, 18), arg); assert.sameValue(result2, 0, `Calendar created from string "${arg}" (second argument)`); - -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-wrong-type.js index d2181107483..2c74354e9dc 100644 --- a/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/compare/argument-propertybag-calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plaindate.compare description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ @@ -33,10 +33,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/compare/argument-proto-in-calendar-fields.js deleted file mode 100644 index 142e1034880..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.compare -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainDate.compare(arg, new Temporal.PlainDate(1976, 11, 18))); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index ffa6b96aa56..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.compare -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, Infinity, -Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const date = new Temporal.PlainDate(2000, 5, 2); - - assert.throws(RangeError, () => Temporal.PlainDate.compare(datetime, date)); - assert.throws(RangeError, () => Temporal.PlainDate.compare(date, datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 2c28bf9a6f3..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.compare -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const date = new Temporal.PlainDate(2000, 5, 2); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.PlainDate.compare(datetime, date), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); - assert.throws( - TypeError, - () => Temporal.PlainDate.compare(date, datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 3d6523e833a..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.compare -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const date = new Temporal.PlainDate(2000, 5, 2); - - assert.throws(RangeError, () => Temporal.PlainDate.compare(datetime, date)); - assert.throws(RangeError, () => Temporal.PlainDate.compare(date, datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index bf475a329e3..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.compare -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const date = new Temporal.PlainDate(2000, 5, 2); - - assert.throws(TypeError, () => Temporal.PlainDate.compare(datetime, date)); - assert.throws(TypeError, () => Temporal.PlainDate.compare(date, datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/compare/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainDate/compare/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index e874d00f7cc..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.compare -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -Temporal.PlainDate.compare({ year: 2000, month: 5, day: 2, calendar }, { year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 2); diff --git a/test/built-ins/Temporal/PlainDate/compare/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDate/compare/calendar-fields-iterable.js deleted file mode 100644 index e99862540f3..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/calendar-fields-iterable.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.compare -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindate.compare steps 1–2: - 1. Set _one_ to ? ToTemporalDate(_one_). - 2. Set _two_ to ? ToTemporalDate(_two_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -Temporal.PlainDate.compare( - { year: 2000, month: 5, day: 2, calendar: calendar1 }, - { year: 2001, month: 6, day: 3, calendar: calendar2 }, -); - -assert.sameValue(calendar1.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar1.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar1.iteratorExhausted[0], "iterated through the whole iterable"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDate/compare/calendar.js b/test/built-ins/Temporal/PlainDate/compare/calendar.js deleted file mode 100644 index 250bffa98cd..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/calendar.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.compare -description: basic tests -features: [Temporal] ----*/ - -class CalendarTraceToString extends Temporal.Calendar { - constructor(id) { - super("iso8601"); - this.id_ = id; - this.calls = 0; - } - toString() { - ++this.calls; - return this.id_; - } -}; - -const calendar1 = new CalendarTraceToString("a"); -const date1 = new Temporal.PlainDate(1914, 2, 23, calendar1); - -const calendar2 = new CalendarTraceToString("a"); -const date2 = new Temporal.PlainDate(1914, 2, 23, calendar2); - -const calendar3 = new CalendarTraceToString("b"); -const date3 = new Temporal.PlainDate(1914, 2, 23, calendar3); - -assert.sameValue(Temporal.PlainDate.compare(date1, date1), 0, "same object"); -assert.sameValue(Temporal.PlainDate.compare(date1, date2), 0, "same date"); -assert.sameValue(Temporal.PlainDate.compare(date1, date3), 0, "same date, different calendar"); - -assert.sameValue(calendar1.calls, 0, "calendar1 toString() calls"); -assert.sameValue(calendar2.calls, 0, "calendar2 toString() calls"); -assert.sameValue(calendar3.calls, 0, "calendar3 toString() calls"); diff --git a/test/built-ins/Temporal/PlainDate/compare/exhaustive.js b/test/built-ins/Temporal/PlainDate/compare/exhaustive.js deleted file mode 100644 index acce9f7169f..00000000000 --- a/test/built-ins/Temporal/PlainDate/compare/exhaustive.js +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.compare -description: Tests for compare() with each possible outcome -features: [Temporal] ----*/ - -const cal1 = "iso8601"; -const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601"); - -assert.sameValue( - Temporal.PlainDate.compare( - new Temporal.PlainDate(2000, 5, 31, cal1), - new Temporal.PlainDate(1987, 5, 31, cal2) - ), - 1, - "year >" -); -assert.sameValue( - Temporal.PlainDate.compare( - new Temporal.PlainDate(1981, 12, 15, cal1), - new Temporal.PlainDate(2048, 12, 15, cal2) - ), - -1, - "year <" -); -assert.sameValue( - Temporal.PlainDate.compare( - new Temporal.PlainDate(2000, 5, 31, cal1), - new Temporal.PlainDate(2000, 3, 31, cal2) - ), - 1, - "month >" -); -assert.sameValue( - Temporal.PlainDate.compare( - new Temporal.PlainDate(1981, 4, 15, cal1), - new Temporal.PlainDate(1981, 12, 15, cal2) - ), - -1, - "month <" -); -assert.sameValue( - Temporal.PlainDate.compare( - new Temporal.PlainDate(2000, 5, 31, cal1), - new Temporal.PlainDate(2000, 5, 14, cal2) - ), - 1, - "day >" -); -assert.sameValue( - Temporal.PlainDate.compare( - new Temporal.PlainDate(1981, 4, 15, cal1), - new Temporal.PlainDate(1981, 4, 21, cal2) - ), - -1, - "day <" -); -assert.sameValue( - Temporal.PlainDate.compare( - new Temporal.PlainDate(2000, 5, 31, cal1), - new Temporal.PlainDate(2000, 5, 31, cal2) - ), - 0, - "=" -); diff --git a/test/built-ins/Temporal/PlainDate/compare/not-same-object.js b/test/built-ins/Temporal/PlainDate/compare/not-same-object.js new file mode 100644 index 00000000000..0ddb8b98c65 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/not-same-object.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.compare +description: Dates are equal even if they are not the same object +features: [Temporal] +---*/ + +const date1 = new Temporal.PlainDate(1914, 2, 23); +const date2 = new Temporal.PlainDate(1914, 2, 23); + +assert.sameValue(Temporal.PlainDate.compare(date1, date1), 0, "same object"); +assert.sameValue(Temporal.PlainDate.compare(date1, date2), 0, "same date"); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDate/from/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index bac3f0a25be..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.from -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -Temporal.PlainDate.from(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDate/from/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDate/from/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index e2061e81b43..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.from -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const arg = { year: 2000, month: 5, day: 2, calendar }; -Temporal.PlainDate.from(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/from/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 46dbb7603b4..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.from -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainDate.from(arg)); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/from/argument-duplicate-calendar-fields.js deleted file mode 100644 index f49238d08cb..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.from -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - - assert.throws(RangeError, () => Temporal.PlainDate.from(arg)); -} diff --git a/test/built-ins/Temporal/PlainDate/from/argument-plaindate.js b/test/built-ins/Temporal/PlainDate/from/argument-plaindate.js index e0ac9111e05..2aada085b0b 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-plaindate.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-plaindate.js @@ -17,7 +17,7 @@ TemporalHelpers.assertPlainDate( "PlainDate is copied" ); -assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied"); +assert.sameValue(result.calendarId, orig.calendarId, "Calendar is copied"); assert.notSameValue( result, diff --git a/test/built-ins/Temporal/PlainDate/from/argument-plaindatetime.js b/test/built-ins/Temporal/PlainDate/from/argument-plaindatetime.js index 498037c245f..8d7c7faa662 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-plaindatetime.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-plaindatetime.js @@ -14,8 +14,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime, calendar) => { +TemporalHelpers.checkPlainDateTimeConversionFastPath((datetime) => { const result = Temporal.PlainDate.from(datetime); TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2); - assert.sameValue(result.getCalendar(), calendar, "calendar result"); }); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-iso-string.js index 0b02a975098..1b8830688af 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-iso-string.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-iso-string.js @@ -21,5 +21,5 @@ for (const calendar of [ const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; const result = Temporal.PlainDate.from(arg); TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, `Calendar created from string "${calendar}"`); - assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); + assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); } diff --git a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-string.js index 72bea4c95a6..c8075d64b96 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-string.js @@ -13,4 +13,4 @@ const calendar = "iso8601"; const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; const result = Temporal.PlainDate.from(arg); TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, `Calendar created from string "${calendar}"`); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-wrong-type.js index 0d26ebb5660..c6a2bdfc9b1 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plaindate.from description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ @@ -28,10 +28,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar.js b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar.js index c1b6eb5de30..73ad36b8204 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-propertybag-calendar.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const calendar = new Temporal.Calendar("iso8601"); +const calendar = "iso8601"; const plainDate = Temporal.PlainDate.from({ year: 1976, month: 11, day: 18, calendar }); TemporalHelpers.assertPlainDate(plainDate, 1976, 11, "M11", 18); -assert.sameValue(plainDate.getISOFields().calendar, "iso8601", "calendar slot should store a string"); +assert.sameValue(plainDate.calendarId, "iso8601", "calendar string is iso8601"); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/from/argument-proto-in-calendar-fields.js deleted file mode 100644 index f350e499664..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.from -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainDate.from(arg)); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-convert.js deleted file mode 100644 index 658e86c7201..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.from -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.PlainDate(1976, 11, 18); - -assert.throws(Test262Error, () => Temporal.PlainDate.from(arg)); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 2564660e585..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.from -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => Temporal.PlainDate.from(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index d272c5a2b65..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.from -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.PlainDate.from(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index a1d2f1b7d59..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.from -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => Temporal.PlainDate.from(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 9866661ac0b..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.from -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => Temporal.PlainDate.from(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime.js b/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime.js index 6288a5e7822..8ae3cf5989a 100644 --- a/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime.js +++ b/test/built-ins/Temporal/PlainDate/from/argument-zoneddatetime.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const calendar = new Temporal.Calendar("iso8601"); +const calendar = "iso8601"; const zdt = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); const result = Temporal.PlainDate.from(zdt); @@ -19,7 +19,7 @@ TemporalHelpers.assertPlainDate( ); assert.sameValue( - result.getCalendar(), + result.calendarId, calendar, "Calendar is copied" ); diff --git a/test/built-ins/Temporal/PlainDate/from/calendar-fields-custom.js b/test/built-ins/Temporal/PlainDate/from/calendar-fields-custom.js deleted file mode 100644 index bf3686bed08..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/calendar-fields-custom.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.from -description: Verify the result of calendar.fields() is treated correctly. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateFromFields(fields) { - assert.compareArray(Object.keys(fields), ["a", "b"]); - return new Temporal.PlainDate(2020, 7, 4); - } - fields(fields) { - assert.compareArray(fields, ["day", "month", "monthCode", "year"]); - return ["b", "a"]; - } -} - -const calendar = new CustomCalendar(); -const actual = []; -const item = TemporalHelpers.propertyBagObserver(actual, { calendar }, "item"); - -const plainDate = Temporal.PlainDate.from(item); -TemporalHelpers.assertPlainDate(plainDate, 2020, 7, "M07", 4); -assert.compareArray(actual, [ - "get item.calendar", - "get item.a", - "get item.b", -]); diff --git a/test/built-ins/Temporal/PlainDate/from/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDate/from/calendar-fields-iterable.js deleted file mode 100644 index a693fe09bc2..00000000000 --- a/test/built-ins/Temporal/PlainDate/from/calendar-fields-iterable.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.from -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindate.from step 3: - 3. Return ? ToTemporalDate(_item_, _options_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -Temporal.PlainDate.from({ year: 2000, month: 5, day: 2, calendar }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDate/from/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/from/calendar-temporal-object.js index 8960848b0cc..7739b04dff9 100644 --- a/test/built-ins/Temporal/PlainDate/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDate/from/calendar-temporal-object.js @@ -20,7 +20,6 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2, calendar: temporalObject }); - assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-primitive.js index e1dcc6795f6..d17e3269ed8 100644 --- a/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-primitive.js +++ b/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-primitive.js @@ -9,8 +9,6 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", @@ -25,9 +23,9 @@ TemporalHelpers.assertPlainDate(result, 2021, 5, "M05", 17); actual.splice(0); // empty it for the next check const failureExpected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", ]; assert.throws(TypeError, () => Temporal.PlainDate.from(7, options)); diff --git a/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string-invalid.js index f3789e814d3..b5fc45c02af 100644 --- a/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string-invalid.js +++ b/test/built-ins/Temporal/PlainDate/from/observable-get-overflow-argument-string-invalid.js @@ -9,9 +9,9 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", ]; let actual = []; diff --git a/test/built-ins/Temporal/PlainDate/from/one-of-era-erayear-undefined.js b/test/built-ins/Temporal/PlainDate/from/one-of-era-erayear-undefined.js new file mode 100644 index 00000000000..1ce0e936a3f --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/one-of-era-erayear-undefined.js @@ -0,0 +1,15 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.from +description: Does not throw a RangeError if only one of era/eraYear fields is present +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const base = { year: 2000, month: 5, day: 2, era: 'ce' }; +TemporalHelpers.assertPlainDate(Temporal.PlainDate.from(base), 2000, 5, 'M05', 2); + +const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 }; +TemporalHelpers.assertPlainDate(Temporal.PlainDate.from(base2), 2000, 5, 'M05', 2); diff --git a/test/built-ins/Temporal/PlainDate/from/order-of-operations.js b/test/built-ins/Temporal/PlainDate/from/order-of-operations.js index 3f53d094478..257bfda34a4 100644 --- a/test/built-ins/Temporal/PlainDate/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/from/order-of-operations.js @@ -9,36 +9,10 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", - "getOwnPropertyDescriptor options.extra", - "get options.extra", + "get options.overflow.toString", + "call options.overflow.toString", "get fields.calendar", - "has fields.calendar.dateAdd", - "has fields.calendar.dateFromFields", - "has fields.calendar.dateUntil", - "has fields.calendar.day", - "has fields.calendar.dayOfWeek", - "has fields.calendar.dayOfYear", - "has fields.calendar.daysInMonth", - "has fields.calendar.daysInWeek", - "has fields.calendar.daysInYear", - "has fields.calendar.fields", - "has fields.calendar.id", - "has fields.calendar.inLeapYear", - "has fields.calendar.mergeFields", - "has fields.calendar.month", - "has fields.calendar.monthCode", - "has fields.calendar.monthDayFromFields", - "has fields.calendar.monthsInYear", - "has fields.calendar.weekOfYear", - "has fields.calendar.year", - "has fields.calendar.yearMonthFromFields", - "has fields.calendar.yearOfWeek", - "get fields.calendar.dateFromFields", - "get fields.calendar.fields", - "call fields.calendar.fields", "get fields.day", "get fields.day.valueOf", "call fields.day.valueOf", @@ -51,21 +25,16 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", - "call fields.calendar.dateFromFields", - // inside Calendar.p.dateFromFields - "get options.overflow.toString", - "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "fields.calendar"); const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7, month: 1.7, monthCode: "M01", day: 1.7, - calendar, -}, "fields"); + calendar: "iso8601", +}, "fields", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", diff --git a/test/built-ins/Temporal/PlainDate/from/out-of-range.js b/test/built-ins/Temporal/PlainDate/from/out-of-range.js new file mode 100644 index 00000000000..e15d330cf73 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/out-of-range.js @@ -0,0 +1,88 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.plaindate.from +description: Should throw RangeError for input not in valid range. +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(fields) is not Object, throw a TypeError exception. + 5. Set options to ? GetOptionsObject(options). + 6. Let result be ? ISODateFromFields(fields, options). + 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). +features: [Temporal, arrow-function] +---*/ + +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, monthCode: "m1", day: 17})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, monthCode: "M1", day: 17})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, monthCode: "m01", day: 17})); + +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 12, monthCode: "M11", day: 17})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, monthCode: "M00", day: 17})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, monthCode: "M19", day: 17})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, monthCode: "M99", day: 17})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, monthCode: "M13", day: 17})); + +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: -1, day: 17})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: -Infinity, day: 17})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 7, day: -17})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 7, day: -Infinity})); + +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 12, day: 0}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 12, day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 1, day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 2, day: 29}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 6, day: 31}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 9, day: 31}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 0, day: 5}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from({year: 2021, month: 13, day: 5}, {overflow: "reject"})); + +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, monthCode: "M12", day: 0}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, monthCode: "M12", day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, monthCode: "M01", day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, monthCode: "M02", day: 29}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, monthCode: "M06", day: 31}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, monthCode: "M09", day: 31}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, monthCode: "M00", day: 5}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, monthCode: "M13", day: 5}, {overflow: "reject"})); + +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 12, day: 0})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 0, day: 3})); + +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 1, day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 2, day: 29}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 3, day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 4, day: 31}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 5, day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 6, day: 31}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 7, day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 8, day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 9, day: 31}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 10, day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 11, day: 31}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 12, day: 32}, {overflow: "reject"})); +assert.throws(RangeError, () => Temporal.PlainDate.from( + {year: 2021, month: 13, day: 5}, {overflow: "reject"})); diff --git a/test/built-ins/Temporal/PlainDate/from/with-year-month-day-need-constrain.js b/test/built-ins/Temporal/PlainDate/from/with-year-month-day-need-constrain.js new file mode 100644 index 00000000000..320e96e52c8 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/with-year-month-day-need-constrain.js @@ -0,0 +1,86 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.plaindate.from +description: Property bag with year/month/day and need constrain +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(fields) is not Object, throw a TypeError exception. + 5. Set options to ? GetOptionsObject(options). + 6. Let result be ? ISODateFromFields(fields, options). + 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 1, day: 133}), + 2021, 1, "M01", 31, + "year/month/day with day need to be constrained in Jan"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 2, day: 133}), + 2021, 2, "M02", 28, + "year/month/day with day need to be constrained in Feb"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 3, day: 133}), + 2021, 3, "M03", 31, + "year/month/day with day need to be constrained in March"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 4, day: 133}), + 2021, 4, "M04", 30, + "year/month/day with day need to be constrained in April"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 5, day: 133}), + 2021, 5, "M05", 31, + "year/month/day with day need to be constrained in May"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 6, day: 133}), + 2021, 6, "M06", 30, + "year/month/day with day need to be constrained in Jun"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 7, day: 133}), + 2021, 7, "M07", 31, + "year/month/day with day need to be constrained in July"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 8, day: 133}), + 2021, 8, "M08", 31, + "year/month/day with day need to be constrained in Aug"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 9, day: 133}), + 2021, 9, "M09", 30, + "year/month/day with day need to be constrained in Sept."); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 10, day: 133}), + 2021, 10, "M10", 31, + "year/month/day with day need to be constrained in Oct."); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 11, day: 133}), + 2021, 11, "M11", 30, + "year/month/day with day need to be constrained in Nov."); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 12, day: 133}), + 2021, 12, "M12", 31, + "year/month/day with day need to be constrained in Dec."); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 13, day: 500}), + 2021, 12, "M12", 31, + "year/month/day with month and day need to be constrained"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, month: 999999, day: 500}), + 2021, 12, "M12", 31, + "year/month/day with month and day need to be constrained"); diff --git a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-month-day.js b/test/built-ins/Temporal/PlainDate/from/with-year-month-day.js similarity index 75% rename from test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-month-day.js rename to test/built-ins/Temporal/PlainDate/from/with-year-month-day.js index cc7bdad2eaa..87068fd4ed9 100644 --- a/test/built-ins/Temporal/Calendar/prototype/dateFromFields/with-year-month-day.js +++ b/test/built-ins/Temporal/PlainDate/from/with-year-month-day.js @@ -1,8 +1,8 @@ // Copyright (C) 2021 the V8 project authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Temporal.Calendar.prototype.dateFromFields with year/month/day +esid: sec-temporal.plaindate.from +description: With year/month/day info: | 1. Let calendar be the this value. 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). @@ -14,9 +14,8 @@ info: | features: [Temporal] includes: [temporalHelpers.js] ---*/ -let cal = new Temporal.Calendar("iso8601") TemporalHelpers.assertPlainDate( - cal.dateFromFields({year: 2021, month: 7, day: 15}), + Temporal.PlainDate.from({year: 2021, month: 7, day: 15}), 2021, 7, "M07", 15, "year/month/day"); diff --git a/test/built-ins/Temporal/PlainDate/from/with-year-monthCode-day-need-constrain.js b/test/built-ins/Temporal/PlainDate/from/with-year-monthCode-day-need-constrain.js new file mode 100644 index 00000000000..07378b40639 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/with-year-monthCode-day-need-constrain.js @@ -0,0 +1,76 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.plaindate.from +description: With year, monthCode and day and need constrain +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(fields) is not Object, throw a TypeError exception. + 5. Set options to ? GetOptionsObject(options). + 6. Let result be ? ISODateFromFields(fields, options). + 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M01", day: 133}), + 2021, 1, "M01", 31, + "year/monthCode/day with day need to be constrained in Jan"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M02", day: 133}), + 2021, 2, "M02", 28, + "year/monthCode/day with day need to be constrained in Feb"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M03", day: 133}), + 2021, 3, "M03", 31, + "year/monthCode/day with day need to be constrained in March"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M04", day: 133}), + 2021, 4, "M04", 30, + "year/monthCode/day with day need to be constrained in April"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M05", day: 133}), + 2021, 5, "M05", 31, + "year/monthCode/day with day need to be constrained in May"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M06", day: 133}), + 2021, 6, "M06", 30, + "year/monthCode/day with day need to be constrained in Jun"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M07", day: 133}), + 2021, 7, "M07", 31, + "year/monthCode/day with day need to be constrained in July"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M08", day: 133}), + 2021, 8, "M08", 31, + "year/monthCode/day with day need to be constrained in Aug"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M09", day: 133}), + 2021, 9, "M09", 30, + "year/monthCode/day with day need to be constrained in Sept."); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M10", day: 133}), + 2021, 10, "M10", 31, + "year/monthCode/day with day need to be constrained in Oct."); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M11", day: 133}), + 2021, 11, "M11", 30, + "year/monthCode/day with day need to be constrained in Nov."); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M12", day: 133}), + 2021, 12, "M12", 31, + "year/monthCode/day with day need to be constrained in Dec."); diff --git a/test/built-ins/Temporal/PlainDate/from/with-year-monthCode-day.js b/test/built-ins/Temporal/PlainDate/from/with-year-monthCode-day.js new file mode 100644 index 00000000000..2bb09d1dfb2 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/with-year-monthCode-day.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.plaindate.from +description: Property bag with year, monthCode and day +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(fields) is not Object, throw a TypeError exception. + 5. Set options to ? GetOptionsObject(options). + 6. Let result be ? ISODateFromFields(fields, options). + 7. Return ? CreateTemporalDate(result.[[Year]], result.[[Month]], result.[[Day]], calendar). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from({year: 2021, monthCode: "M07", day: 15}), + 2021, 7, "M07", 15, + "year/monthCode/day"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/add-days.js b/test/built-ins/Temporal/PlainDate/prototype/add/add-days.js new file mode 100644 index 00000000000..f629e919247 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/add-days.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Add duration with days and calculate correctly +info: | + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +let p10d = new Temporal.Duration(0,0,0,10); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-07-16").add(p10d), 2021, 7, "M07", 26, + "add 10 days and result into the same month"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-07-26").add(p10d), 2021, 8, "M08", 5, + "add 10 days and result into next month"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-12-26").add(p10d), 2022, 1, "M01", 5, + "add 10 days and result into next year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-26").add(p10d), 2020, 3, "M03", 7, + "add 10 days from a leap year in Feb and result into March"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-26").add(p10d), 2021, 3, "M03", 8, + "add 10 days from a non leap year in Feb and result into March"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-19").add(p10d), 2020, 2, "M02", 29, + "add 10 days from a leap year in Feb 19 and result into Feb 29"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-19").add(p10d), 2021, 3, "M03", 1, + "add 10 days from a non leap year in Feb 19 and result into March 1"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/add-months-weeks.js b/test/built-ins/Temporal/PlainDate/prototype/add/add-months-weeks.js new file mode 100644 index 00000000000..c9ba250f33a --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/add-months-weeks.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Add duration with months and weeks and calculate correctly +info: | + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +let p2m3w = new Temporal.Duration(0,2,3); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-29").add(p2m3w), 2020, 5, "M05", 20, + "add two months 3 weeks from Feb 29 of a leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-28").add(p2m3w), 2020, 5, "M05", 19, + "add two months 3 weeks from Feb 28 of a leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-28").add(p2m3w), 2021, 5, "M05", 19, + "add two months 3 weeks from Feb 28 of a non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-12-28").add(p2m3w), 2021, 3, "M03", 21, + "add two months 3 weeks from end of year to non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2019-12-28").add(p2m3w), 2020, 3, "M03", 20, + "add two months 3 weeks from end of year to leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2019-10-28").add(p2m3w), 2020, 1, "M01", 18, + "add two months 3 weeks and cause roll into a new year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2019-10-31").add(p2m3w), 2020, 1, "M01", 21, + "add two months 3 weeks and cause roll into a new year"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/add-months.js b/test/built-ins/Temporal/PlainDate/prototype/add/add-months.js new file mode 100644 index 00000000000..ff6c6fc87b6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/add-months.js @@ -0,0 +1,32 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Add duration with months and calculate correctly +info: | + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +let p5m = new Temporal.Duration(0, 5); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-07-16").add(p5m), 2021, 12, "M12", 16, + "add five months and result in the same year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-08-16").add(p5m), 2022, 1, "M01", 16, + "add five months and result in the next year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-10-31").add(p5m), 2022, 3, "M03", 31, + "add five months and result in the next year in end of month"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2019-10-01").add(p5m), 2020, 3, "M03", 1, + "add five months and result in the next year in end of month on leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-09-30").add(p5m), 2022, 2, "M02", 28, + "add five months and result in the nexdt year and constrain to Feb 28"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2019-09-30").add(p5m), 2020, 2, "M02", 29, + "add five months and result in the nexdt year and constrain to Feb 29 on leap year"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/add-weeks-days.js b/test/built-ins/Temporal/PlainDate/prototype/add/add-weeks-days.js new file mode 100644 index 00000000000..bd5209697e0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/add-weeks-days.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Add duration with weeks and days and calculate correctly +info: | + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +let p2w3d = new Temporal.Duration(0,0,2,3); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-29").add(p2w3d), 2020, 3, "M03", 17, + "add 2 weeks and 3 days (17 days) from Feb 29 in a leap year and cause rolling into March"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-28").add(p2w3d), 2021, 3, "M03", 17, + "add 2 weeks and 3 days (17 days) from Feb and cause rolling into March in a non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-28").add(p2w3d), 2020, 3, "M03", 16, + "add 2 weeks and 3 days (17 days) from Feb and cause rolling into March in a leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-12-28").add(p2w3d), 2021, 1, "M01", 14, + "add 2 weeks and 3 days (17 days) and cause rolling into a new year"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/add-weeks.js b/test/built-ins/Temporal/PlainDate/prototype/add/add-weeks.js new file mode 100644 index 00000000000..edcc3adb7b0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/add-weeks.js @@ -0,0 +1,62 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Add duration with weeks and calculate correctly +info: | + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +let p1w = new Temporal.Duration(0,0,1); +let p6w = new Temporal.Duration(0,0,6); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-19").add(p1w), 2021, 2, "M02", 26, + "add one week in Feb"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-27").add(p1w), 2021, 3, "M03", 6, + "add one week in Feb and result in March"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-27").add(p1w), 2020, 3, "M03", 5, + "add one week in Feb and result in March in a leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-12-24").add(p1w), 2021, 12, "M12", 31, + "add one week and result in the last day of a year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-12-25").add(p1w), 2022, 1, "M01", 1, + "add one week and result in the first day of next year"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-01-27").add(p1w), 2021, 2, "M02", 3, + "add one week and result in next month from a month with 31 days"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-06-27").add(p1w), 2021, 7, "M07", 4, + "add one week and result in next month from a month with 30 days"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-07-27").add(p1w), 2021, 8, "M08", 3, + "add one week and result in next month from a month with 31 days"); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-19").add(p6w), 2021, 4, "M04", 2, + "add six weeks and result in next month from Feb in a non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-19").add(p6w), 2020, 4, "M04", 1, + "add six weeks and result in next month from Feb in a leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-12-24").add(p6w), 2022, 2, "M02", 4, + "add six weeks and result in the next year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-01-27").add(p6w), 2021, 3, "M03", 10, + "add six weeks and result in the same year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-01-27").add(p6w), 2020, 3, "M03", 9, + "add six weeks and result in the same year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-06-27").add(p6w), 2021, 8, "M08", 8, + "add six weeks and result in the same year crossing month of 30 and 31 days"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-07-27").add(p6w), 2021, 9, "M09", 7, + "add six weeks and result in the same year crossing month of 31 and 31 days"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/add-years-months-days.js b/test/built-ins/Temporal/PlainDate/prototype/add/add-years-months-days.js new file mode 100644 index 00000000000..58d41e76dba --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/add-years-months-days.js @@ -0,0 +1,44 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Add duration with years, months and days and calculate correctly +info: | + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +let p1y2m4d = new Temporal.Duration(1,2,0,4); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-07-16").add(p1y2m4d), 2022, 9, "M09", 20, + "add one year two months and 4 days"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-27").add(p1y2m4d), 2022, 5, "M05", 1, + "add one year two months and 4 days and roll into new month from a month of 30 days"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-01-28").add(p1y2m4d), 2022, 4, "M04", 1, + "add one year two months and 4 days and roll into new month from a month of 31 days"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-26").add(p1y2m4d), 2022, 4, "M04", 30, + "add one year two months and 4 days which roll from March to April in a non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2023-02-26").add(p1y2m4d), 2024, 4, "M04", 30, + "add one year two months and 4 days which roll from March to April in a leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-12-30").add(p1y2m4d), 2023, 3, "M03", 4, + "add one year two months and 4 days which roll month into new year and roll day into March in non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2022-12-30").add(p1y2m4d), 2024, 3, "M03", 4, + "add one year two months and 4 days which roll month into new year and roll day into March in leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2022-12-29").add(p1y2m4d), 2024, 3, "M03", 4, + "add one year two months and 4 days which roll month into new year and roll day into March in leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-07-30").add(p1y2m4d), 2022, 10, "M10", 4, + "add one year two months and 4 days which roll into a new month from a month with 30 days"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-06-30").add(p1y2m4d), 2022, 9, "M09", 3, + "add one year two months and 4 days which roll into a new month from a month with 31 days"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/add-years-months.js b/test/built-ins/Temporal/PlainDate/prototype/add/add-years-months.js new file mode 100644 index 00000000000..2e9e5c46858 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/add-years-months.js @@ -0,0 +1,26 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Add duration with years and months and calculate correctly +info: | + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +let p1y2m = new Temporal.Duration(1,2); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-07-16").add(p1y2m), 2022, 9, "M09", 16, + "add one year and 2 months"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-11-30").add(p1y2m), 2023, 1, "M01", 30, + "add one year and 2 months roll into a new year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-12-31").add(p1y2m), 2023, 2, "M02", 28, + "add one year and 2 months roll into a new year and constrain in Feb 28 of a non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2022-12-31").add(p1y2m), 2024, 2, "M02", 29, + "add one year and 2 months roll into a new year and constrain in Feb 29 of a leap year"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/add-years-weeks.js b/test/built-ins/Temporal/PlainDate/prototype/add/add-years-weeks.js new file mode 100644 index 00000000000..81288ff4915 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/add-years-weeks.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Add duration with years and weeks and calculate correctly +info: | + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +let p1y2w = new Temporal.Duration(1,0,2); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-28").add(p1y2w), 2021, 3, "M03", 14, + "add 1 year and 2 weeks to Feb 28 and cause roll into March in a non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-29").add(p1y2w), 2021, 3, "M03", 14, + "add 1 year and 2 weeks to Feb 29 and cause roll into March in a non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2019-02-28").add(p1y2w), 2020, 3, "M03", 13, + "add 1 year and 2 weeks to Feb 28 and cause roll into March in a leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-02-28").add(p1y2w), 2022, 3, "M03", 14, + "add 1 year and 2 weeks to Feb 28 and cause roll into March in a non leap year"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-12-28").add(p1y2w), 2022, 1, "M01", 11, + "add 1 year and 2 weeks and cause roll into a new year"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/add-years.js b/test/built-ins/Temporal/PlainDate/prototype/add/add-years.js new file mode 100644 index 00000000000..f414dda2d8f --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/add-years.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Add duration with years only calculate correctly +info: | + 8. Let result be ? AddISODate(date.[[ISOYear]], date.[[ISOMonth]], date.[[ISODay]], duration.[[Years]], duration.[[Months]], duration.[[Weeks]], duration.[[Days]], overflow). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +let p1y = new Temporal.Duration(1); +let p4y = new Temporal.Duration(4); + +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-29").add(p1y), 2021, 2, "M02", 28, + "add one year on Feb 29"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2020-02-29").add(p4y), 2024, 2, "M02", 29, + "add four years on Feb 29"); +TemporalHelpers.assertPlainDate( + Temporal.PlainDate.from("2021-07-16").add(p1y), 2022, 7, "M07", 16, + "add one year on other date"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/argument-string-invalid.js b/test/built-ins/Temporal/PlainDate/prototype/add/argument-string-invalid.js new file mode 100644 index 00000000000..abe66bf8f1c --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/add/argument-string-invalid.js @@ -0,0 +1,16 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.add +description: Throws RangeError when duration string is invalid +info: | + ... + 5. Set duration to ? ToTemporalDuration(duration). +features: [Temporal, arrow-function] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); +assert.throws(RangeError, + () => instance.add("invalid duration string"), + "invalid duration string causes a RangeError"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/argument-string.js b/test/built-ins/Temporal/PlainDate/prototype/add/argument-string.js index 5abb43791bf..7f9a284af9d 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/add/argument-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/add/argument-string.js @@ -11,3 +11,5 @@ features: [Temporal] const instance = Temporal.PlainDate.from({ year: 2000, month: 5, day: 2 }); const result = instance.add("P3D"); TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 5); + +TemporalHelpers.assertPlainDate(instance.add("P1M1W"), 2000, 6, "M06", 9, "calendar units"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/add/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 2791e757fde..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/add/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.add -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.add(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/calendar-invalid-return.js b/test/built-ins/Temporal/PlainDate/prototype/add/calendar-invalid-return.js deleted file mode 100644 index 982c09edf79..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/add/calendar-invalid-return.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.add -description: Throw when the returned value from the calendar's dateAdd method is not a PlainDate. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor(value) { - super("iso8601"); - this.value = value; - } - dateAdd() { - return this.value; - } -} - -const tests = [ - [undefined], - [null, "null"], - [true], - ["2000-05"], - [Symbol()], - [200005], - [200005n], - [{}, "plain object"], - [() => {}, "lambda"], - [Temporal.PlainDate, "Temporal.PlainDate"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype"], -]; -for (const [test, description = typeof test] of tests) { - const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar(test)); - assert.throws(TypeError, () => plainDate.add({ years: 1 }), `Expected error with ${description}`); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/custom.js b/test/built-ins/Temporal/PlainDate/prototype/add/custom.js deleted file mode 100644 index 5e449dc0523..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/add/custom.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.add -description: Basic tests with custom calendar -includes: [compareArray.js,temporalHelpers.js] -features: [Temporal] ----*/ - -const result = new Temporal.PlainDate(1920, 5, 3); -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(...args) { - ++calls; - assert.sameValue(args.length, 3, "Three arguments"); - assert.sameValue(args[0], plainDate, "First argument"); - TemporalHelpers.assertDuration(args[1], 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Second argument"); - assert.sameValue(typeof args[2], "object", "Third argument: type"); - assert.sameValue(Object.getPrototypeOf(args[2]), null, "Third argument: prototype"); - assert.compareArray(Object.keys(args[2]), [], "Third argument: keys"); - return result; - } -} -const calendar = new CustomCalendar(); -const plainDate = new Temporal.PlainDate(1976, 11, 18, calendar); -assert.sameValue(plainDate.add({ years: 43 }), result); -assert.sameValue(calls, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js index c1f29fad5c4..605a2760c9a 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/add/order-of-operations.js @@ -40,20 +40,13 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", - // AddDate - "get this.calendar.dateAdd", - "call this.calendar.dateAdd", - // inside Calendar.p.dateAdd "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); const fields = TemporalHelpers.propertyBagObserver(actual, { years: 1, @@ -76,51 +69,3 @@ instance.add(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -const noCalendarExpected = [ - // ToTemporalDurationRecord - "get fields.days", - "get fields.days.valueOf", - "call fields.days.valueOf", - "get fields.hours", - "get fields.hours.valueOf", - "call fields.hours.valueOf", - "get fields.microseconds", - "get fields.microseconds.valueOf", - "call fields.microseconds.valueOf", - "get fields.milliseconds", - "get fields.milliseconds.valueOf", - "call fields.milliseconds.valueOf", - "get fields.minutes", - "get fields.minutes.valueOf", - "call fields.minutes.valueOf", - "get fields.months", - "get fields.nanoseconds", - "get fields.nanoseconds.valueOf", - "call fields.nanoseconds.valueOf", - "get fields.seconds", - "get fields.seconds.valueOf", - "call fields.seconds.valueOf", - "get fields.weeks", - "get fields.years", - "get this.calendar.dateAdd", - // AddDate - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; - -const noCalendarFields = TemporalHelpers.propertyBagObserver(actual, { - days: 1, - hours: 1, - minutes: 1, - seconds: 1, - milliseconds: 1, - microseconds: 1, - nanoseconds: 1, -}, "fields"); - -instance.add(noCalendarFields, options); -assert.compareArray(actual, noCalendarExpected, "order of operations with no calendar operation"); - -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDate/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/calendarId/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 4f655e84d46..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/calendarId/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.calendarid -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.calendarId; - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/day/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/day/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 28fccb92742..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/day/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.day -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "day"); -Object.defineProperty(Temporal.Calendar.prototype, "day", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("day should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.day; - -Object.defineProperty(Temporal.Calendar.prototype, "day", dayOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/day/custom.js b/test/built-ins/Temporal/PlainDate/prototype/day/custom.js deleted file mode 100644 index 281a825734a..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/day/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.day -description: Custom calendar tests for day(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - day(...args) { - ++calls; - assert.compareArray(args, [pd], "day arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.day; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/day/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/day/validate-calendar-value.js deleted file mode 100644 index e273666cb43..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/day/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.day -description: Validate result returned from calendar day() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - day() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.day, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js deleted file mode 100644 index dab5c5c6e41..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.dayofweek -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfWeek"); -Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dayOfWeek should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.dayOfWeek; - -Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", dayOfWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/custom.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/custom.js deleted file mode 100644 index 0c0a888466d..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.dayofweek -description: Custom calendar tests for dayOfWeek(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dayOfWeek(...args) { - ++calls; - assert.compareArray(args, [pd], "dayOfWeek arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.dayOfWeek; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/validate-calendar-value.js deleted file mode 100644 index 129d890c7a2..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.dayofweek -description: Validate result returned from calendar dayOfWeek() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - dayOfWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.dayOfWeek, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index bfb8706e17f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.dayofyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfYear"); -Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dayOfYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.dayOfYear; - -Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", dayOfYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/custom.js deleted file mode 100644 index 3a5a881a4c0..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.dayofyear -description: Custom calendar tests for dayOfYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dayOfYear(...args) { - ++calls; - assert.compareArray(args, [pd], "dayOfYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.dayOfYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/validate-calendar-value.js deleted file mode 100644 index a83716d2032..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.dayofyear -description: Validate result returned from calendar dayOfYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - dayOfYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.dayOfYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/builtin-calendar-no-observable-calls.js deleted file mode 100644 index e33ba86814f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.daysinmonth -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInMonthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInMonth"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInMonth should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.daysInMonth; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", daysInMonthOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/custom.js b/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/custom.js deleted file mode 100644 index badcadb649c..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.daysinmonth -description: Custom calendar tests for daysInMonth(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInMonth(...args) { - ++calls; - assert.compareArray(args, [pd], "daysInMonth arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.daysInMonth; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/validate-calendar-value.js deleted file mode 100644 index 050921e4737..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.daysinmonth -description: Validate result returned from calendar daysInMonth() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInMonth() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.daysInMonth, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 3c00d1f7705..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.daysinweek -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInWeek"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInWeek should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.daysInWeek; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", daysInWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/custom.js b/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/custom.js deleted file mode 100644 index 0892a71a0d7..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.daysinweek -description: Custom calendar tests for daysInWeek(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInWeek(...args) { - ++calls; - assert.compareArray(args, [pd], "daysInWeek arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.daysInWeek; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/validate-calendar-value.js deleted file mode 100644 index ed74bc56ca6..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.daysinweek -description: Validate result returned from calendar daysInWeek() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.daysInWeek, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/daysInYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 9c5337fbea3..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/daysInYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.daysinyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInYear"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.daysInYear; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", daysInYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/daysInYear/custom.js deleted file mode 100644 index 04a99e71961..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/daysInYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.daysinyear -description: Custom calendar tests for daysInYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInYear(...args) { - ++calls; - assert.compareArray(args, [pd], "daysInYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.daysInYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/daysInYear/validate-calendar-value.js deleted file mode 100644 index 3ff42ead902..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/daysInYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.daysinyear -description: Validate result returned from calendar daysInYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.daysInYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 8eb87a8709c..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDate(2000, 5, 2); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.equals(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 1bab8319c7e..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDate(2000, 5, 2); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.equals(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 5f90050c0c8..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDate(2000, 5, 2); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-duplicate-calendar-fields.js deleted file mode 100644 index 87d5b82aa16..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainDate(2000, 5, 2); - - assert.throws(RangeError, () => instance.equals(arg)); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid.js deleted file mode 100644 index a20357f64dd..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-object-valid.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: equals with a valid property bag -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDate(2000, 5, 2); -assert.sameValue(instance.equals({ year: 2000, month: 5, day: 2 }), true, "same date"); -assert.sameValue(instance.equals({ year: 2000, month: 5, day: 4 }), false, "different date"); - -const calendar = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "a", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert.sameValue(instance.withCalendar(calendar).equals({ year: 2000, month: 5, day: 2 }), - false, "different calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-wrong-type.js index 1cab7c1e23a..0172fc4adf2 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.plaindate.prototype.equals description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.PlainDate(2000, 5, 2); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-proto-in-calendar-fields.js deleted file mode 100644 index 6ceb3d7e156..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDate(2000, 5, 2); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string.js index 9919d175632..2c50287fe08 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-string.js @@ -10,28 +10,3 @@ features: [Temporal] const instance = new Temporal.PlainDate(2000, 5, 2); assert.sameValue(instance.equals("2000-05-02"), true, "same date"); assert.sameValue(instance.equals("2000-05-04"), false, "different date"); - -const calendar = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "a", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert.sameValue(instance.withCalendar(calendar).equals("2000-05-02"), false, "different calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-convert.js deleted file mode 100644 index 2e2b82dc442..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.PlainDate(1976, 11, 18); - -assert.throws(Test262Error, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 8eede893fca..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.equals(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index e2750c5a2dd..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => date.equals(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index c9fd688250c..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.equals(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index c7e10d641aa..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => date.equals(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/equals/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 21b39b6353a..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.equals(new Temporal.PlainDate(2000, 5, 2)); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-different.js b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-different.js deleted file mode 100644 index 66be3ef1ac4..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-different.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.protoype.equals -description: test if the calendar is compared -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CalendarTraceId extends Temporal.Calendar { - constructor(id) { - super("iso8601"); - this.id_ = id; - this.calls = 0; - } - get id() { - ++this.calls; - return this.id_; - } - toString() { - TemporalHelpers.assertUnreachable('toString should not be called'); - } -}; - -const calendar1 = new CalendarTraceId("a"); -const date1 = new Temporal.PlainDate(1914, 2, 23, calendar1); - -const calendar2 = new CalendarTraceId("b"); -const date2 = new Temporal.PlainDate(1914, 2, 23, calendar2); - -assert.sameValue(date1.equals(date2), false, "different calendars"); -assert.sameValue(calendar1.calls, 1, "calendar1 id getter calls"); -assert.sameValue(calendar2.calls, 1, "calendar2 id getter calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-same.js b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-same.js deleted file mode 100644 index cf38dc08aaa..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-call-same.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.protoype.equals -description: test if the calendar is compared -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CalendarTraceToString extends Temporal.Calendar { - constructor(id) { - super("iso8601"); - this.id_ = id; - this.calls = 0; - } - get id() { - ++this.calls; - return this.id_; - } - toString() { - TemporalHelpers.assertUnreachable('toString should not be called'); - } -}; - -const calendar1 = new CalendarTraceToString("a"); -const date1 = new Temporal.PlainDate(1914, 2, 23, calendar1); - -const calendar2 = new CalendarTraceToString("a"); -const date2 = new Temporal.PlainDate(1914, 2, 23, calendar2); - -assert.sameValue(date1.equals(date2), true, "same calendar id"); -assert.sameValue(calendar1.calls, 1, "calendar1 id getter calls"); -assert.sameValue(calendar2.calls, 1, "calendar2 id getter calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 5de98aa4001..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -instance.equals({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-fields-iterable.js deleted file mode 100644 index 2d4575071e9..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.equals -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindate.prototype.equals step 3: - 3. Set _other_ to ? ToTemporalDate(_other_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const date = new Temporal.PlainDate(2000, 5, 2, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -date.equals({ year: 2005, month: 6, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-no-call.js b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-no-call.js deleted file mode 100644 index 95f485fa49b..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-no-call.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.protoype.equals -description: test if the calendar is compared -features: [Temporal] ----*/ - -class CalendarTraceToString extends Temporal.Calendar { - constructor(id) { - super("iso8601"); - this.id_ = id; - this.calls = 0; - } - toString() { - ++this.calls; - return this.id_; - } -}; - -const calendar1 = new CalendarTraceToString("a"); -const date1 = new Temporal.PlainDate(1914, 2, 23, calendar1); - -const calendar2 = new CalendarTraceToString("b"); -const date2 = new Temporal.PlainDate(1914, 2, 22, calendar2); - -assert.sameValue(date1.equals(date2), false, "different ISO dates"); -assert.sameValue(calendar1.calls, 0, "calendar1 toString() calls"); -assert.sameValue(calendar2.calls, 0, "calendar2 toString() calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-temporal-object.js index 7c0d150b549..7e5113ea320 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const date = new Temporal.PlainDate(2000, 5, 2, temporalObject); + const date = new Temporal.PlainDate(2000, 5, 2, "iso8601"); date.equals({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/branding.js b/test/built-ins/Temporal/PlainDate/prototype/getCalendar/branding.js deleted file mode 100644 index c2b346989fb..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getcalendar -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getCalendar = Temporal.PlainDate.prototype.getCalendar; - -assert.sameValue(typeof getCalendar, "function"); - -assert.throws(TypeError, () => getCalendar.call(undefined), "undefined"); -assert.throws(TypeError, () => getCalendar.call(null), "null"); -assert.throws(TypeError, () => getCalendar.call(true), "true"); -assert.throws(TypeError, () => getCalendar.call(""), "empty string"); -assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getCalendar.call(1), "1"); -assert.throws(TypeError, () => getCalendar.call({}), "plain object"); -assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDate), "Temporal.PlainDate"); -assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDate.prototype), "Temporal.PlainDate.prototype"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/builtin.js b/test/built-ins/Temporal/PlainDate/prototype/getCalendar/builtin.js deleted file mode 100644 index 08474bc0318..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getcalendar -description: > - Tests that Temporal.PlainDate.prototype.getCalendar - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainDate.prototype.getCalendar), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainDate.prototype.getCalendar), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainDate.prototype.getCalendar), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainDate.prototype.getCalendar.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/length.js b/test/built-ins/Temporal/PlainDate/prototype/getCalendar/length.js deleted file mode 100644 index 70b9d9017ff..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getcalendar -description: Temporal.PlainDate.prototype.getCalendar.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDate.prototype.getCalendar, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/name.js b/test/built-ins/Temporal/PlainDate/prototype/getCalendar/name.js deleted file mode 100644 index 91189d8e6c7..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getcalendar -description: Temporal.PlainDate.prototype.getCalendar.name is "getCalendar". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDate.prototype.getCalendar, "name", { - value: "getCalendar", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/not-a-constructor.js b/test/built-ins/Temporal/PlainDate/prototype/getCalendar/not-a-constructor.js deleted file mode 100644 index 12675be1950..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getcalendar -description: > - Temporal.PlainDate.prototype.getCalendar does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainDate.prototype.getCalendar(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainDate.prototype.getCalendar), false, - "isConstructor(Temporal.PlainDate.prototype.getCalendar)"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/prop-desc.js b/test/built-ins/Temporal/PlainDate/prototype/getCalendar/prop-desc.js deleted file mode 100644 index 1932c08e2f0..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getCalendar/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getcalendar -description: The "getCalendar" property of Temporal.PlainDate.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainDate.prototype.getCalendar, - "function", - "`typeof PlainDate.prototype.getCalendar` is `function`" -); - -verifyProperty(Temporal.PlainDate.prototype, "getCalendar", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/branding.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/branding.js deleted file mode 100644 index f24b13c2257..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getISOFields = Temporal.PlainDate.prototype.getISOFields; - -assert.sameValue(typeof getISOFields, "function"); - -assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); -assert.throws(TypeError, () => getISOFields.call(null), "null"); -assert.throws(TypeError, () => getISOFields.call(true), "true"); -assert.throws(TypeError, () => getISOFields.call(""), "empty string"); -assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getISOFields.call(1), "1"); -assert.throws(TypeError, () => getISOFields.call({}), "plain object"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainDate), "Temporal.PlainDate"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainDate.prototype), "Temporal.PlainDate.prototype"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/builtin.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/builtin.js deleted file mode 100644 index 1d51121d4d0..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: > - Tests that Temporal.PlainDate.prototype.getISOFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainDate.prototype.getISOFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainDate.prototype.getISOFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainDate.prototype.getISOFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainDate.prototype.getISOFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/custom.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/custom.js deleted file mode 100644 index 0e9e7a3aa18..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/custom.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: getISOFields does not call into user code. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarThrowEverything(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -const result = instance.getISOFields(); - -assert.sameValue(result.isoYear, 2000, "isoYear result"); -assert.sameValue(result.isoMonth, 5, "isoMonth result"); -assert.sameValue(result.isoDay, 2, "isoDay result"); -assert.sameValue(result.calendar, calendar, "calendar result"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/field-names.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/field-names.js deleted file mode 100644 index 405459ab06e..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/field-names.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: Correct field names on the object returned from getISOFields -features: [Temporal] ----*/ - -const date = new Temporal.PlainDate(2000, 5, 2); - -const result = date.getISOFields(); -assert.sameValue(result.isoYear, 2000, "isoYear result"); -assert.sameValue(result.isoMonth, 5, "isoMonth result"); -assert.sameValue(result.isoDay, 2, "isoDay result"); -assert.sameValue(result.calendar, "iso8601", "calendar result"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/field-prop-desc.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/field-prop-desc.js deleted file mode 100644 index 139af2c021f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/field-prop-desc.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: Properties on the returned object have the correct descriptor -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoMonth", - "isoYear", -]; - -const date = new Temporal.PlainDate(2000, 5, 2); -const result = date.getISOFields(); - -for (const property of expected) { - verifyProperty(result, property, { - writable: true, - enumerable: true, - configurable: true, - }); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/field-traversal-order.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/field-traversal-order.js deleted file mode 100644 index 10b631991c6..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/field-traversal-order.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: Properties added in correct order to object returned from getISOFields -includes: [compareArray.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoMonth", - "isoYear", -]; - -const date = new Temporal.PlainDate(2000, 5, 2); -const result = date.getISOFields(); - -assert.compareArray(Object.keys(result), expected); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/length.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/length.js deleted file mode 100644 index 679f49fec83..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: Temporal.PlainDate.prototype.getISOFields.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDate.prototype.getISOFields, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/name.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/name.js deleted file mode 100644 index 67e6a28e508..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: Temporal.PlainDate.prototype.getISOFields.name is "getISOFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDate.prototype.getISOFields, "name", { - value: "getISOFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/not-a-constructor.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/not-a-constructor.js deleted file mode 100644 index 265576e0cb3..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: > - Temporal.PlainDate.prototype.getISOFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainDate.prototype.getISOFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainDate.prototype.getISOFields), false, - "isConstructor(Temporal.PlainDate.prototype.getISOFields)"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/prop-desc.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/prop-desc.js deleted file mode 100644 index 89d42869c1a..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: The "getISOFields" property of Temporal.PlainDate.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainDate.prototype.getISOFields, - "function", - "`typeof PlainDate.prototype.getISOFields` is `function`" -); - -verifyProperty(Temporal.PlainDate.prototype, "getISOFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/prototype.js b/test/built-ins/Temporal/PlainDate/prototype/getISOFields/prototype.js deleted file mode 100644 index 769df656d93..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/getISOFields/prototype.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.getisofields -description: Correct prototype on the object returned from getISOFields -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDate(2000, 5, 2); -const result = instance.getISOFields(); -assert.sameValue(Object.getPrototypeOf(result), Object.prototype, "prototype"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index a793bc1eef9..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.inleapyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const inLeapYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "inLeapYear"); -Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("inLeapYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.inLeapYear; - -Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", inLeapYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/custom.js deleted file mode 100644 index c296fc4f970..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.inleapyear -description: Custom calendar tests for inLeapYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - inLeapYear(...args) { - ++calls; - assert.compareArray(args, [pd], "inLeapYear arguments"); - return true; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.inLeapYear; -assert.sameValue(result, true, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/validate-calendar-value.js deleted file mode 100644 index a539274c977..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/validate-calendar-value.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.inleapyear -description: Validate result returned from calendar inLeapYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [0, TypeError], - [-0, TypeError], - [42, TypeError], - [7.1, TypeError], - [NaN, TypeError], - [Infinity, TypeError], - [-Infinity, TypeError], - ["", TypeError], - ["a string", TypeError], - ["0", TypeError], - [Symbol("foo"), TypeError], - [0n, TypeError], - [42n, TypeError], - [{}, TypeError], - [{valueOf() { return false; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - inLeapYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.inLeapYear, `${typeof result} ${String(result)} not converted to boolean`); -}); - -const preservedResults = [ - true, - false, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - inLeapYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.sameValue(instance.inLeapYear, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/month/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/month/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 09a4464612f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/month/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.month -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "month"); -Object.defineProperty(Temporal.Calendar.prototype, "month", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("month should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.month; - -Object.defineProperty(Temporal.Calendar.prototype, "month", monthOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/month/custom.js b/test/built-ins/Temporal/PlainDate/prototype/month/custom.js deleted file mode 100644 index 2499c36e6bf..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/month/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.month -description: Custom calendar tests for month(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - month(...args) { - ++calls; - assert.compareArray(args, [pd], "month arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.month; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/month/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/month/validate-calendar-value.js deleted file mode 100644 index 0a7b1faac32..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/month/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.month -description: Validate result returned from calendar month() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - month() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.month, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/monthCode/builtin-calendar-no-observable-calls.js deleted file mode 100644 index efe6f395f43..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/monthCode/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.monthcode -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthCode should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.monthCode; - -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/monthCode/custom.js b/test/built-ins/Temporal/PlainDate/prototype/monthCode/custom.js deleted file mode 100644 index fa984a8d231..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/monthCode/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.monthcode -description: Custom calendar tests for monthCode(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthCode(...args) { - ++calls; - assert.compareArray(args, [pd], "monthCode arguments"); - return "M01"; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.monthCode; -assert.sameValue(result, "M01", "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/monthCode/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/monthCode/validate-calendar-value.js deleted file mode 100644 index 5c20fb1ec89..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/monthCode/validate-calendar-value.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.monthcode -description: Validate result returned from calendar monthCode() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [Symbol("foo"), TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, TypeError], - [{toString() { return "M01"; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - monthCode() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.monthCode, `${typeof result} ${String(result)} not converted to string`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 896ae8f7bb0..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.monthsinyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthsInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthsInYear"); -Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthsInYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.monthsInYear; - -Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", monthsInYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/custom.js deleted file mode 100644 index 8038a08a8f3..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.monthsinyear -description: Custom calendar tests for monthsInYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthsInYear(...args) { - ++calls; - assert.compareArray(args, [pd], "monthsInYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.monthsInYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/validate-calendar-value.js deleted file mode 100644 index b37c05220cc..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.monthsinyear -description: Validate result returned from calendar monthsInYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - monthsInYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.monthsInYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 6386c38f46f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDate(2000, 5, 2); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.since(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index b4a603f5365..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDate(2000, 5, 2); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.since(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 7bf7b1cbbfb..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.since -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDate(2000, 5, 2); - -assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-duplicate-calendar-fields.js deleted file mode 100644 index 8eb663563b8..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.since -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainDate(2000, 5, 2); - - assert.throws(RangeError, () => instance.since(arg)); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-wrong-type.js index cabc64bba19..043ff198940 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-propertybag-calendar-wrong-type.js @@ -9,7 +9,6 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.PlainDate(2000, 5, 2); const primitiveTests = [ @@ -31,10 +30,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-proto-in-calendar-fields.js deleted file mode 100644 index c11d30bbdaa..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.since -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDate(2000, 5, 2); - -assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-convert.js deleted file mode 100644 index 30c2ff30d14..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.PlainDate(1976, 11, 18); - -assert.throws(Test262Error, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index ce35b550d62..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.since(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index d694ac88523..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => date.since(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index c3672ccd0d1..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.since(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 0a3497025f8..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => date.since(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/since/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 9d9699cc174..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.since(new Temporal.PlainDate(1999, 4, 1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 782f4823b18..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -instance.since({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js deleted file mode 100644 index e7d05784ff4..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: > - Calendar.dateUntil method is called with a null-prototype object as the - options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -const argument = new Temporal.PlainDate(2022, 6, 14, calendar); -instance.since(argument, { largestUnit: "months" }); -assert.sameValue(calendar.dateUntilCallCount, 1, "dateUntil should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index 8febb2b34ef..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: The options object passed to calendar.dateUntil has a largestUnit property with its value in the singular form -info: | - sec-temporal.plaindate.prototype.since steps 13–14: - 13. Let _untilOptions_ be ? MergeLargestUnitOption(_options_, _largestUnit_). - 14. Let _result_ be ? CalendarDateUntil(_temporalDate_.[[Calendar]], _other_, _temporalDate_, _untilOptions_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.PlainDate(2000, 5, 2, calendar); - const later = new Temporal.PlainDate(2001, 6, 3, calendar); - later.since(earlier, { largestUnit }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [] - } -); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-fields-iterable.js deleted file mode 100644 index 0c66704c388..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindate.prototype.since step 3: - 3. Set _other_ to ? ToTemporalDate(_other_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const date = new Temporal.PlainDate(2000, 5, 2, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -date.since({ year: 2005, month: 6, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-id-match.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-id-match.js index 0c2953910ca..aa20863c445 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-id-match.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-id-match.js @@ -3,28 +3,11 @@ /*--- esid: sec-temporal.plaindate.prototype.since -description: Calculation is performed if calendars' toString results match +description: Calculation is performed if calendars' IDs match includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -class Calendar1 extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - toString() { - return "A"; - } -} -class Calendar2 extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - toString() { - return "A"; - } -} - -const plainDate1 = new Temporal.PlainDate(2000, 1, 1, new Calendar1()); -const plainDate2 = new Temporal.PlainDate(2000, 1, 2, new Calendar2()); +const plainDate1 = new Temporal.PlainDate(2000, 1, 1, "iso8601"); +const plainDate2 = Temporal.PlainDate.from({ year: 2000, month: 1, day: 2, calendar: "2024-05-16[u-ca=iso8601]" }); TemporalHelpers.assertDuration(plainDate2.since(plainDate1), 0, 0, 0, /* days = */ 1, 0, 0, 0, 0, 0, 0); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-invalid-return.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-invalid-return.js deleted file mode 100644 index 27c463b6f9d..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-invalid-return.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: Throw when the returned value from the calendar's dateUntil method is not a Duration. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor(value) { - super("iso8601"); - this.value = value; - } - dateUntil() { - return this.value; - } -} - -const tests = [ - [undefined], - [null, "null"], - [true], - ["2000-05"], - [Symbol()], - [200005], - [200005n], - [{}, "plain object"], - [() => {}, "lambda"], - [Temporal.Duration, "Temporal.Duration"], - [Temporal.Duration.prototype, "Temporal.Duration.prototype"], -]; -for (const [test, description = typeof test] of tests) { - const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar(test)); - assert.throws( - TypeError, - () => plainDate.since("2022-06-20", { largestUnit: "years" }), - `Expected error with ${description}` - ); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-mismatch.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-mismatch.js deleted file mode 100644 index f8226f5f9c5..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-mismatch.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: RangeError thrown if calendars' id properties do not match -features: [Temporal] ----*/ - -const calendar1 = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "A", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const calendar2 = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "B", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const plainDate1 = new Temporal.PlainDate(2000, 1, 1, calendar1); -const plainDate2 = new Temporal.PlainDate(2000, 1, 1, calendar2); -assert.throws(RangeError, () => plainDate1.since(plainDate2)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-temporal-object.js index 333aee1f873..e05a102ed51 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const date = new Temporal.PlainDate(2000, 5, 2, temporalObject); + const date = new Temporal.PlainDate(2000, 5, 2); date.since({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/custom.js b/test/built-ins/Temporal/PlainDate/prototype/since/custom.js deleted file mode 100644 index a59f4af781c..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/custom.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: Basic tests with custom calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const result = new Temporal.Duration(1, 3, 5, 7, 9); -const options = { largestUnit: "years" }; -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateUntil(...args) { - ++calls; - assert.sameValue(args.length, 3, "Three arguments"); - assert.sameValue(args[0], plainDate, "First argument"); - assert.sameValue(args[1], other, "Second argument"); - assert.sameValue(args[2].largestUnit, "year", "Third argument: largestUnit"); - return result; - } -} -const calendar = new CustomCalendar(); -const plainDate = new Temporal.PlainDate(1976, 11, 18, calendar); -const other = new Temporal.PlainDate(2022, 6, 20, calendar); -TemporalHelpers.assertDuration(plainDate.since(other, options), - -1, -3, -5, -7, 0, 0, 0, 0, 0, 0, "result"); -assert.sameValue(calls, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js index 3dcf5f262a5..ef1541e5528 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/since/order-of-operations.js @@ -11,30 +11,6 @@ features: [Temporal] const expected = [ // ToTemporalDate "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.dateFromFields", - "get other.calendar.fields", - "call other.calendar.fields", "get other.day", "get other.day.valueOf", "call other.day.valueOf", @@ -47,44 +23,31 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", - "call other.calendar.dateFromFields", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, ownCalendar); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); const otherDatePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, month: 6, monthCode: "M06", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { @@ -98,96 +61,7 @@ function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", ro }, "options"); } -// clear any observable things that happened while constructing the objects -actual.splice(0); - // basic order of observable operations with calendar call, without rounding: instance.since(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" })); -assert.compareArray(actual, expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", -]), "order of operations"); -actual.splice(0); // clear - -// short-circuit for identical objects: -const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 5, - monthCode: "M05", - day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); - -instance.since(identicalPropertyBag, createOptionsObserver()); -assert.compareArray(actual, expected, "order of operations with identical dates"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest year: -const expectedOpsForYearRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); +assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest year and skips a DateUntil call: -const otherDatePropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual, { - year: 2001, - month: 5, - monthCode: "M05", - day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); -const expectedOpsForYearRoundingSameMonth = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.since(otherDatePropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months/weeks"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest month: -const expectedOpsForMonthRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "months" })); -assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest week: -const expectedOpsForWeekRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateUntil", - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.since(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); -assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/rounding-zero-year-month-week-length.js b/test/built-ins/Temporal/PlainDate/prototype/since/rounding-zero-year-month-week-length.js deleted file mode 100644 index a495e0da159..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/since/rounding-zero-year-month-week-length.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.since -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const d1 = new Temporal.PlainDate(1970, 1, 1, cal); -const d2 = new Temporal.PlainDate(1971, 1, 1, cal); - -assert.throws(RangeError, () => d1.since(d2, { smallestUnit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => d1.since(d2, { smallestUnit: "months" }), "zero month length handled correctly"); -assert.throws(RangeError, () => d1.since(d2, { smallestUnit: "weeks" }), "zero week length handled correctly"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/builtin-calendar-no-observable-calls.js deleted file mode 100644 index f23120c5917..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/subtract/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.subtract -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.subtract(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/calendar-invalid-return.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/calendar-invalid-return.js deleted file mode 100644 index 574040aaa07..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/subtract/calendar-invalid-return.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.subtract -description: Throw when the returned value from the calendar's dateAdd method is not a PlainDate. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor(value) { - super("iso8601"); - this.value = value; - } - dateAdd() { - return this.value; - } -} - -const tests = [ - [undefined], - [null, "null"], - [true], - ["2000-05"], - [Symbol()], - [200005], - [200005n], - [{}, "plain object"], - [() => {}, "lambda"], - [Temporal.PlainDate, "Temporal.PlainDate"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype"], -]; -for (const [test, description = typeof test] of tests) { - const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar(test)); - assert.throws(TypeError, () => plainDate.subtract({ years: 1 }), `Expected error with ${description}`); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/custom.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/custom.js deleted file mode 100644 index 33098d557ef..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/subtract/custom.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.subtract -description: Basic tests with custom calendar -includes: [compareArray.js,temporalHelpers.js] -features: [Temporal] ----*/ - -const result = new Temporal.PlainDate(1920, 5, 3); -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(...args) { - ++calls; - assert.sameValue(args.length, 3, "Three arguments"); - assert.sameValue(args[0], plainDate, "First argument"); - TemporalHelpers.assertDuration(args[1], -43, 0, 0, 0, 0, 0, 0, 0, 0, 0, "Second argument"); - assert.sameValue(typeof args[2], "object", "Third argument: type"); - assert.sameValue(Object.getPrototypeOf(args[2]), null, "Third argument: prototype"); - assert.compareArray(Object.keys(args[2]), [], "Third argument: keys"); - return result; - } -} -const calendar = new CustomCalendar(); -const plainDate = new Temporal.PlainDate(1976, 11, 18, calendar); -assert.sameValue(plainDate.subtract({ years: 43 }), result); -assert.sameValue(calls, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js index 317b7b68310..477fc58ec72 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/subtract/order-of-operations.js @@ -40,20 +40,13 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", - // AddDate - "get this.calendar.dateAdd", - "call this.calendar.dateAdd", - // inside Calendar.p.dateAdd "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); const fields = TemporalHelpers.propertyBagObserver(actual, { years: 1, @@ -76,51 +69,3 @@ instance.subtract(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -const noCalendarExpected = [ - // ToTemporalDurationRecord - "get fields.days", - "get fields.days.valueOf", - "call fields.days.valueOf", - "get fields.hours", - "get fields.hours.valueOf", - "call fields.hours.valueOf", - "get fields.microseconds", - "get fields.microseconds.valueOf", - "call fields.microseconds.valueOf", - "get fields.milliseconds", - "get fields.milliseconds.valueOf", - "call fields.milliseconds.valueOf", - "get fields.minutes", - "get fields.minutes.valueOf", - "call fields.minutes.valueOf", - "get fields.months", - "get fields.nanoseconds", - "get fields.nanoseconds.valueOf", - "call fields.nanoseconds.valueOf", - "get fields.seconds", - "get fields.seconds.valueOf", - "call fields.seconds.valueOf", - "get fields.weeks", - "get fields.years", - "get this.calendar.dateAdd", - // AddDate - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; - -const noCalendarFields = TemporalHelpers.propertyBagObserver(actual, { - days: 1, - hours: 1, - minutes: 1, - seconds: 1, - milliseconds: 1, - microseconds: 1, - nanoseconds: 1, -}, "fields"); - -instance.subtract(noCalendarFields, options); -assert.compareArray(actual, noCalendarExpected, "order of operations with no calendar operation"); - -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDate/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toJSON/builtin-calendar-no-observable-calls.js deleted file mode 100644 index bb0871ff3a5..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toJSON/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tojson -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.toJSON(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 7603e4557bc..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toLocaleString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tolocalestring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.toLocaleString(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units.js index 2de2f0c8cb6..1f15b6b2174 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-balance-negative-time-units.js @@ -35,10 +35,9 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); const date = new Temporal.PlainDate(2000, 5, 2); const pdt = date.toPlainDateTime(datetime); -TemporalHelpers.assertPlainDateTime(pdt, 2000, 5, "M05", 2, 1, 1, 1, 1, 0, 999); +TemporalHelpers.assertPlainDateTime(pdt, 2000, 5, "M05", 2, 0, 59, 1, 1, 1, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index ad8dc11155a..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplaindatetime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.toPlainDateTime(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 6197ad75841..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplaindatetime -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => date.toPlainDateTime(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 00ab1cf7817..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplaindatetime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.toPlainDateTime(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 3af8fa988f6..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplaindatetime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => date.toPlainDateTime(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/custom.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/custom.js deleted file mode 100644 index 66a3208dd24..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainDateTime/custom.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplaindatetime -description: toPlainDateTime() doesn't call into the calendar. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarThrowEverything(); -const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); -const result = plainDate.toPlainDateTime("11:30:23"); -assert.sameValue(result.getCalendar(), calendar, "calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/basic.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/basic.js index c64b637bc33..9f5bc2f452a 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/basic.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/basic.js @@ -8,8 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const calendar = new Temporal.Calendar("iso8601"); -const pd = new Temporal.PlainDate(1970, 12, 24, calendar); +const pd = new Temporal.PlainDate(1970, 12, 24, "iso8601"); const pmd = pd.toPlainMonthDay(); TemporalHelpers.assertPlainMonthDay(pmd, "M12", 24); -assert.sameValue(pmd.getISOFields().calendar, "iso8601"); +assert.sameValue(pmd.calendarId, "iso8601"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 64027364001..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDate(2023, 5, 2, "iso8601"); -instance.toPlainMonthDay(); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 96140145686..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthDayFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthDayFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthDayFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.toPlainMonthDay(); - -Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", monthDayFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-arguments.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-arguments.js deleted file mode 100644 index b8dda84d662..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-arguments.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: Correct options value is passed to calendar method -info: | - MonthDayFromFields ( calendar, fields [ , options ] ) - - 3. If options is not present, then - a. Set options to undefined. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthDayFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.sameValue(args[1], undefined, "args[1]"); - return super.monthDayFromFields(...args); - } -} -const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar()); -const result = plainDate.toPlainMonthDay(); -TemporalHelpers.assertPlainMonthDay(result, "M05", 2); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fields-iterable.js deleted file mode 100644 index 96e39b8b35b..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fields-iterable.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindate.prototype.toplainmonthday step 4: - 4. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"monthCode"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "monthCode", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const date = new Temporal.PlainDate(2000, 5, 2, calendar); -date.toPlainMonthDay(); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index d16ae4d32e5..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: > - Calendar.monthDayFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -instance.toPlainMonthDay(); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1, "monthDayFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-invalid-return.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-invalid-return.js deleted file mode 100644 index 93f3b4fb2ad..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-invalid-return.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: Throw when the returned value is not a PlainMonthDay. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor(value) { - super("iso8601"); - this.value = value; - } - monthDayFromFields() { - return this.value; - } -} - -const tests = [ - [undefined], - [null, "null"], - [true], - ["2000-05"], - [Symbol()], - [200005], - [200005n], - [{}, "plain object"], - [() => {}, "lambda"], - [Temporal.PlainMonthDay, "Temporal.PlainMonthDay"], - [Temporal.PlainMonthDay.prototype, "Temporal.PlainMonthDay.prototype"], -]; -for (const [test, description = typeof test] of tests) { - const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar(test)); - assert.throws(TypeError, () => plainDate.toPlainMonthDay(), `Expected error with ${description}`); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined.js deleted file mode 100644 index 681c5f08a64..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-monthdayfromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: > - Calendar.monthDayFromFields method is called with undefined as the options - value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -instance.toPlainMonthDay(); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/constructor-in-calendar-fields.js deleted file mode 100644 index 909debb9eb9..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const date = new Temporal.PlainDate(2023, 5, 1, calendar); - -assert.throws(RangeError, () => date.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/duplicate-calendar-fields.js deleted file mode 100644 index 3f2cfd33e1f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const date = new Temporal.PlainDate(2023, 5, 1, calendar); - - assert.throws(RangeError, () => date.toPlainMonthDay()); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/proto-in-calendar-fields.js deleted file mode 100644 index 99105732a44..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.toplainmonthday -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const date = new Temporal.PlainDate(2023, 5, 1, calendar); - -assert.throws(RangeError, () => date.toPlainMonthDay()); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/basic.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/basic.js index d2c722c514d..4ddc1d25e42 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/basic.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/basic.js @@ -8,8 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const calendar = new Temporal.Calendar("iso8601"); -const pd = new Temporal.PlainDate(1970, 12, 24, calendar); +const pd = new Temporal.PlainDate(1970, 12, 24, "iso8601"); const pym = pd.toPlainYearMonth(); TemporalHelpers.assertPlainYearMonth(pym, 1970, 12, "M12"); -assert.sameValue(pym.getISOFields().calendar, "iso8601"); +assert.sameValue(pym.calendarId, "iso8601"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 0d9a3c72e6e..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDate(2023, 5, 2, "iso8601"); -instance.toPlainYearMonth(); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 9a1b0cabff7..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const yearMonthFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearMonthFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("yearMonthFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.toPlainYearMonth(); - -Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", yearMonthFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-arguments.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-arguments.js deleted file mode 100644 index 5dd51a40c1b..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-arguments.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: Correct options value is passed to calendar method -info: | - YearMonthFromFields ( calendar, fields [ , options ] ) - - 3. If options is not present, then - a. Set options to undefined. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearMonthFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.sameValue(args[1], undefined, "args[1]"); - return super.yearMonthFromFields(...args); - } -} -const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar()); -const result = plainDate.toPlainYearMonth(); -TemporalHelpers.assertPlainYearMonth(result, 2000, 5, "M05"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fields-iterable.js deleted file mode 100644 index 7203335d86f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fields-iterable.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindate.prototype.toplainyearmonth step 4: - 4. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const date = new Temporal.PlainDate(2000, 5, 2, calendar); -date.toPlainYearMonth(); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 08c546c1f94..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: > - Calendar.yearMonthFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -instance.toPlainYearMonth(); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-invalid-return.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-invalid-return.js deleted file mode 100644 index d7d5a1e5b89..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-invalid-return.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: Throw when the returned value is not a PlainYearMonth. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor(value) { - super("iso8601"); - this.value = value; - } - yearMonthFromFields() { - return this.value; - } -} - -const tests = [ - [undefined], - [null, "null"], - [true], - ["2000-05"], - [Symbol()], - [200005], - [200005n], - [{}, "plain object"], - [() => {}, "lambda"], - [Temporal.PlainYearMonth, "Temporal.PlainYearMonth"], - [Temporal.PlainYearMonth.prototype, "Temporal.PlainYearMonth.prototype"], -]; -for (const [test, description = typeof test] of tests) { - const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar(test)); - assert.throws(TypeError, () => plainDate.toPlainYearMonth(), `Expected error with ${description}`); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined.js deleted file mode 100644 index 6ef9df6b85f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-yearmonthfromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: > - Calendar.yearMonthFromFields method is called with undefined as the options - value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -instance.toPlainYearMonth(); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/constructor-in-calendar-fields.js deleted file mode 100644 index 7d77028b7a1..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const date = new Temporal.PlainDate(2023, 5, 1, calendar); - -assert.throws(RangeError, () => date.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/duplicate-calendar-fields.js deleted file mode 100644 index fcfcda724aa..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const date = new Temporal.PlainDate(2023, 5, 1, calendar); - - assert.throws(RangeError, () => date.toPlainYearMonth()); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/proto-in-calendar-fields.js deleted file mode 100644 index c8d1a8fa433..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.toplainyearmonth -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const date = new Temporal.PlainDate(2023, 5, 1, calendar); - -assert.throws(RangeError, () => date.toPlainYearMonth()); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/toString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index fa597d0768f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tostring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.toString(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js deleted file mode 100644 index e8f0edb7006..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendar-tostring.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.protoype.tostring -description: Number of observable 'toString' calls on the calendar for each value of calendarName -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls; -const customCalendar = { - get id() { - ++calls; - return "custom"; - }, - toString() { - TemporalHelpers.assertUnreachable('toString should not be called'); - }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const date = new Temporal.PlainDate(2000, 5, 2, customCalendar); -[ - ["always", "2000-05-02[u-ca=custom]", 1], - ["auto", "2000-05-02[u-ca=custom]", 1], - ["critical", "2000-05-02[!u-ca=custom]", 1], - ["never", "2000-05-02", 0], - [undefined, "2000-05-02[u-ca=custom]", 1], -].forEach(([calendarName, expectedResult, expectedCalls]) => { - calls = 0; - const result = date.toString({ calendarName }); - assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js index a5621276a5f..fd4646053db 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-always.js @@ -7,39 +7,6 @@ description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05-02[u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-02[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05-02[u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-02[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.PlainDate(2000, 5, 2, ...args); - const result = date.toString({ calendarName: "always" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = always`); -} +const date = new Temporal.PlainDate(2000, 5, 2); +const result = date.toString({ calendarName: "always" }); +assert.sameValue(result, "2000-05-02[u-ca=iso8601]", `built-in ISO calendar for calendarName = always`); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js index 77e8c5dd4d9..dfac7a06f3c 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-auto.js @@ -7,39 +7,6 @@ description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05-02", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-02[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05-02", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-02[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.PlainDate(2000, 5, 2, ...args); - const result = date.toString({ calendarName: "auto" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); -} +const date = new Temporal.PlainDate(2000, 5, 2); +const result = date.toString({ calendarName: "auto" }); +assert.sameValue(result, "2000-05-02", `built-in ISO calendar for calendarName = auto`); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js index dc3d37b7566..2af44b82ab4 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-critical.js @@ -9,39 +9,6 @@ description: > features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05-02[!u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-02[!u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05-02[!u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-02[!u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-02[!u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.PlainDate(2000, 5, 2, ...args); - const result = date.toString({ calendarName: "critical" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); -} +const date = new Temporal.PlainDate(2000, 5, 2); +const result = date.toString({ calendarName: "critical" }); +assert.sameValue(result, "2000-05-02[!u-ca=iso8601]", `built-in ISO calendar for calendarName = critical`); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js index 1d25028717e..00207ee3e3d 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-never.js @@ -7,39 +7,6 @@ description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05-02", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-02", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05-02", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-02", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-02", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.PlainDate(2000, 5, 2, ...args); - const result = date.toString({ calendarName: "never" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = never`); -} +const date = new Temporal.PlainDate(2000, 5, 2); +const result = date.toString({ calendarName: "never" }); +assert.sameValue(result, "2000-05-02", `built-in ISO calendar for calendarName = never`); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js index fac29dcf86f..e1c5052a01e 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-undefined.js @@ -14,40 +14,7 @@ info: | features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05-02", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-02[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05-02", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-02[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.PlainDate(2000, 5, 2, ...args); - const result = date.toString({ calendarName: undefined }); - assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); - // See options-object.js for {} and options-undefined.js for absent options arg -} +const date = new Temporal.PlainDate(2000, 5, 2); +const result = date.toString({ calendarName: undefined }); +assert.sameValue(result, "2000-05-02", `default calendarName option is auto with built-in ISO calendar`); +// See options-object.js for {} and options-undefined.js for absent options arg diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js index d3718951bfe..80c0b3c6c89 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js @@ -15,32 +15,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const calendar = { - id: "custom", - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const date = new Temporal.PlainDate(2000, 5, 2, calendar); +const date = new Temporal.PlainDate(2000, 5, 2, "iso8601"); TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", (calendarName) => date.toString({ calendarName }), - (result, descr) => assert.sameValue(result, "2000-05-02[u-ca=custom]", descr), + (result, descr) => assert.sameValue(result, "2000-05-02", descr), ); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/options-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toString/options-undefined.js deleted file mode 100644 index 416b42fc2ba..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/options-undefined.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tostring -description: Verify that undefined options are handled correctly. -features: [Temporal] ----*/ - -const calendar = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "custom", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const date1 = new Temporal.PlainDate(2000, 5, 2); -const date2 = new Temporal.PlainDate(2000, 5, 2, calendar); - -[ - [date1, "2000-05-02"], - [date2, "2000-05-02[u-ca=custom]"], -].forEach(([date, expected]) => { - const explicit = date.toString(undefined); - assert.sameValue(explicit, expected, "default calendarName option is auto"); - - const implicit = date.toString(); - assert.sameValue(implicit, expected, "default calendarName option is auto"); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/toString/order-of-operations.js index a773a9a7925..a53a018d3c1 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toString/order-of-operations.js @@ -12,14 +12,10 @@ const expected = [ "get options.calendarName", "get options.calendarName.toString", "call options.calendarName.toString", - "get this.calendar.id", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); const options = TemporalHelpers.propertyBagObserver(actual, { calendarName: "auto", diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/basic.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/basic.js index 99591700caf..47c909eef3e 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/basic.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/basic.js @@ -8,7 +8,7 @@ features: [Temporal] ---*/ const plainDate = Temporal.PlainDate.from("2020-01-01"); -const timeZone = Temporal.TimeZone.from("UTC"); +const timeZone = "UTC"; const plainTime = Temporal.PlainTime.from("12:00"); let result = plainDate.toZonedDateTime({ timeZone, plainTime }); @@ -17,13 +17,7 @@ assert.sameValue(result.toString(), "2020-01-01T12:00:00+00:00[UTC]", "objects p result = plainDate.toZonedDateTime(timeZone); assert.sameValue(result.toString(), "2020-01-01T00:00:00+00:00[UTC]", "time zone object argument"); -result = plainDate.toZonedDateTime("UTC"); -assert.sameValue(result.toString(), "2020-01-01T00:00:00+00:00[UTC]", "time zone string argument"); - -result = plainDate.toZonedDateTime({ timeZone }); -assert.sameValue(result.toString(), "2020-01-01T00:00:00+00:00[UTC]", "time zone object property"); - -result = plainDate.toZonedDateTime({ timeZone: "UTC", plainTime }); +result = plainDate.toZonedDateTime({ timeZone, plainTime }); assert.sameValue(result.toString(), "2020-01-01T12:00:00+00:00[UTC]", "time zone string property"); result = plainDate.toZonedDateTime({ timeZone, plainTime: "12:00" }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/branding.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/branding.js index 6ef14dad488..e035cdfbec4 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/branding.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/branding.js @@ -11,7 +11,7 @@ const toZonedDateTime = Temporal.PlainDate.prototype.toZonedDateTime; assert.sameValue(typeof toZonedDateTime, "function"); -const args = [new Temporal.TimeZone("UTC")]; +const args = ["UTC"]; assert.throws(TypeError, () => toZonedDateTime.apply(undefined, args), "undefined"); assert.throws(TypeError, () => toZonedDateTime.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/calendar.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/calendar.js deleted file mode 100644 index e2a3d12d393..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/calendar.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: Calendar of the receiver is used -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -const timeCalendar = { toString() { return "iso8601"; } }; -const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); -const result = plainDate.toZonedDateTime({ - timeZone: "UTC", - plainTime: { hour: 12, minute: 30, calendar: timeCalendar }, -}); -assert.sameValue(result.epochNanoseconds, 957270600_000_000_000n); -assert.sameValue(result.timeZoneId, "UTC"); -assert.sameValue(result.getCalendar(), calendar); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index 35e8d127932..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants can be at most 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - calls++; - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12 })]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.PlainDate(1970, 1, 1); -instance.toZonedDateTime({ timeZone, plainTime: new Temporal.PlainTime(12) }); - -assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js deleted file mode 100644 index f8ec3994ed1..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.PlainDate(1970, 1, 1); -assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, plainTime: new Temporal.PlainTime(12) }), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index a736930b881..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); - -const instance = new Temporal.PlainDate(2000, 5, 2, nonBuiltinISOCalendar); -instance.toZonedDateTime(timeZone); - -assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index e2c15ec9b9c..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - calls++; - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12 }), - utcInstant.add({ hours: 12 }) - ]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.PlainDate(1970, 1, 1); -instance.toZonedDateTime({ timeZone, plainTime: new Temporal.PlainTime(12) }); - -assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index eb2e3851c4d..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.PlainDate(1970, 1, 1); -assert.throws(RangeError, () => instance.toZonedDateTime({ timeZone, plainTime: new Temporal.PlainTime(12) }), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/order-of-operations.js index 9c00c83da6f..d293691aef0 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/order-of-operations.js @@ -11,9 +11,6 @@ features: [Temporal] const actual = []; const expected = [ "get item.timeZone", - "has item.timeZone.getOffsetNanosecondsFor", - "has item.timeZone.getPossibleInstantsFor", - "has item.timeZone.id", "get item.plainTime", // ToTemporalTime "get item.plainTime.hour", @@ -34,18 +31,9 @@ const expected = [ "get item.plainTime.second", "get item.plainTime.second.valueOf", "call item.plainTime.second.valueOf", - // lookup in PlainDate.p.toZonedDateTime - "get item.timeZone.getOffsetNanosecondsFor", - "get item.timeZone.getPossibleInstantsFor", - // GetInstantFor - "call item.timeZone.getPossibleInstantsFor", ]; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 1, 1, calendar); -const springForwardInstance = new Temporal.PlainDate(2000, 4, 2, calendar); -const fallBackInstance = new Temporal.PlainDate(2000, 10, 29, calendar); -actual.splice(0); // clear calendar calls that happened in constructors +const instance = new Temporal.PlainDate(2000, 1, 1, "iso8601"); const plainTime = TemporalHelpers.propertyBagObserver(actual, { hour: 2, @@ -55,41 +43,11 @@ const plainTime = TemporalHelpers.propertyBagObserver(actual, { microsecond: 0, nanosecond: 0, }, "item.plainTime"); -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const timeZone = TemporalHelpers.timeZoneObserver(actual, "item.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); const item = TemporalHelpers.propertyBagObserver(actual, { plainTime, - timeZone, -}, "item"); + timeZone: "UTC" +}, "item", ["timeZone"]); instance.toZonedDateTime(item); -assert.compareArray(actual, expected, "order of operations at normal wall-clock time"); -actual.splice(0); // clear - -const plainTime130 = TemporalHelpers.propertyBagObserver(actual, { - hour: 1, - minute: 30, - second: 0, - millisecond: 0, - microsecond: 0, - nanosecond: 0, -}, "item.plainTime"); -const item130 = TemporalHelpers.propertyBagObserver(actual, { - plainTime: plainTime130, - timeZone, -}, "item"); - -fallBackInstance.toZonedDateTime(item130); -assert.compareArray(actual, expected, "order of operations at repeated wall-clock time"); -actual.splice(0); // clear - -springForwardInstance.toZonedDateTime(item); -assert.compareArray(actual, expected.concat([ - "call item.timeZone.getOffsetNanosecondsFor", - "call item.timeZone.getOffsetNanosecondsFor", - "call item.timeZone.getPossibleInstantsFor", -]), "order of operations at skipped wall-clock time"); +assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-balance-negative-time-units.js index 44484630d1c..8fe94d09aca 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-balance-negative-time-units.js @@ -28,19 +28,16 @@ info: | ii. 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.plaindate.prototype.tozoneddatetime step 6.a: a. Set _temporalTime_ to ? ToTemporalTime(_temporalTime_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); -const otherTimeZone = new Temporal.TimeZone("UTC"); // should not be used to convert datetime to PlainTime const date = new Temporal.PlainDate(2000, 5, 2); -const zdt = date.toZonedDateTime({ timeZone: otherTimeZone, plainTime: datetime }); +const zdt = date.toZonedDateTime({ timeZone: "UTC", plainTime: datetime }); -assert.sameValue(zdt.microsecond, 0); -assert.sameValue(zdt.nanosecond, 999); +assert.sameValue(zdt.hour, 0); +assert.sameValue(zdt.minute, 59); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 1e814437792..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.toZonedDateTime({ plainTime: datetime, timeZone: "UTC" })); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index e772ff8051c..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => date.toZonedDateTime({ plainTime: datetime, timeZone: "UTC" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 948eb5efd76..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.toZonedDateTime({ plainTime: datetime, timeZone: "UTC" })); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index c158557b7be..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/plaintime-argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => date.toZonedDateTime({ plainTime: datetime, timeZone: "UTC" })); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index d9980be43a7..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => date.toZonedDateTime({ plainTime, timeZone })); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 9680738ecf9..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const date = new Temporal.PlainDate(2000, 5, 2); - const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => date.toZonedDateTime({ plainTime, timeZone }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index eef842bfe87..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => date.toZonedDateTime({ plainTime, timeZone })); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index abc228d4af7..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const plainTime = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(TypeError, () => date.toZonedDateTime({ plainTime, timeZone })); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index a3d4f477904..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.plaindate.prototype.tozoneddatetime step 7: - 7. Let _instant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _temporalDateTime_, *"compatible"*). - sec-temporal-builtintimezonegetinstantfor step 1: - 1. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-builtintimezonegetinstantfor step 14: - 14. Assert: _disambiguation_ is *"compatible"* or *"later"*. - sec-temporal-builtintimezonegetinstantfor step 16: - 16. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _later_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected1 = [ - "2000-05-02T00:00:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const date = new Temporal.PlainDate(2000, 5, 2); - date.toZonedDateTime(timeZone); -}, expected1); - -// Same, but test the other path where the time doesn't exist and -// GetPossibleInstantsFor is called again on a later time - -const expected2 = [ - "2030-01-01T00:30:00", - "2030-01-01T01:30:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const date = new Temporal.PlainDate(2030, 1, 1); - date.toZonedDateTime({ plainTime: new Temporal.PlainTime(0, 30), timeZone }); -}, expected2); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getpossibleinstantsfor.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getpossibleinstantsfor.js deleted file mode 100644 index 9386d117308..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-getpossibleinstantsfor.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: Calendar of the receiver is used -features: [Temporal] ----*/ - -const calendar = new Temporal.Calendar("iso8601"); -class CustomTimeZone extends Temporal.TimeZone { - constructor() { - super("UTC"); - } - getPossibleInstantsFor(plainDateTime) { - assert.sameValue(plainDateTime.getCalendar(), calendar); - return [new Temporal.Instant(987654321_000_000_000n)]; - } -} -const timeZone = new CustomTimeZone(); -const plainDate = new Temporal.PlainDate(2000, 5, 2, calendar); -const result = plainDate.toZonedDateTime({ - timeZone, - plainTime: { hour: 12, minute: 30 }, -}); -assert.sameValue(result.epochNanoseconds, 987654321_000_000_000n); -assert.sameValue(result.getTimeZone(), timeZone); -assert.sameValue(result.getCalendar(), calendar); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js index 69be4a11ac2..739b9ea4783 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string.js index 6e4036ef43f..850a0d43ed1 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string.js @@ -4,33 +4,12 @@ /*--- esid: sec-temporal.plaindate.prototype.tozoneddatetime description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.PlainDate(2000, 5, 2); ["UTC", "+01:30"].forEach((timeZone) => { const result = instance.toZonedDateTime(timeZone); - assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); + assert.sameValue(result.timeZoneId, timeZone, `time zone slot should store string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-wrong-type.js index 6163db000ae..a977ab907f0 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/prototype/toZonedDateTime/timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plaindate.prototype.tozoneddatetime description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index a71ec3efdcc..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDate(2000, 5, 2); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.until(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 5aa613c6dd7..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDate(2000, 5, 2); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.until(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 1c3fb02454e..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.until -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDate(2000, 5, 2); - -assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-duplicate-calendar-fields.js deleted file mode 100644 index 342c0a1dd4a..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.until -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainDate(2000, 5, 2); - - assert.throws(RangeError, () => instance.until(arg)); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-wrong-type.js index e0383ce83ef..023184f7f7d 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.plaindate.prototype.until description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.PlainDate(2000, 5, 2); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-proto-in-calendar-fields.js deleted file mode 100644 index 73fe934d587..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.until -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDate(2000, 5, 2); - -assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-convert.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-convert.js deleted file mode 100644 index 4aca3ad346b..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.PlainDate(1976, 11, 18); - -assert.throws(Test262Error, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index dc983f8cb3c..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.until(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index bf478c4d7db..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => date.until(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index e2f5b251e67..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => date.until(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 326010d3c66..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const date = new Temporal.PlainDate(2000, 5, 2); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => date.until(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/until/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 6b13d151ef6..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.until(new Temporal.PlainDate(2001, 6, 13)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index e55859f7278..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -instance.until({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js deleted file mode 100644 index ad5c782d4fa..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: > - Calendar.dateUntil method is called with a null-prototype object as the - options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -const argument = new Temporal.PlainDate(2022, 6, 14, calendar); -instance.until(argument, { largestUnit: "months" }); -assert.sameValue(calendar.dateUntilCallCount, 1, "dateUntil should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index f85e886ebe8..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: The options object passed to calendar.dateUntil has a largestUnit property with its value in the singular form -info: | - sec-temporal.plaindate.prototype.until steps 12–13: - 13. Let _untilOptions_ be ? MergeLargestUnitOption(_options_, _largestUnit_). - 14. Let _result_ be ? CalendarDateUntil(_temporalDate_.[[Calendar]], _temporalDate_, _other_, _untilOptions_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.PlainDate(2000, 5, 2, calendar); - const later = new Temporal.PlainDate(2001, 6, 3, calendar); - earlier.until(later, { largestUnit }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [] - } -); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-fields-iterable.js deleted file mode 100644 index 9bf9f358ae7..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindate.prototype.until step 3: - 3. Set _other_ to ? ToTemporalDate(_other_). - sec-temporal-totemporaldate step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const date = new Temporal.PlainDate(2000, 5, 2, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -date.until({ year: 2005, month: 6, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-id-match.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-id-match.js index 9eb1c085782..514860154d1 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-id-match.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-id-match.js @@ -3,28 +3,11 @@ /*--- esid: sec-temporal.plaindate.prototype.until -description: Calculation is performed if calendars' toString results match +description: Calculation is performed if calendars' IDs match includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -class Calendar1 extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - toString() { - return "A"; - } -} -class Calendar2 extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - toString() { - return "A"; - } -} - -const plainDate1 = new Temporal.PlainDate(2000, 1, 1, new Calendar1()); -const plainDate2 = new Temporal.PlainDate(2000, 1, 2, new Calendar2()); +const plainDate1 = new Temporal.PlainDate(2000, 1, 1, "iso8601"); +const plainDate2 = Temporal.PlainDate.from({ year: 2000, month: 1, day: 2, calendar: "2024-05-16[u-ca=iso8601]" }); TemporalHelpers.assertDuration(plainDate1.until(plainDate2), 0, 0, 0, /* days = */ 1, 0, 0, 0, 0, 0, 0); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-invalid-return.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-invalid-return.js deleted file mode 100644 index a7f898c5de1..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-invalid-return.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: Throw when the returned value from the calendar's dateUntil method is not a Duration. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor(value) { - super("iso8601"); - this.value = value; - } - dateUntil() { - return this.value; - } -} - -const tests = [ - [undefined], - [null, "null"], - [true], - ["2000-05"], - [Symbol()], - [200005], - [200005n], - [{}, "plain object"], - [() => {}, "lambda"], - [Temporal.Duration, "Temporal.Duration"], - [Temporal.Duration.prototype, "Temporal.Duration.prototype"], -]; -for (const [test, description = typeof test] of tests) { - const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar(test)); - assert.throws( - TypeError, () => plainDate.until("2022-06-20", { largestUnit: "years" }), - `Expected error with ${description}` - ); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-mismatch.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-mismatch.js deleted file mode 100644 index 05c96de8c96..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-mismatch.js +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: RangeError thrown if calendars' id properties do not match -features: [Temporal] ----*/ - -const calendar1 = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "A", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const calendar2 = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "B", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const plainDate1 = new Temporal.PlainDate(2000, 1, 1, calendar1); -const plainDate2 = new Temporal.PlainDate(2000, 1, 1, calendar2); -assert.throws(RangeError, () => plainDate1.until(plainDate2)); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-temporal-object.js index c14e4796743..5688bc5ae0e 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const date = new Temporal.PlainDate(2000, 5, 2, temporalObject); + const date = new Temporal.PlainDate(2000, 5, 2, "iso8601"); date.until({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/custom.js b/test/built-ins/Temporal/PlainDate/prototype/until/custom.js deleted file mode 100644 index d11dc68640b..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/custom.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: Basic tests with custom calendar -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const result = new Temporal.Duration(1, 3, 5, 7, 9); -const options = { largestUnit: "years" }; -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateUntil(...args) { - ++calls; - assert.sameValue(args.length, 3, "Three arguments"); - assert.sameValue(args[0], plainDate, "First argument"); - assert.sameValue(args[1], other, "Second argument"); - assert.sameValue(args[2].largestUnit, "year", "Third argument: largestUnit"); - return result; - } -} -const calendar = new CustomCalendar(); -const plainDate = new Temporal.PlainDate(1976, 11, 18, calendar); -const other = new Temporal.PlainDate(2022, 6, 20, calendar); -TemporalHelpers.assertDuration(plainDate.until(other, options), - 1, 3, 5, 7, 0, 0, 0, 0, 0, 0, "result"); -assert.sameValue(calls, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-day.js b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-day.js new file mode 100644 index 00000000000..e8d6f2f671a --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-day.js @@ -0,0 +1,47 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: Date arithmetic with largestUnit "day" +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +["day", "days"].forEach(function(largestUnit) { + let opt = {largestUnit}; + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-16", opt), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-17", opt), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-17", opt), + 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, "32 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-09-16", opt), + 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, "62 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2022-07-16", opt), + 0, 0, 0, 365, 0, 0, 0, 0, 0, 0, "365 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2031-07-16", opt), + 0, 0, 0, 3652, 0, 0, 0, 0, 0, 0, "3652 days"); + + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-17").until("2021-07-16", opt), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-17").until("2021-07-16", opt), + 0, 0, 0, -32, 0, 0, 0, 0, 0, 0, "negative 32 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-09-16").until("2021-07-16", opt), + 0, 0, 0, -62, 0, 0, 0, 0, 0, 0, "negative 62 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2022-07-16").until("2021-07-16", opt), + 0, 0, 0, -365, 0, 0, 0, 0, 0, 0, "negative 365 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2031-07-16").until("2021-07-16", opt), + 0, 0, 0, -3652, 0, 0, 0, 0, 0, 0, "negative 3652 days"); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-month.js b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-month.js new file mode 100644 index 00000000000..d79d82a5241 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-month.js @@ -0,0 +1,83 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: Date arithmetic with largestUnit "month" +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +["month", "months"].forEach(function(largestUnit) { + let opt = {largestUnit}; + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-16", opt), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-17", opt), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-23", opt), + 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, "7 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-16", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2020-12-16").until("2021-01-16", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in different year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-01-05").until("2021-02-05", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-01-07").until("2021-03-07", opt), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 month in same year across Feb 28"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-17", opt), + 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, "1 month and 1 day in a month with 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-13", opt), + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, "28 days roll across a month which has 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-09-16", opt), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 months with both months which have 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2022-07-16", opt), + 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, "12 months"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2031-07-16", opt), + 0, 120, 0, 0, 0, 0, 0, 0, 0, 0, "120 months"); + + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-17").until("2021-07-16", opt), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-23").until("2021-07-16", opt), + 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, "negative 7 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-16").until("2021-07-16", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-01-16").until("2020-12-16", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in different year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-02-05").until("2021-01-05", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-03-07").until("2021-01-07", opt), + 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 month in same year across Feb 28"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-17").until("2021-07-16", opt), + 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, "negative 1 month and 1 day in a month with 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-13").until("2021-07-16", opt), + 0, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 28 days roll across a month which has 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-09-16").until("2021-07-16", opt), + 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 months with both months which have 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2022-07-16").until("2021-07-16", opt), + 0, -12, 0, 0, 0, 0, 0, 0, 0, 0, "negative 12 months"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2031-07-16").until("2021-07-16", opt), + 0, -120, 0, 0, 0, 0, 0, 0, 0, 0, "negative 120 months"); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-week.js b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-week.js new file mode 100644 index 00000000000..44e44dfab49 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-week.js @@ -0,0 +1,60 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: Date arithmetic with largestUnit "week" +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +["week", "weeks"].forEach(function(largestUnit) { + let opt = {largestUnit}; + + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-16", opt), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-17", opt), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-23", opt), + 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, "7 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-16", opt), + 0, 0, 4, 3, 0, 0, 0, 0, 0, 0, "4 weeks and 3 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-13", opt), + 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, "4 weeks"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-09-16", opt), + 0, 0, 8, 6, 0, 0, 0, 0, 0, 0, "8 weeks and 6 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2022-07-16", opt), + 0, 0, 52, 1, 0, 0, 0, 0, 0, 0, "52 weeks and 1 day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2031-07-16", opt), + 0, 0, 521, 5, 0, 0, 0, 0, 0, 0, "521 weeks and 5 days"); + + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-17").until("2021-07-16", opt), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-23").until("2021-07-16", opt), + 0, 0, -1, 0, 0, 0, 0, 0, 0, 0, "negative 7 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-16").until("2021-07-16", opt), + 0, 0, -4, -3, 0, 0, 0, 0, 0, 0, "negative 4 weeks and 3 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-13").until("2021-07-16", opt), + 0, 0, -4, 0, 0, 0, 0, 0, 0, 0, "negative 4 weeks"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-09-16").until("2021-07-16", opt), + 0, 0, -8, -6, 0, 0, 0, 0, 0, 0, "negative 8 weeks and 6 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2022-07-16").until("2021-07-16", opt), + 0, 0, -52, -1, 0, 0, 0, 0, 0, 0, "negative 52 weeks and 1 day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2031-07-16").until("2021-07-16", opt), + 0, 0, -521, -5, 0, 0, 0, 0, 0, 0, "negative 521 weeks and 5 days"); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-year.js b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-year.js new file mode 100644 index 00000000000..850c8de6766 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/largestunit-year.js @@ -0,0 +1,193 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: Date arithmetic with largestUnit "year" +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +["year", "years"].forEach(function(largestUnit) { + let opt = {largestUnit}; + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-16", opt), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-17", opt), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-23", opt), + 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, "7 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-16", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2020-12-16").until("2021-01-16", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in different year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-01-05").until("2021-02-05", opt), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, "1 month in same year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-01-07").until("2021-03-07", opt), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 month in same year across Feb 28"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-17", opt), + 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, "1 month and 1 day in a month with 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-13", opt), + 0, 0, 0, 28, 0, 0, 0, 0, 0, 0, "28 days roll across a month which has 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-09-16", opt), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, "2 months with both months which have 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2022-07-16", opt), + 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "1 year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2031-07-16", opt), + 10, 0, 0, 0, 0, 0, 0, 0, 0, 0, "10 years"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2022-07-19", opt), + 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, "1 year and 3 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2022-09-19", opt), + 1, 2, 0, 3, 0, 0, 0, 0, 0, 0, "1 year 2 months and 3 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2031-12-16", opt), + 10, 5, 0, 0, 0, 0, 0, 0, 0, 0, "10 years and 5 months"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("1997-12-16").until("2021-07-16", opt), + 23, 7, 0, 0, 0, 0, 0, 0, 0, 0, "23 years and 7 months"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("1997-07-16").until("2021-07-16", opt), + 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, "24 years"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("1997-07-16").until("2021-07-15", opt), + 23, 11, 0, 29, 0, 0, 0, 0, 0, 0, "23 years, 11 months and 29 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("1997-06-16").until("2021-06-15", opt), + 23, 11, 0, 30, 0, 0, 0, 0, 0, 0, "23 years, 11 months and 30 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("1960-02-16").until("2020-03-16", opt), + 60, 1, 0, 0, 0, 0, 0, 0, 0, 0, "60 years, 1 month"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("1960-02-16").until("2021-03-15", opt), + 61, 0, 0, 27, 0, 0, 0, 0, 0, 0, "61 years, 27 days in non leap year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("1960-02-16").until("2020-03-15", opt), + 60, 0, 0, 28, 0, 0, 0, 0, 0, 0, "60 years, 28 days in leap year"); + + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-03-30").until("2021-07-16", opt), + 0, 3, 0, 16, 0, 0, 0, 0, 0, 0, "3 months and 16 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2020-03-30").until("2021-07-16", opt), + 1, 3, 0, 16, 0, 0, 0, 0, 0, 0, "1 year, 3 months and 16 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("1960-03-30").until("2021-07-16", opt), + 61, 3, 0, 16, 0, 0, 0, 0, 0, 0, "61 years, 3 months and 16 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2019-12-30").until("2021-07-16", opt), + 1, 6, 0, 16, 0, 0, 0, 0, 0, 0, "1 year, 6 months and 16 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2020-12-30").until("2021-07-16", opt), + 0, 6, 0, 16, 0, 0, 0, 0, 0, 0, "6 months and 16 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("1997-12-30").until("2021-07-16", opt), + 23, 6, 0, 16, 0, 0, 0, 0, 0, 0, "23 years, 6 months and 16 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("0001-12-25").until("2021-07-16", opt), + 2019, 6, 0, 21, 0, 0, 0, 0, 0, 0, "2019 years, 6 months and 21 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2019-12-30").until("2021-03-05", opt), + 1, 2, 0, 5, 0, 0, 0, 0, 0, 0, "1 year, 2 months and 5 days"); + + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-17").until("2021-07-16", opt), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-23").until("2021-07-16", opt), + 0, 0, 0, -7, 0, 0, 0, 0, 0, 0, "negative 7 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-16").until("2021-07-16", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-01-16").until("2020-12-16", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in different year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-02-05").until("2021-01-05", opt), + 0, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 month in same year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-03-07").until("2021-01-07", opt), + 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 month in same year across Feb 28"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-17").until("2021-07-16", opt), + 0, -1, 0, -1, 0, 0, 0, 0, 0, 0, "negative 1 month and 1 day in a month with 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-13").until("2021-07-16", opt), + 0, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 28 days roll across a month which has 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-09-16").until("2021-07-16", opt), + 0, -2, 0, 0, 0, 0, 0, 0, 0, 0, "negative 2 months with both months which have 31 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2022-07-16").until("2021-07-16", opt), + -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "negative 1 year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2031-07-16").until("2021-07-16", opt), + -10, 0, 0, 0, 0, 0, 0, 0, 0, 0, "negative 10 years"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2022-07-19").until("2021-07-16", opt), + -1, 0, 0, -3, 0, 0, 0, 0, 0, 0, "negative 1 year and 3 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2022-09-19").until("2021-07-16", opt), + -1, -2, 0, -3, 0, 0, 0, 0, 0, 0, "negative 1 year 2 months and 3 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2031-12-16").until("2021-07-16", opt), + -10, -5, 0, 0, 0, 0, 0, 0, 0, 0, "negative 10 years and 5 months"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("1997-12-16", opt), + -23, -7, 0, 0, 0, 0, 0, 0, 0, 0, "negative 23 years and 7 months"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("1997-07-16", opt), + -24, 0, 0, 0, 0, 0, 0, 0, 0, 0, "negative 24 years"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-15").until("1997-07-16", opt), + -23, -11, 0, -30, 0, 0, 0, 0, 0, 0, "negative 23 years, 11 months and 30 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-06-15").until("1997-06-16", opt), + -23, -11, 0, -29, 0, 0, 0, 0, 0, 0, "negative 23 years, 11 months and 29 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2020-03-16").until("1960-02-16", opt), + -60, -1, 0, 0, 0, 0, 0, 0, 0, 0, "negative 60 years, 1 month"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-03-15").until("1960-02-16", opt), + -61, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 61 years, 28 days in non leap year"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2020-03-15").until("1960-02-16", opt), + -60, 0, 0, -28, 0, 0, 0, 0, 0, 0, "negative 60 years, 28 days in leap year"); + + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-03-30", opt), + 0, -3, 0, -17, 0, 0, 0, 0, 0, 0, "negative 3 months and 17 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2020-03-30", opt), + -1, -3, 0, -17, 0, 0, 0, 0, 0, 0, "negative 1 year, 3 months and 17 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("1960-03-30", opt), + -61, -3, 0, -17, 0, 0, 0, 0, 0, 0, "negative 61 years, 3 months and 17 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2019-12-30", opt), + -1, -6, 0, -17, 0, 0, 0, 0, 0, 0, "negative 1 year, 6 months and 17 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2020-12-30", opt), + 0, -6, 0, -17, 0, 0, 0, 0, 0, 0, "negative 6 months and 17 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("1997-12-30", opt), + -23, -6, 0, -17, 0, 0, 0, 0, 0, 0, "negative 23 years, 6 months and 17 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("0001-12-25", opt), + -2019, -6, 0, -22, 0, 0, 0, 0, 0, 0, "negative 2019 years, 6 months and 22 days"); + TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-03-05").until("2019-12-30", opt), + -1, -2, 0, -6, 0, 0, 0, 0, 0, 0, "negative 1 year, 2 months and 6 days"); +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/no-options.js b/test/built-ins/Temporal/PlainDate/prototype/until/no-options.js new file mode 100644 index 00000000000..dc686e63c1d --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/no-options.js @@ -0,0 +1,54 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: With no options +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. Set one to ? ToTemporalDate(one). + 5. Set two to ? ToTemporalDate(two). + 6. Set options to ? GetOptionsObject(options). + 7. Let largestUnit be ? ToLargestTemporalUnit(options, « "hour", "minute", "second", "millisecond", "microsecond", "nanosecond" », "auto", "day"). + 8. Let result be ! DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit). + 9. Return ? CreateTemporalDuration(result.[[Years]], result.[[Months]], result.[[Weeks]], result.[[Days]], 0, 0, 0, 0, 0, 0). +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-16"), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "same day"); +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-07-17"), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "one day"); +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-08-17"), + 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, "32 days"); +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2021-09-16"), + 0, 0, 0, 62, 0, 0, 0, 0, 0, 0, "62 days"); +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2022-07-16"), + 0, 0, 0, 365, 0, 0, 0, 0, 0, 0, "365 days"); +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-16").until("2031-07-16"), + 0, 0, 0, 3652, 0, 0, 0, 0, 0, 0, "3652 days"); + +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-07-17").until("2021-07-16"), + 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "negative one day"); +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-08-17").until("2021-07-16"), + 0, 0, 0, -32, 0, 0, 0, 0, 0, 0, "negative 32 days"); +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2021-09-16").until("2021-07-16"), + 0, 0, 0, -62, 0, 0, 0, 0, 0, 0, "negative 62 days"); +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2022-07-16").until("2021-07-16"), + 0, 0, 0, -365, 0, 0, 0, 0, 0, 0, "negative 365 days"); +TemporalHelpers.assertDuration( + Temporal.PlainDate.from("2031-07-16").until("2021-07-16"), + 0, 0, 0, -3652, 0, 0, 0, 0, 0, 0, "negative 3652 days"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js index 0807b344d8a..adce3da784b 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/until/order-of-operations.js @@ -11,30 +11,6 @@ features: [Temporal] const expected = [ // ToTemporalDate "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.dateFromFields", - "get other.calendar.fields", - "call other.calendar.fields", "get other.day", "get other.day.valueOf", "call other.day.valueOf", @@ -47,44 +23,31 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", - "call other.calendar.dateFromFields", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, ownCalendar); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); const otherDatePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, month: 6, monthCode: "M06", day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { @@ -98,97 +61,7 @@ function createOptionsObserver({ smallestUnit = "days", largestUnit = "auto", ro }, "options"); } -// clear any observable things that happened while constructing the objects -actual.splice(0); - // basic order of observable operations with calendar call, without rounding: instance.until(otherDatePropertyBag, createOptionsObserver({ largestUnit: "years" })); -assert.compareArray(actual, expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", -]), "order of operations"); +assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -// short-circuit for identical objects: - -const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 5, - monthCode: "M05", - day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); - -instance.since(identicalPropertyBag, createOptionsObserver()); -assert.compareArray(actual, expected, "order of operations with identical dates"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest year: -const expectedOpsForYearRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest year and skips a DateUntil call: -const otherDatePropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual, { - year: 2001, - month: 5, - monthCode: "M05", - day: 2, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); -const expectedOpsForYearRoundingSameMonth = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherDatePropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months/weeks"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest month: -const expectedOpsForMonthRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "months" })); -assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest week: -const expectedOpsForWeekRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateUntil", - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherDatePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); -assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/rounding-zero-year-month-week-length.js b/test/built-ins/Temporal/PlainDate/prototype/until/rounding-zero-year-month-week-length.js deleted file mode 100644 index 670d200281c..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/until/rounding-zero-year-month-week-length.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.until -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const d1 = new Temporal.PlainDate(1970, 1, 1, cal); -const d2 = new Temporal.PlainDate(1971, 1, 1, cal); - -assert.throws(RangeError, () => d1.until(d2, { smallestUnit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => d1.until(d2, { smallestUnit: "months" }), "zero month length handled correctly"); -assert.throws(RangeError, () => d1.until(d2, { smallestUnit: "weeks" }), "zero week length handled correctly"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/zero-length-duration-result.js b/test/built-ins/Temporal/PlainDate/prototype/until/zero-length-duration-result.js new file mode 100644 index 00000000000..58fdbc6c4e2 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/zero-length-duration-result.js @@ -0,0 +1,16 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: The duration from a date to itself is a zero duration (PT0S) +esid: sec-temporal.plaindate.prototype.until +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const date = new Temporal.PlainDate(2001, 6, 3); + +['year', 'month', 'week', 'day'].forEach((largestUnit) => { + const result = date.until(date, { largestUnit }); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, "The duration from a date to itself is zero") +}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 1605f26aca1..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.weekofyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const weekOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "weekOfYear"); -Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("weekOfYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.weekOfYear; - -Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", weekOfYearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom-calendar-weekofyear.js b/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom-calendar-weekofyear.js deleted file mode 100644 index 35261207ed9..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom-calendar-weekofyear.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.weekofyear -description: > - Temporal.PlainDate.prototype.weekOfYear returns undefined for all - custom calendars where weekOfYear() returns undefined. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - weekOfYear() { - return undefined; - } -} - -const calendar = new CustomCalendar(); -const customCalendarDate = new Temporal.PlainDate(2024, 1, 1, calendar); -assert.sameValue(customCalendarDate.weekOfYear, undefined); diff --git a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom.js deleted file mode 100644 index 22e9cb3d3a7..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.weekofyear -description: Custom calendar tests for weekOfYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - weekOfYear(...args) { - ++calls; - assert.compareArray(args, [pd], "weekOfYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.weekOfYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/validate-calendar-value.js deleted file mode 100644 index 0033b10161e..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/validate-calendar-value.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.weekofyear -description: Validate result returned from calendar weekOfYear() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - weekOfYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.weekOfYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDate/prototype/with/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 5b10fe3d3e0..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDate(2023, 5, 2, "iso8601"); -instance.with({ day: 5 }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/with/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 1880e425f6b..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); - }, -}); -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.with({ year: 2001 }); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDate/prototype/with/calendar-fields-iterable.js deleted file mode 100644 index 8e5da8e0540..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-fields-iterable.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.with -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindate.prototype.with step 9: - 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const date = new Temporal.PlainDate(2000, 5, 2, calendar); -date.with({ year: 2005 }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDate/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 985d7415db5..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.with -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -instance.with({ day: 24 }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-invalid-return.js b/test/built-ins/Temporal/PlainDate/prototype/with/calendar-invalid-return.js deleted file mode 100644 index 3a6afd17b30..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-invalid-return.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.with -description: Throw when the returned value from the calendar's dateFromFields method is not a PlainDate. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor(value) { - super("iso8601"); - this.value = value; - } - dateFromFields() { - return this.value; - } -} - -const tests = [ - [undefined], - [null, "null"], - [true], - ["2000-05"], - [Symbol()], - [200005], - [200005n], - [{}, "plain object"], - [() => {}, "lambda"], - [Temporal.PlainDate, "Temporal.PlainDate"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype"], -]; -for (const [test, description = typeof test] of tests) { - const plainDate = new Temporal.PlainDate(2000, 5, 2, new CustomCalendar(test)); - assert.throws(TypeError, () => plainDate.with({ year: 1 }), `Expected error with ${description}`); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-merge-fields-returns-primitive.js b/test/built-ins/Temporal/PlainDate/prototype/with/calendar-merge-fields-returns-primitive.js deleted file mode 100644 index e6271bfcd17..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-merge-fields-returns-primitive.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.with -description: > - with() should throw a TypeError if mergeFields() returns a primitive, - without passing the value on to any other calendar methods -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Symbol, Temporal] ----*/ - -[undefined, null, true, 3.14159, "bad value", Symbol("no"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarMergeFieldsReturnsPrimitive(primitive); - const instance = new Temporal.PlainDate(2000, 5, 2, calendar); - assert.throws(TypeError, () => instance.with({ year: 2005 }), "bad return from mergeFields() throws"); - assert.sameValue(calendar.dateFromFieldsCallCount, 0, "dateFromFields() never called"); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDate/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js deleted file mode 100644 index d422c91b8be..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.with -description: > - Calendar.mergeFields method is called with null-prototype fields objects -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckMergeFieldsPrototypePollution(); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); -instance.with({ day: 24 }); -assert.sameValue(calendar.mergeFieldsCallCount, 1, "mergeFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/with/constructor-in-calendar-fields.js deleted file mode 100644 index 67cc276cf35..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.with -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const date = new Temporal.PlainDate(2023, 5, 1, calendar); - -assert.throws(RangeError, () => date.with({day: 15})); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/copies-merge-fields-object.js b/test/built-ins/Temporal/PlainDate/prototype/with/copies-merge-fields-object.js deleted file mode 100644 index 3a55993bc82..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/copies-merge-fields-object.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.with -description: The object returned from mergeFields() is copied before being passed to dateFromFields(). -info: | - sec-temporal.plaindate.prototype.with steps 13–15: - 13. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialDate_). - 14. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, «»). - 15. Return ? DateFromFields(_calendar_, _fields_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get day", - "get day.valueOf", - "call day.valueOf", - "get month", - "get month.valueOf", - "call month.valueOf", - "get monthCode", - "get monthCode.toString", - "call monthCode.toString", - "get year", - "get year.valueOf", - "call year.valueOf", -]; - -const calendar = TemporalHelpers.calendarMergeFieldsGetters(); -const date = new Temporal.PlainDate(2021, 3, 31, calendar); -date.with({ year: 2022 }); - -assert.compareArray(calendar.mergeFieldsReturnOperations, expected, "getters called on mergeFields return"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/custom.js b/test/built-ins/Temporal/PlainDate/prototype/with/custom.js deleted file mode 100644 index 16109882870..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/custom.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.with -description: Basic tests with custom calendar -features: [Temporal] ----*/ - -const result = new Temporal.PlainDate(1920, 5, 3); -const options = { - extra: "property", -}; -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateFromFields(...args) { - ++calls; - assert.sameValue(args.length, 2, "Two arguments"); - assert.sameValue(typeof args[0], "object", "First argument: type"); - assert.sameValue(args[0].day, 18, "First argument: day"); - assert.sameValue(args[0].month, 11, "First argument: month"); - assert.sameValue(args[0].monthCode, "M11", "First argument: monthCode"); - assert.sameValue(args[0].year, 43, "First argument: year"); - assert.notSameValue(args[1], options, "Second argument is a copy of options"); - assert.sameValue(args[1].extra, "property", "All properties are copied"); - assert.sameValue(Object.getPrototypeOf(args[1]), null, "Copy has null prototype"); - return result; - } -} -const calendar = new CustomCalendar(); -const plainDate = new Temporal.PlainDate(1976, 11, 18, calendar); -assert.sameValue(plainDate.with({ year: 43 }, options), result); -assert.sameValue(calls, 1); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/with/duplicate-calendar-fields.js deleted file mode 100644 index 5e895c43edc..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.with -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['month'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const date = new Temporal.PlainDate(2023, 5, 1, calendar); - - assert.throws(RangeError, () => date.with({day: 15})); -} diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/order-of-operations.js b/test/built-ins/Temporal/PlainDate/prototype/with/order-of-operations.js index 1bdc7103a6c..3e3d1b1df5f 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDate/prototype/with/order-of-operations.js @@ -12,27 +12,10 @@ const expected = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", + // GetTemporalOverflowOption "get options.overflow", - "getOwnPropertyDescriptor options.extra", - "get options.extra", - // lookup - "get this.calendar.dateFromFields", - "get this.calendar.fields", - "get this.calendar.mergeFields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields on receiver - "get this.calendar.day", - "call this.calendar.day", - "get this.calendar.month", - "call this.calendar.month", - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", + "get options.overflow.toString", + "call options.overflow.toString", // PrepareTemporalFields on argument "get fields.day", "get fields.day.valueOf", @@ -46,18 +29,10 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", - // CalendarMergeFields - "call this.calendar.mergeFields", - // CalendarDateFromFields - "call this.calendar.dateFromFields", - // inside Calendar.p.dateFromFields - "get options.overflow.toString", - "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDate(2000, 5, 2, calendar); +const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); // clear observable operations that occurred during the constructor call actual.splice(0); diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDate/prototype/with/proto-in-calendar-fields.js deleted file mode 100644 index 3b0d5d9ffcb..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/with/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindate.prototype.with -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const date = new Temporal.PlainDate(2023, 5, 1, calendar); - -assert.throws(RangeError, () => date.with({day: 15})); diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/basic.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/basic.js index cdf6f3807c0..e28b9046739 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/basic.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/basic.js @@ -9,20 +9,9 @@ features: [Temporal] ---*/ const plainDate = Temporal.PlainDate.from("1976-11-18"); -const calendar = Temporal.Calendar.from("iso8601"); - -const objectResult = plainDate.withCalendar(calendar); -assert.notSameValue(objectResult, plainDate, "object: new object"); -TemporalHelpers.assertPlainDate(objectResult, 1976, 11, "M11", 18, "object"); -assert.sameValue(objectResult.getCalendar(), calendar, "object: calendar"); +const calendar = "iso8601"; const stringResult = plainDate.withCalendar("iso8601"); assert.notSameValue(stringResult, plainDate, "string: new object"); TemporalHelpers.assertPlainDate(stringResult, 1976, 11, "M11", 18, "string"); -assert.sameValue(stringResult.getISOFields().calendar, "iso8601", "string: calendar slot stores a string"); - -const originalCalendar = plainDate.getCalendar(); -const sameResult = plainDate.withCalendar(originalCalendar); -assert.notSameValue(sameResult, plainDate, "original: new object"); -TemporalHelpers.assertPlainDate(sameResult, 1976, 11, "M11", 18, "original"); -assert.sameValue(sameResult.getCalendar(), originalCalendar, "original: calendar slot stores and object"); +assert.sameValue(stringResult.calendarId, "iso8601", "string: calendar is iso8601"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/branding.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/branding.js index 964b62ac283..3b259990998 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/branding.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/branding.js @@ -11,7 +11,7 @@ const withCalendar = Temporal.PlainDate.prototype.withCalendar; assert.sameValue(typeof withCalendar, "function"); -const args = [new Temporal.Calendar("iso8601")]; +const args = ["iso8601"]; assert.throws(TypeError, () => withCalendar.apply(undefined, args), "undefined"); assert.throws(TypeError, () => withCalendar.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 4c2a9524d81..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.withcalendar -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.withCalendar("iso8601"); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-case-insensitive.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-case-insensitive.js index 6a0ce65d69d..db18d84e8aa 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-case-insensitive.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-case-insensitive.js @@ -7,29 +7,7 @@ description: Calendar names are case-insensitive features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDate(1976, 11, 18, "iso8601"); let arg = "iSo8601"; const result = instance.withCalendar(arg); diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-iso-string.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-iso-string.js index aa99e6cae0a..b13cbcfdc47 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-iso-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-iso-string.js @@ -7,29 +7,7 @@ description: An ISO 8601 string can be converted to a calendar ID in Calendar features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDate(1976, 11, 18, "iso8601"); for (const arg of [ "2020-01-01", @@ -42,5 +20,5 @@ for (const arg of [ "2020-01[u-ca=iso8601]", ]) { const result = instance.withCalendar(arg); - assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); + assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); } diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-number.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-number.js index 370ebb6af83..e0cfb967959 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-number.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-number.js @@ -7,29 +7,7 @@ description: A number is not allowed to be a calendar features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDate(1976, 11, 18, "iso8601"); const numbers = [ 1, diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string-leap-second.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string-leap-second.js index 604f6085381..c73c5449dc6 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string-leap-second.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string-leap-second.js @@ -7,29 +7,7 @@ description: Leap second is a valid ISO string for Calendar features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDate(1976, 11, 18, "iso8601"); const arg = "2016-12-31T23:59:60"; const result = instance.withCalendar(arg); diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string.js index 90a2149df6c..90095e884fa 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-string.js @@ -7,31 +7,9 @@ description: A calendar ID is valid input for Calendar features: [Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDate(1976, 11, 18, "iso8601"); const arg = "iso8601"; const result = instance.withCalendar(arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-temporal-object.js index 24ba4c7d1eb..43d2ed729ea 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-temporal-object.js @@ -3,7 +3,9 @@ /*--- esid: sec-temporal.plaindate.prototype.withcalendar -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots +description: > + Fast path for converting other Temporal objects to calendar ID by reading + internal slots info: | sec-temporal-totemporalcalendar step 1.b: b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then @@ -22,8 +24,6 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT const actual = []; const expected = []; - const calendar = arg.getISOFields().calendar; - Object.defineProperty(arg, "calendar", { get() { actual.push("get calendar"); @@ -31,31 +31,9 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT }, }); - const instance = new Temporal.PlainDate(1976, 11, 18, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); + const instance = new Temporal.PlainDate(1976, 11, 18, "iso8601"); const result = instance.withCalendar(arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar"); assert.compareArray(actual, expected, "calendar getter not called"); }); diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js index a637c317fc5..944eec4a608 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/calendar-wrong-type.js @@ -5,33 +5,11 @@ esid: sec-temporal.plaindate.prototype.withcalendar description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar + for Calendar features: [BigInt, Symbol, Temporal] ---*/ -const instance = new Temporal.PlainDate(1976, 11, 18, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDate(1976, 11, 18, "iso8601"); const primitiveTests = [ [null, "null"], @@ -51,9 +29,8 @@ for (const [arg, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [arg, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/subclassing-ignored.js b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/subclassing-ignored.js index 5c0595831dc..4f763912e8d 100644 --- a/test/built-ins/Temporal/PlainDate/prototype/withCalendar/subclassing-ignored.js +++ b/test/built-ins/Temporal/PlainDate/prototype/withCalendar/subclassing-ignored.js @@ -8,40 +8,13 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const customCalendar = { - era() { return undefined; }, - eraYear() { return undefined; }, - year() { return 1900; }, - month() { return 2; }, - monthCode() { return "M02"; }, - day() { return 5; }, - id: "custom-calendar", - toString() { return "custom-calendar"; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - TemporalHelpers.checkSubclassingIgnored( Temporal.PlainDate, [2000, 5, 2], "withCalendar", - [customCalendar], + ["iso8601"], (result) => { - TemporalHelpers.assertPlainDate(result, 1900, 2, "M02", 5); - assert.sameValue(result.getCalendar(), customCalendar, "calendar result"); + TemporalHelpers.assertPlainDate(result, 2000, 5, "M05", 2); + assert.sameValue(result.calendarId, "iso8601", "calendar result"); }, ); diff --git a/test/built-ins/Temporal/PlainDate/prototype/year/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/year/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 55f6be8a71d..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/year/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.year -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const yearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "year"); -Object.defineProperty(Temporal.Calendar.prototype, "year", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("year should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.year; - -Object.defineProperty(Temporal.Calendar.prototype, "year", yearOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/year/custom.js b/test/built-ins/Temporal/PlainDate/prototype/year/custom.js deleted file mode 100644 index 8d1a50eb55b..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/year/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.year -description: Custom calendar tests for year(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - year(...args) { - ++calls; - assert.compareArray(args, [pd], "year arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.year; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/year/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/year/validate-calendar-value.js deleted file mode 100644 index 6399e5380b5..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/year/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.year -description: Validate result returned from calendar year() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [NaN, RangeError], - ["string", TypeError], - [{}, TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, RangeError], - [-0.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - year() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.year, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - year() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.sameValue(instance.year, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js deleted file mode 100644 index a56c732cf3e..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.yearofweek -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const yearOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearOfWeek"); -Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("yearOfWeek should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDate(2000, 5, 2, "iso8601"); -instance.yearOfWeek; - -Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", yearOfWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom-calendar-weekofyear.js b/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom-calendar-weekofyear.js deleted file mode 100644 index fdb51a1b172..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom-calendar-weekofyear.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.yearofweek -description: > - Temporal.PlainDate.prototype.yearOfWeek returns undefined for all - custom calendars where yearOfWeek() returns undefined. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearOfWeek() { - return undefined; - } -} - -const calendar = new CustomCalendar(); -const customCalendarDate = new Temporal.PlainDate(2024, 1, 1, calendar); -assert.sameValue(customCalendarDate.yearOfWeek, undefined); diff --git a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom.js b/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom.js deleted file mode 100644 index 85431118585..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.yearofweek -description: Custom calendar tests for yearOfWeek(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearOfWeek(...args) { - ++calls; - assert.compareArray(args, [pd], "yearOfWeek arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pd = new Temporal.PlainDate(1830, 8, 25, calendar); -const result = pd.yearOfWeek; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js b/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js deleted file mode 100644 index e8f682dad2f..00000000000 --- a/test/built-ins/Temporal/PlainDate/prototype/yearOfWeek/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.yearofweek -description: Validate result returned from calendar yearOfWeek() method -features: [Temporal] ----*/ - -const badResults = [ - [Infinity, RangeError], - [-Infinity, RangeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [NaN, RangeError], - ["string", TypeError], - [{}, TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, RangeError], - [-0.1, RangeError], - [NaN, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - yearOfWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.yearOfWeek, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - yearOfWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.sameValue(instance.yearOfWeek, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/calendar-iso-string.js b/test/built-ins/Temporal/PlainDateTime/calendar-iso-string.js new file mode 100644 index 00000000000..4bc1431607b --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/calendar-iso-string.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.constructor +description: An ISO string is not valid input for a constructor's calendar param +features: [Temporal] +---*/ + +assert.throws( + RangeError, + () => new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, "1997-12-04[u-ca=iso8601]"), + "An ISO string is not a valid calendar ID for constructor parameter" +); diff --git a/test/built-ins/Temporal/PlainDateTime/calendar-string.js b/test/built-ins/Temporal/PlainDateTime/calendar-string.js index 450c24c3a59..d1e4f9331d8 100644 --- a/test/built-ins/Temporal/PlainDateTime/calendar-string.js +++ b/test/built-ins/Temporal/PlainDateTime/calendar-string.js @@ -10,4 +10,4 @@ features: [Temporal] const arg = "iso8601"; const result = new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/PlainDateTime/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/calendar-temporal-object.js deleted file mode 100644 index 0ef5ca40a89..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/calendar-temporal-object.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const result = new Temporal.PlainDateTime(2000, 5, 2, 15, 23, 30, 987, 654, 321, arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/calendar-undefined.js b/test/built-ins/Temporal/PlainDateTime/calendar-undefined.js index e4a692d2632..2654cb8e88b 100644 --- a/test/built-ins/Temporal/PlainDateTime/calendar-undefined.js +++ b/test/built-ins/Temporal/PlainDateTime/calendar-undefined.js @@ -9,12 +9,6 @@ features: [Temporal] const dateTimeArgs = [2020, 12, 24, 12, 34, 56, 123, 456, 789]; -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - const dateTimeExplicit = new Temporal.PlainDateTime(...dateTimeArgs, undefined); assert.sameValue(dateTimeExplicit.calendarId, "iso8601"); diff --git a/test/built-ins/Temporal/PlainDateTime/calendar-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/calendar-wrong-type.js index 531a710f6e2..b76c42f7175 100644 --- a/test/built-ins/Temporal/PlainDateTime/calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plaindatetime description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar + for Calendar features: [BigInt, Symbol, Temporal] ---*/ @@ -27,9 +27,8 @@ for (const [arg, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [arg, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index dfcd0d2bd37..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.compare -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, calendar: "iso8601" }; -Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18)); -Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-string.js index c5b7858472f..4fada99c0b3 100644 --- a/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-string.js @@ -4,19 +4,9 @@ /*--- esid: sec-temporal.plaindatetime.compare description: A calendar ID is valid input for Calendar -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - const calendar = "iso8601"; const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; @@ -26,5 +16,3 @@ assert.sameValue(result1, 0, `Calendar created from string "${arg}" (first argum const result2 = Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg); assert.sameValue(result2, 0, `Calendar created from string "${arg}" (second argument)`); - -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-wrong-type.js index f91c49c253f..fae20dd9f16 100644 --- a/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plaindatetime.compare description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ @@ -33,10 +33,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index c10ddd89adc..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.compare -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, Infinity, -Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => Temporal.PlainDateTime.compare(datetime, plain)); - assert.throws(RangeError, () => Temporal.PlainDateTime.compare(plain, datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 2abee235936..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.compare -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.PlainDateTime.compare(datetime, plain), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); - assert.throws( - TypeError, - () => Temporal.PlainDateTime.compare(plain, datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 2326c5adb2a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.compare -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => Temporal.PlainDateTime.compare(datetime, plain)); - assert.throws(RangeError, () => Temporal.PlainDateTime.compare(plain, datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index d113b03b473..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.compare -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - - assert.throws(TypeError, () => Temporal.PlainDateTime.compare(datetime, plain)); - assert.throws(TypeError, () => Temporal.PlainDateTime.compare(plain, datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/compare/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index c772880030b..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.compare -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const arg1 = { year: 2000, month: 5, day: 2, calendar }; -const arg2 = new Temporal.PlainDateTime(1976, 11, 18); - -Temporal.PlainDateTime.compare(arg1, arg2); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar (first argument)"); - -calendar.dateFromFieldsCallCount = 0; - -Temporal.PlainDateTime.compare(arg2, arg1); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar (second argument)"); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/compare/calendar-fields-iterable.js deleted file mode 100644 index e18745c3533..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/calendar-fields-iterable.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.compare -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindatetime.compare steps 1–2: - 1. Set _one_ to ? ToTemporalDateTime(_one_). - 2. Set _two_ to ? ToTemporalDateTime(_two_). - sec-temporal-totemporaldatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -Temporal.PlainDateTime.compare( - { year: 2000, month: 5, day: 2, calendar: calendar1 }, - { year: 2001, month: 6, day: 3, calendar: calendar2 }, -); - -assert.sameValue(calendar1.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar1.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar1.iteratorExhausted[0], "iterated through the whole iterable"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/calendar-ignored.js b/test/built-ins/Temporal/PlainDateTime/compare/calendar-ignored.js deleted file mode 100644 index 42b53741fa3..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/calendar-ignored.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.compare -description: Calendar is not taken into account for the comparison. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar1 = TemporalHelpers.calendarThrowEverything(); -const calendar2 = TemporalHelpers.calendarThrowEverything(); -const dt1 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar1); -const dt2 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar1); -const dt3 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar1); -const dt4 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar2); - -assert.sameValue(Temporal.PlainDateTime.compare(dt1, dt2), -1, "smaller"); -assert.sameValue(Temporal.PlainDateTime.compare(dt2, dt3), 0, "equal with same calendar"); -assert.sameValue(Temporal.PlainDateTime.compare(dt2, dt4), 0, "equal with different calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/compare/constructor-in-calendar-fields.js deleted file mode 100644 index 6883de7a817..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.compare -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18))); -assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/compare/duplicate-calendar-fields.js deleted file mode 100644 index 8176133e82d..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/duplicate-calendar-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.compare -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - - assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18))); - assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg)); -} diff --git a/test/built-ins/Temporal/PlainDateTime/compare/exhaustive.js b/test/built-ins/Temporal/PlainDateTime/compare/exhaustive.js index ae19ccbf271..d1043059e30 100644 --- a/test/built-ins/Temporal/PlainDateTime/compare/exhaustive.js +++ b/test/built-ins/Temporal/PlainDateTime/compare/exhaustive.js @@ -7,157 +7,154 @@ description: Tests for compare() with each possible outcome features: [Temporal] ---*/ -const cal1 = "iso8601"; -const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601"); - assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1), - new Temporal.PlainDateTime(1987, 5, 31, 12, 15, 45, 333, 777, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111), + new Temporal.PlainDateTime(1987, 5, 31, 12, 15, 45, 333, 777, 111) ), 1, "year >" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(1981, 12, 15, 6, 30, 15, 222, 444, 6, cal1), - new Temporal.PlainDateTime(2048, 12, 15, 6, 30, 15, 222, 444, 6, cal2) + new Temporal.PlainDateTime(1981, 12, 15, 6, 30, 15, 222, 444, 6), + new Temporal.PlainDateTime(2048, 12, 15, 6, 30, 15, 222, 444, 6) ), -1, "year <" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1), - new Temporal.PlainDateTime(2000, 3, 31, 12, 15, 45, 333, 777, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111), + new Temporal.PlainDateTime(2000, 3, 31, 12, 15, 45, 333, 777, 111) ), 1, "month >" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal1), - new Temporal.PlainDateTime(1981, 12, 15, 6, 30, 15, 222, 444, 6, cal2) + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6), + new Temporal.PlainDateTime(1981, 12, 15, 6, 30, 15, 222, 444, 6) ), -1, "month <" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1), - new Temporal.PlainDateTime(2000, 5, 14, 12, 15, 45, 333, 777, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111), + new Temporal.PlainDateTime(2000, 5, 14, 12, 15, 45, 333, 777, 111) ), 1, "day >" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal1), - new Temporal.PlainDateTime(1981, 4, 21, 6, 30, 15, 222, 444, 6, cal2) + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6), + new Temporal.PlainDateTime(1981, 4, 21, 6, 30, 15, 222, 444, 6) ), -1, "day <" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1), - new Temporal.PlainDateTime(2000, 5, 31, 6, 15, 45, 333, 777, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111), + new Temporal.PlainDateTime(2000, 5, 31, 6, 15, 45, 333, 777, 111) ), 1, "hour >" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal1), - new Temporal.PlainDateTime(1981, 4, 15, 22, 30, 15, 222, 444, 6, cal2) + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6), + new Temporal.PlainDateTime(1981, 4, 15, 22, 30, 15, 222, 444, 6) ), -1, "hour <" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1), - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 22, 333, 777, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111), + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 22, 333, 777, 111) ), 1, "minute >" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal1), - new Temporal.PlainDateTime(1981, 4, 15, 6, 57, 15, 222, 444, 6, cal2) + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6), + new Temporal.PlainDateTime(1981, 4, 15, 6, 57, 15, 222, 444, 6) ), -1, "minute <" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 6, 333, 777, 111, cal1), - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 5, 333, 777, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 6, 333, 777, 111), + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 5, 333, 777, 111) ), 1, "second >" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 3, 222, 444, 6, cal1), - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 4, 222, 444, 6, cal2) + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 3, 222, 444, 6), + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 4, 222, 444, 6) ), -1, "second <" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 6, 777, 111, cal1), - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 5, 777, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 6, 777, 111), + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 5, 777, 111) ), 1, "millisecond >" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 3, 444, 6, cal1), - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 4, 444, 6, cal2) + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 3, 444, 6), + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 4, 444, 6) ), -1, "millisecond <" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 6, 111, cal1), - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 5, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 6, 111), + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 5, 111) ), 1, "microsecond >" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 3, 6, cal1), - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 4, 6, cal2) + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 3, 6), + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 4, 6) ), -1, "microsecond <" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 999, cal1), - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 999), + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111) ), 1, "nanosecond >" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 0, cal1), - new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6, cal2) + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 0), + new Temporal.PlainDateTime(1981, 4, 15, 6, 30, 15, 222, 444, 6) ), -1, "nanosecond <" ); assert.sameValue( Temporal.PlainDateTime.compare( - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal1), - new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111, cal2) + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111), + new Temporal.PlainDateTime(2000, 5, 31, 12, 15, 45, 333, 777, 111) ), 0, "=" diff --git a/test/built-ins/Temporal/PlainDateTime/compare/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/compare/proto-in-calendar-fields.js deleted file mode 100644 index ecca8b72c07..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.compare -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainDateTime.compare(arg, new Temporal.PlainDateTime(1976, 11, 18))); -assert.throws(RangeError, () => Temporal.PlainDateTime.compare(new Temporal.PlainDateTime(1976, 11, 18), arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/compare/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/PlainDateTime/compare/read-time-fields-before-datefromfields.js deleted file mode 100644 index 5e5ca28556e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/compare/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.compare -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.plaindatetime.compare steps 1–2: - 1. Set _one_ to ? ToTemporalDateTime(_one_). - 2. Set _two_ to ? ToTemporalDateTime(_two_). - sec-temporal-totemporaldatetime step 2.e: - e. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const result = Temporal.PlainDateTime.compare( - { year: 2000, month: 5, day: 2, hour: 12, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321, calendar }, - { year: 2000, month: 5, day: 2, hour: 6, minute: 54, second: 32, millisecond: 123, microsecond: 456, nanosecond: 789, calendar }, -); - -// will be 0 if the time fields are coerced to their max values due to Infinity -assert.sameValue(result, 1, "comparison result"); diff --git a/test/built-ins/Temporal/PlainDateTime/constructor-full.js b/test/built-ins/Temporal/PlainDateTime/constructor-full.js index 677ac59c19c..2f9cb153cd9 100644 --- a/test/built-ins/Temporal/PlainDateTime/constructor-full.js +++ b/test/built-ins/Temporal/PlainDateTime/constructor-full.js @@ -8,8 +8,7 @@ features: [Temporal] includes: [temporalHelpers.js] ---*/ -const calendar = Temporal.Calendar.from("iso8601"); -const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar); +const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); TemporalHelpers.assertPlainDateTime(datetime, 1976, 11, "M11", 18, 15, 23, 30, 123, 456, 789, @@ -17,7 +16,7 @@ TemporalHelpers.assertPlainDateTime(datetime, ); assert.sameValue( - datetime.getCalendar(), - calendar, + datetime.calendarId, + "iso8601", "calendar supplied in constructor can be extracted and is unchanged" ); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDateTime/from/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index c1e98f5f4f4..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.from -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, calendar: "iso8601" }; -Temporal.PlainDateTime.from(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-plaindate.js b/test/built-ins/Temporal/PlainDateTime/from/argument-plaindate.js index 693abbdb65d..e38fc4f742d 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-plaindate.js +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-plaindate.js @@ -14,8 +14,8 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => { +TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => { const result = Temporal.PlainDateTime.from(date); TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 0, 0, 0, 0, 0, 0, "midnight is assumed"); - assert.sameValue(result.getCalendar(), calendar, "calendar result"); + assert.sameValue(result.calendarId, "iso8601", "calendar result"); }); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-plaindatetime.js b/test/built-ins/Temporal/PlainDateTime/from/argument-plaindatetime.js index ea0a21bf238..6b3db78c0a5 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-plaindatetime.js +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-plaindatetime.js @@ -17,7 +17,7 @@ TemporalHelpers.assertPlainDateTime( "PlainDateTime is copied" ); -assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied"); +assert.sameValue(result.calendarId, orig.calendarId, "Calendar is copied"); assert.notSameValue( result, diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-iso-string.js index 46bf466c9e1..cb54d4f983d 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-iso-string.js +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-iso-string.js @@ -21,5 +21,5 @@ for (const calendar of [ const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; const result = Temporal.PlainDateTime.from(arg); TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); - assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); + assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); } diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-string.js index 70ff0507f68..9b8617afc46 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-string.js @@ -13,4 +13,4 @@ const calendar = "iso8601"; const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; const result = Temporal.PlainDateTime.from(arg); TemporalHelpers.assertPlainDateTime(result, 1976, 11, "M11", 18, 0, 0, 0, 0, 0, 0, `Calendar created from string "${calendar}"`); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-wrong-type.js index 108f2862e4d..092c83c9eab 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-propertybag-calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plaindatetime.from description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ @@ -28,10 +28,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-balance-negative-time-units.js index 83b4f71311a..76ce252d771 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-balance-negative-time-units.js @@ -35,9 +35,8 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); const pdt = Temporal.PlainDateTime.from(datetime); -TemporalHelpers.assertPlainDateTime(pdt, 1970, 1, "M01", 1, 1, 1, 1, 1, 0, 999); +TemporalHelpers.assertPlainDateTime(pdt, 1970, 1, "M01", 1, 0, 59, 1, 1, 1, 1); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index f95ca760908..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.from -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => Temporal.PlainDateTime.from(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index f905463f1ca..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.from -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.PlainDateTime.from(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index f0f685b23a9..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.from -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => Temporal.PlainDateTime.from(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 846b9d3733d..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.from -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => Temporal.PlainDateTime.from(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/from/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/from/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 0dfc7e0ff34..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.from -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const arg = { year: 2000, month: 5, day: 2, calendar }; -Temporal.PlainDateTime.from(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/from/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/from/calendar-fields-iterable.js deleted file mode 100644 index d2e5ae473fb..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/calendar-fields-iterable.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.from -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindatetime.from step 3: - 3. Return ? ToTemporalDateTime(_item_, _options_). - sec-temporal-totemporaldatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDateTime/from/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/from/calendar-temporal-object.js index 3659a257c81..fc66891a053 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDateTime/from/calendar-temporal-object.js @@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, calendar: temporalObject }); - assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/PlainDateTime/from/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/from/constructor-in-calendar-fields.js deleted file mode 100644 index 94398829310..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.from -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/from/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/from/duplicate-calendar-fields.js deleted file mode 100644 index 7e25ff716b0..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.from -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - - assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg)); -} diff --git a/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-primitive.js index babe403a9cd..252511ed7a7 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-primitive.js +++ b/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-primitive.js @@ -9,8 +9,6 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", @@ -24,11 +22,6 @@ assert.compareArray(actual, expected, "Successful call"); TemporalHelpers.assertPlainDateTime(result, 2021, 5, "M05", 17, 12, 34, 56, 0, 0, 0); actual.splice(0); // empty it for the next check -const failureExpected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", -]; assert.throws(TypeError, () => Temporal.PlainDateTime.from(7, options)); -assert.compareArray(actual, failureExpected, "Failing call"); +assert.compareArray(actual, expected, "Failing call"); diff --git a/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-string-invalid.js index 9eff4e745b5..1fd76087a5a 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-string-invalid.js +++ b/test/built-ins/Temporal/PlainDateTime/from/observable-get-overflow-argument-string-invalid.js @@ -9,9 +9,9 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", ]; let actual = []; diff --git a/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js index 1bda6e21710..f19ffb35227 100644 --- a/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/from/order-of-operations.js @@ -9,40 +9,12 @@ features: [Temporal] ---*/ const expected = [ - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", + // GetTemporalOverflowOption "get options.overflow", - "getOwnPropertyDescriptor options.extra", - "get options.extra", + "get options.overflow.toString", + "call options.overflow.toString", // GetTemporalCalendarSlotValueWithISODefault "get fields.calendar", - "has fields.calendar.dateAdd", - "has fields.calendar.dateFromFields", - "has fields.calendar.dateUntil", - "has fields.calendar.day", - "has fields.calendar.dayOfWeek", - "has fields.calendar.dayOfYear", - "has fields.calendar.daysInMonth", - "has fields.calendar.daysInWeek", - "has fields.calendar.daysInYear", - "has fields.calendar.fields", - "has fields.calendar.id", - "has fields.calendar.inLeapYear", - "has fields.calendar.mergeFields", - "has fields.calendar.month", - "has fields.calendar.monthCode", - "has fields.calendar.monthDayFromFields", - "has fields.calendar.monthsInYear", - "has fields.calendar.weekOfYear", - "has fields.calendar.year", - "has fields.calendar.yearMonthFromFields", - "has fields.calendar.yearOfWeek", - // lookup - "get fields.calendar.dateFromFields", - "get fields.calendar.fields", - // CalendarFields - "call fields.calendar.fields", // PrepareTemporalFields "get fields.day", "get fields.day.valueOf", @@ -74,10 +46,6 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", - // InterpretTemporalDateTimeFields - "get options.overflow.toString", - "call options.overflow.toString", - "call fields.calendar.dateFromFields", ]; const actual = []; @@ -92,8 +60,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { millisecond: 1.7, microsecond: 1.7, nanosecond: 1.7, - calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), -}, "fields"); + calendar: "iso8601", +}, "fields", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", diff --git a/test/built-ins/Temporal/PlainDateTime/from/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/from/proto-in-calendar-fields.js deleted file mode 100644 index 485df8ba912..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.from -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainDateTime.from(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/from/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/PlainDateTime/from/read-time-fields-before-datefromfields.js deleted file mode 100644 index e24ca12d4a6..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/from/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.from -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.plaindatetime.from step 3: - 3. Return ? ToTemporalDateTime(_item_, _options_). - sec-temporal-totemporaldatetime step 2.e: - e. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321, calendar }); - -assert.sameValue(datetime.hour, 12, "hour value"); -assert.sameValue(datetime.minute, 34, "minute value"); -assert.sameValue(datetime.second, 56, "second value"); -assert.sameValue(datetime.millisecond, 987, "millisecond value"); -assert.sameValue(datetime.microsecond, 654, "microsecond value"); -assert.sameValue(datetime.nanosecond, 321, "nanosecond value"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/add/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/add/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 64aedee8e73..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/add/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.add -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.add(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/add/calendar-dateadd.js b/test/built-ins/Temporal/PlainDateTime/prototype/add/calendar-dateadd.js deleted file mode 100644 index 25f858886f8..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/add/calendar-dateadd.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.add -description: PlainDateTime.prototype.add should call dateAdd with the appropriate values. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(plainDate, duration, options) { - ++calls; - TemporalHelpers.assertPlainDate(plainDate, 2020, 3, "M03", 14, "plainDate argument"); - TemporalHelpers.assertDuration(duration, 0, 10, 0, 1, 0, 0, 0, 0, 0, 0, "duration argument"); - assert.sameValue(typeof options, "object", "options argument: type"); - assert.sameValue(Object.getPrototypeOf(options), null, "options argument: prototype"); - return super.dateAdd(plainDate, duration, options); - } -} - -const plainDateTime = new Temporal.PlainDateTime(2020, 3, 14, 12, 34, 56, 987, 654, 321, new CustomCalendar()); -const result = plainDateTime.add({ months: 10, hours: 14 }); -TemporalHelpers.assertPlainDateTime(result, 2021, 1, "M01", 15, 2, 34, 56, 987, 654, 321); -assert.sameValue(calls, 1, "should have called dateAdd"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js index 5230e93b7b2..10a5c9e45db 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/add/order-of-operations.js @@ -40,18 +40,13 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", - // AddDateTime -> AddDate - "get this.calendar.dateAdd", - "call this.calendar.dateAdd", - // inside Calendar.p.dateAdd "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); // clear observable operations that occurred during the constructor call actual.splice(0); @@ -74,51 +69,3 @@ instance.add(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -const noCalendarExpected = [ - // ToTemporalDurationRecord - "get fields.days", - "get fields.days.valueOf", - "call fields.days.valueOf", - "get fields.hours", - "get fields.hours.valueOf", - "call fields.hours.valueOf", - "get fields.microseconds", - "get fields.microseconds.valueOf", - "call fields.microseconds.valueOf", - "get fields.milliseconds", - "get fields.milliseconds.valueOf", - "call fields.milliseconds.valueOf", - "get fields.minutes", - "get fields.minutes.valueOf", - "call fields.minutes.valueOf", - "get fields.months", - "get fields.nanoseconds", - "get fields.nanoseconds.valueOf", - "call fields.nanoseconds.valueOf", - "get fields.seconds", - "get fields.seconds.valueOf", - "call fields.seconds.valueOf", - "get fields.weeks", - "get fields.years", - "get this.calendar.dateAdd", - // AddDateTime -> AddDate - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; - -const noCalendarFields = TemporalHelpers.propertyBagObserver(actual, { - days: 1, - hours: 1, - minutes: 1, - seconds: 1, - milliseconds: 1, - microseconds: 1, - nanoseconds: 1, -}, "fields"); - -instance.add(noCalendarFields, options); -assert.compareArray(actual, noCalendarExpected, "order of operations with no calendar operation"); - -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 404ce8f1bd9..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.calendarid -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.calendarId; - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/day/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/day/builtin-calendar-no-observable-calls.js deleted file mode 100644 index fcafe7d6729..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/day/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.day -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "day"); -Object.defineProperty(Temporal.Calendar.prototype, "day", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("day should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.day; - -Object.defineProperty(Temporal.Calendar.prototype, "day", dayOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/day/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/day/custom.js deleted file mode 100644 index 86856dedb91..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/day/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.day -description: Custom calendar tests for day(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - day(...args) { - ++calls; - assert.compareArray(args, [pdt], "day arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.day; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/day/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/day/validate-calendar-value.js deleted file mode 100644 index 521ae997036..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/day/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.day -description: Validate result returned from calendar day() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - day() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.day, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/basic.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/basic.js index 437ac74b60e..de897ea3a4b 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/basic.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/basic.js @@ -7,6 +7,5 @@ description: Checking day of week for a "normal" case (non-undefined, non-bounda features: [Temporal] ---*/ -const calendar = Temporal.Calendar.from("iso8601"); -const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar); +const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); assert.sameValue(datetime.dayOfWeek, 4, "check day of week information"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 1d692b7bdde..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.dayofweek -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfWeek"); -Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dayOfWeek should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.dayOfWeek; - -Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", dayOfWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/custom.js deleted file mode 100644 index 0a6e0b6c6e8..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.dayofweek -description: Custom calendar tests for dayOfWeek(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dayOfWeek(...args) { - ++calls; - assert.compareArray(args, [pdt], "dayOfWeek arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.dayOfWeek; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/validate-calendar-value.js deleted file mode 100644 index 1714b6765aa..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.dayofweek -description: Validate result returned from calendar dayOfWeek() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - dayOfWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.dayOfWeek, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/basic.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/basic.js index 98ee0fbef0a..3d5735fd425 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/basic.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/basic.js @@ -7,6 +7,5 @@ description: Checking day of year for a "normal" case (non-undefined, non-bounda features: [Temporal] ---*/ -const calendar = Temporal.Calendar.from("iso8601"); -const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar); +const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); assert.sameValue(datetime.dayOfYear, 323, "check day of year information"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 99bbe5fc7aa..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.dayofyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfYear"); -Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dayOfYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.dayOfYear; - -Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", dayOfYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/custom.js deleted file mode 100644 index c5ae72ee091..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.dayofyear -description: Custom calendar tests for dayOfYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dayOfYear(...args) { - ++calls; - assert.compareArray(args, [pdt], "dayOfYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.dayOfYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/validate-calendar-value.js deleted file mode 100644 index 710f877ffed..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.dayofyear -description: Validate result returned from calendar dayOfYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - dayOfYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.dayOfYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js deleted file mode 100644 index e88de1affa6..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.daysinmonth -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInMonthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInMonth"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInMonth should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.daysInMonth; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", daysInMonthOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/custom.js deleted file mode 100644 index 145490c8281..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.daysinmonth -description: Custom calendar tests for daysInMonth(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInMonth(...args) { - ++calls; - assert.compareArray(args, [pdt], "daysInMonth arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.daysInMonth; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/validate-calendar-value.js deleted file mode 100644 index 51e3047b125..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.daysinmonth -description: Validate result returned from calendar daysInMonth() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInMonth() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.daysInMonth, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 43d327af3d0..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.daysinweek -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInWeek"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInWeek should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.daysInWeek; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", daysInWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/custom.js deleted file mode 100644 index eb4bcdf0d5a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.daysinweek -description: Custom calendar tests for daysInWeek(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInWeek(...args) { - ++calls; - assert.compareArray(args, [pdt], "daysInWeek arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.daysInWeek; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/validate-calendar-value.js deleted file mode 100644 index 2e7b1c77bcc..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.daysinweek -description: Validate result returned from calendar daysInWeek() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.daysInWeek, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index f4ffd20eb14..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.daysinyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInYear"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.daysInYear; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", daysInYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/custom.js deleted file mode 100644 index 17290b20b5a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.daysinyear -description: Custom calendar tests for daysInYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInYear(...args) { - ++calls; - assert.compareArray(args, [pdt], "daysInYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.daysInYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/validate-calendar-value.js deleted file mode 100644 index ed6759a58c0..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.daysinyear -description: Validate result returned from calendar daysInYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.daysInYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index f978ce07e00..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, calendar: "iso8601" }; -instance.equals(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-wrong-type.js index 6825ff3d19a..46f88bcd58c 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.plaindatetime.prototype.equals description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js index f09be96fc07..b08a70d5836 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js @@ -28,14 +28,12 @@ info: | ii. 1. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.plaindatetime.prototype.until step 3: 3. Set _other_ ? ToTemporalDateTime(_other_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); -assert(new Temporal.PlainDateTime(1970, 1, 1, 1, 1, 1, 1, 0, 999).equals(datetime)); +assert(new Temporal.PlainDateTime(1970, 1, 1, 0, 59, 1, 1, 1, 1).equals(datetime)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 53f040d0ff7..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.equals(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 0ec08786d40..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => plain.equals(zoned), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 9fe9520e239..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.equals(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index ec2fa6d0212..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => plain.equals(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 74b5c6dfae9..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.equals(new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321)); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-checked.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-checked.js deleted file mode 100644 index bd13a761865..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-checked.js +++ /dev/null @@ -1,109 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: Calendar is taken into account if the ISO data is equal -includes: [compareArray.js,temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; - -function makeCalendar(id, objectName) { - const calendar = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, - }; - TemporalHelpers.observeProperty(actual, calendar, "id", id, objectName); - return calendar; -} - -const calendar1 = makeCalendar("A", "calendar1"); -const calendar2 = makeCalendar("A", "calendar2"); -const calendar3 = makeCalendar("B", "calendar3"); -const dt1 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar1); -const dt1b = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar1); -const dt2 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar2); -const dt3 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar3); -actual.splice(0); // disregard the HasProperty checks done in the constructor - -assert.sameValue(dt1.equals(dt1b), true, "same calendar object"); -assert.compareArray(actual, []); - -assert.sameValue(dt1.equals(dt2), true, "same calendar string"); -assert.compareArray(actual, ["get calendar1.id", "get calendar2.id"]); - -actual.splice(0); // empty it for the next check -assert.sameValue(dt1.equals(dt3), false, "different calendar string"); -assert.compareArray(actual, ["get calendar1.id", "get calendar3.id"]); - -const calendar4 = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - get id() { TemporalHelpers.assertUnreachable('should not get calendar4.id'); }, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const calendar5 = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - get id() { TemporalHelpers.assertUnreachable('should not get calendar5.id'); }, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const dt4 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar4); -const dt5 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar4); -const dt6 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, calendar5); -assert.sameValue(dt4.equals(dt5), false, "not equal same calendar"); -assert.sameValue(dt4.equals(dt6), false, "not equal different calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 645a10124e0..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.equals(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-fields-iterable.js deleted file mode 100644 index 58a0aeccc9c..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindatetime.prototype.equals step 3: - 3. Set _other_ to ? ToTemporalDateTime(_other_). - sec-temporal-totemporaldatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -datetime.equals({ year: 2005, month: 6, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-temporal-object.js index 553475ccc6e..82fd1769ff1 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject); + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); datetime.equals({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/constructor-in-calendar-fields.js deleted file mode 100644 index 1afac8a644a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/duplicate-calendar-fields.js deleted file mode 100644 index b1c3b9cadfb..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => instance.equals(arg)); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/proto-in-calendar-fields.js deleted file mode 100644 index 56b7c488277..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/read-time-fields-before-datefromfields.js deleted file mode 100644 index 3a6ea884ab4..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/equals/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.equals -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.plaindatetime.prototype.equals step 3: - 3. Set _other_ to ? ToTemporalDateTime(_other_). - sec-temporal-totemporaldatetime step 2.e: - e. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = new Temporal.PlainDateTime(2021, 3, 31, 12, 34, 56, 987, 654, 321, calendar); -const result = datetime.equals({ year: 2021, month: 3, day: 31, hour: 12, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321, calendar }); - -assert(result, "time fields are not modified"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/branding.js b/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/branding.js deleted file mode 100644 index 556f515cde1..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getcalendar -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getCalendar = Temporal.PlainDateTime.prototype.getCalendar; - -assert.sameValue(typeof getCalendar, "function"); - -assert.throws(TypeError, () => getCalendar.call(undefined), "undefined"); -assert.throws(TypeError, () => getCalendar.call(null), "null"); -assert.throws(TypeError, () => getCalendar.call(true), "true"); -assert.throws(TypeError, () => getCalendar.call(""), "empty string"); -assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getCalendar.call(1), "1"); -assert.throws(TypeError, () => getCalendar.call({}), "plain object"); -assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDateTime), "Temporal.PlainDateTime"); -assert.throws(TypeError, () => getCalendar.call(Temporal.PlainDateTime.prototype), "Temporal.PlainDateTime.prototype"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/builtin.js b/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/builtin.js deleted file mode 100644 index 8073d1423d3..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getcalendar -description: > - Tests that Temporal.PlainDateTime.prototype.getCalendar - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainDateTime.prototype.getCalendar), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainDateTime.prototype.getCalendar), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainDateTime.prototype.getCalendar), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainDateTime.prototype.getCalendar.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/length.js b/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/length.js deleted file mode 100644 index 4aa0b2f9e58..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getcalendar -description: Temporal.PlainDateTime.prototype.getCalendar.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDateTime.prototype.getCalendar, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/name.js b/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/name.js deleted file mode 100644 index 55a49aa11fb..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getcalendar -description: Temporal.PlainDateTime.prototype.getCalendar.name is "getCalendar". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDateTime.prototype.getCalendar, "name", { - value: "getCalendar", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/not-a-constructor.js b/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/not-a-constructor.js deleted file mode 100644 index 1500ff41ce1..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getcalendar -description: > - Temporal.PlainDateTime.prototype.getCalendar does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainDateTime.prototype.getCalendar(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainDateTime.prototype.getCalendar), false, - "isConstructor(Temporal.PlainDateTime.prototype.getCalendar)"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/prop-desc.js b/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/prop-desc.js deleted file mode 100644 index 0896290df60..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getCalendar/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getcalendar -description: The "getCalendar" property of Temporal.PlainDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainDateTime.prototype.getCalendar, - "function", - "`typeof PlainDateTime.prototype.getCalendar` is `function`" -); - -verifyProperty(Temporal.PlainDateTime.prototype, "getCalendar", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/branding.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/branding.js deleted file mode 100644 index d4a26742b31..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getISOFields = Temporal.PlainDateTime.prototype.getISOFields; - -assert.sameValue(typeof getISOFields, "function"); - -assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); -assert.throws(TypeError, () => getISOFields.call(null), "null"); -assert.throws(TypeError, () => getISOFields.call(true), "true"); -assert.throws(TypeError, () => getISOFields.call(""), "empty string"); -assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getISOFields.call(1), "1"); -assert.throws(TypeError, () => getISOFields.call({}), "plain object"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainDateTime), "Temporal.PlainDateTime"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainDateTime.prototype), "Temporal.PlainDateTime.prototype"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/builtin.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/builtin.js deleted file mode 100644 index 6e17b1b5f62..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: > - Tests that Temporal.PlainDateTime.prototype.getISOFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainDateTime.prototype.getISOFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainDateTime.prototype.getISOFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainDateTime.prototype.getISOFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainDateTime.prototype.getISOFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/custom.js deleted file mode 100644 index b3b80bdccf8..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/custom.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: getISOFields does not call into user code. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarThrowEverything(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -const result = instance.getISOFields(); - -assert.sameValue(result.isoYear, 2000, "isoYear result"); -assert.sameValue(result.isoMonth, 5, "isoMonth result"); -assert.sameValue(result.isoDay, 2, "isoDay result"); -assert.sameValue(result.isoHour, 12, "isoHour result"); -assert.sameValue(result.isoMinute, 34, "isoMinute result"); -assert.sameValue(result.isoSecond, 56, "isoSecond result"); -assert.sameValue(result.isoMillisecond, 987, "isoMillisecond result"); -assert.sameValue(result.isoMicrosecond, 654, "isoMicrosecond result"); -assert.sameValue(result.isoNanosecond, 321, "isoNanosecond result"); -assert.sameValue(result.calendar, calendar, "calendar result"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/field-names.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/field-names.js deleted file mode 100644 index d34f56f6d52..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/field-names.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: Correct field names on the object returned from getISOFields -features: [Temporal] ----*/ - -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -const result = datetime.getISOFields(); -assert.sameValue(result.isoYear, 2000, "isoYear result"); -assert.sameValue(result.isoMonth, 5, "isoMonth result"); -assert.sameValue(result.isoDay, 2, "isoDay result"); -assert.sameValue(result.isoHour, 12, "isoHour result"); -assert.sameValue(result.isoMinute, 34, "isoMinute result"); -assert.sameValue(result.isoSecond, 56, "isoSecond result"); -assert.sameValue(result.isoMillisecond, 987, "isoMillisecond result"); -assert.sameValue(result.isoMicrosecond, 654, "isoMicrosecond result"); -assert.sameValue(result.isoNanosecond, 321, "isoNanosecond result"); -assert.sameValue(result.calendar, "iso8601", "calendar result"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/field-prop-desc.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/field-prop-desc.js deleted file mode 100644 index fdad48faf11..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/field-prop-desc.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: Properties on the returned object have the correct descriptor -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoHour", - "isoMicrosecond", - "isoMillisecond", - "isoMinute", - "isoMonth", - "isoNanosecond", - "isoSecond", - "isoYear", -]; - -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const result = datetime.getISOFields(); - -for (const property of expected) { - verifyProperty(result, property, { - writable: true, - enumerable: true, - configurable: true, - }); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/field-traversal-order.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/field-traversal-order.js deleted file mode 100644 index ba6f19faf21..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/field-traversal-order.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: Properties added in correct order to object returned from getISOFields -includes: [compareArray.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoHour", - "isoMicrosecond", - "isoMillisecond", - "isoMinute", - "isoMonth", - "isoNanosecond", - "isoSecond", - "isoYear", -]; - -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const result = datetime.getISOFields(); - -assert.compareArray(Object.keys(result), expected); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/length.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/length.js deleted file mode 100644 index 463e3b0b16d..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: Temporal.PlainDateTime.prototype.getISOFields.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDateTime.prototype.getISOFields, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/name.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/name.js deleted file mode 100644 index ec6793d108a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: Temporal.PlainDateTime.prototype.getISOFields.name is "getISOFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainDateTime.prototype.getISOFields, "name", { - value: "getISOFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/not-a-constructor.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/not-a-constructor.js deleted file mode 100644 index 7c459d11d42..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: > - Temporal.PlainDateTime.prototype.getISOFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainDateTime.prototype.getISOFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainDateTime.prototype.getISOFields), false, - "isConstructor(Temporal.PlainDateTime.prototype.getISOFields)"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/prop-desc.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/prop-desc.js deleted file mode 100644 index c77649c9c47..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: The "getISOFields" property of Temporal.PlainDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainDateTime.prototype.getISOFields, - "function", - "`typeof PlainDateTime.prototype.getISOFields` is `function`" -); - -verifyProperty(Temporal.PlainDateTime.prototype, "getISOFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/prototype.js b/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/prototype.js deleted file mode 100644 index 1e00cd2300d..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/getISOFields/prototype.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getisofields -description: Correct prototype on the object returned from getISOFields -features: [Temporal] ----*/ - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const result = instance.getISOFields(); -assert.sameValue(Object.getPrototypeOf(result), Object.prototype, "prototype"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index f14f52befba..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.inleapyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const inLeapYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "inLeapYear"); -Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("inLeapYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.inLeapYear; - -Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", inLeapYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/custom.js deleted file mode 100644 index ace87a3151a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.inleapyear -description: Custom calendar tests for inLeapYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - inLeapYear(...args) { - ++calls; - assert.compareArray(args, [pdt], "inLeapYear arguments"); - return true; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.inLeapYear; -assert.sameValue(result, true, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/validate-calendar-value.js deleted file mode 100644 index cd01153e45f..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/validate-calendar-value.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.inleapyear -description: Validate result returned from calendar inLeapYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [0, TypeError], - [-0, TypeError], - [42, TypeError], - [7.1, TypeError], - [NaN, TypeError], - [Infinity, TypeError], - [-Infinity, TypeError], - ["", TypeError], - ["a string", TypeError], - ["0", TypeError], - [Symbol("foo"), TypeError], - [0n, TypeError], - [42n, TypeError], - [{}, TypeError], - [{valueOf() { return false; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - inLeapYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.inLeapYear, `${typeof result} ${String(result)} not converted to boolean`); -}); - -const preservedResults = [ - true, - false, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - inLeapYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.sameValue(instance.inLeapYear, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/month/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/month/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 0e2b4b86689..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/month/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.month -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "month"); -Object.defineProperty(Temporal.Calendar.prototype, "month", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("month should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.month; - -Object.defineProperty(Temporal.Calendar.prototype, "month", monthOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/month/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/month/custom.js deleted file mode 100644 index c9bffd38da4..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/month/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.month -description: Custom calendar tests for month(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - month(...args) { - ++calls; - assert.compareArray(args, [pdt], "month arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.month; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/month/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/month/validate-calendar-value.js deleted file mode 100644 index 928d3ade7f1..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/month/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.month -description: Validate result returned from calendar month() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - month() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.month, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 705187ff7e2..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.monthcode -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthCode should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.monthCode; - -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/custom.js deleted file mode 100644 index edba63c4979..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.monthcode -description: Custom calendar tests for monthCode(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthCode(...args) { - ++calls; - assert.compareArray(args, [pdt], "monthCode arguments"); - return "M01"; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.monthCode; -assert.sameValue(result, "M01", "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/validate-calendar-value.js deleted file mode 100644 index 1a097ab1dd2..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/monthCode/validate-calendar-value.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.monthcode -description: Validate result returned from calendar monthCode() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [Symbol("foo"), TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, TypeError], - [{toString() { return "M01"; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - monthCode() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.monthCode, `${typeof result} ${String(result)} not converted to string`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/basic.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/basic.js index f918a25355e..579b6e619b6 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/basic.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/basic.js @@ -7,6 +7,5 @@ description: Checking months in year for a "normal" case (non-undefined, non-bou features: [Temporal] ---*/ -const calendar = Temporal.Calendar.from("iso8601"); -const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar); +const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); assert.sameValue(datetime.monthsInYear, 12, "check months in year information"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 2ea990acbaf..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.monthsinyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthsInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthsInYear"); -Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthsInYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.monthsInYear; - -Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", monthsInYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/custom.js deleted file mode 100644 index 9f7d23731c5..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.monthsinyear -description: Custom calendar tests for monthsInYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthsInYear(...args) { - ++calls; - assert.compareArray(args, [pdt], "monthsInYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.monthsInYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/validate-calendar-value.js deleted file mode 100644 index 4366df824b7..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.monthsinyear -description: Validate result returned from calendar monthsInYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - monthsInYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.monthsInYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 3441f7b4efc..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, calendar: "iso8601" }; -instance.since(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-wrong-type.js index 6e17c616a01..745ea669a37 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-propertybag-calendar-wrong-type.js @@ -9,7 +9,6 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); const primitiveTests = [ @@ -31,10 +30,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js index 963e5170415..dbc0d8f1cbb 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js @@ -35,9 +35,8 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); const diff = new Temporal.PlainDateTime(1970, 1, 1).since(datetime); -TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, -1, -1, -1, -1, 0, -999); +TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 0, -59, -1, -1, -1, -1); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index a0696a0ca4a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.since(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 0273f4cd298..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => plain.since(zoned), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index d7aa27f805e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.since(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 450e21cd587..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => plain.since(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 1eb71403dd5..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.since(new Temporal.PlainDateTime(1999, 4, 1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateadd-called-with-plaindate-instance.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateadd-called-with-plaindate-instance.js deleted file mode 100644 index 4259fee78e2..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateadd-called-with-plaindate-instance.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: > - relativeTo parameters that are not ZonedDateTime or undefined, are always - converted to PlainDate for observable calendar calls -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddPlainDateInstance(); -const instance = new Temporal.PlainDateTime(1970, 1, 1, 0, 0, 0, 0, 0, 0, calendar); -instance.since(new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 0, 0, 0, calendar), { smallestUnit: "month" }); -assert(calendar.dateAddCallCount > 0, "assertions in calendar.dateAdd() should have been tested"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index ca8e43431c9..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.since(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-copy-of-options.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-copy-of-options.js deleted file mode 100644 index 82cbddc3b5a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-copy-of-options.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: The dateUntil() method on the calendar is called with a copy of the options bag -features: [Temporal] ----*/ - -const originalOptions = { - largestUnit: "year", - shouldBeCopied: {}, -}; -let called = false; - -class Calendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateUntil(d1, d2, options) { - called = true; - assert.notSameValue(options, originalOptions, "options bag should be a copy"); - assert.sameValue(options.shouldBeCopied, originalOptions.shouldBeCopied, "options bag should be a shallow copy"); - return new Temporal.Duration(); - } -} -const calendar = new Calendar(); -const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -const later = new Temporal.PlainDateTime(2001, 6, 3, 13, 35, 57, 988, 655, 322, calendar); -earlier.since(later, originalOptions); -assert(called, "calendar.dateUntil must be called"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js deleted file mode 100644 index c4cc4df467f..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: > - Calendar.dateUntil method is called with a null-prototype object as the - options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -const argument = new Temporal.PlainDateTime(2022, 6, 14, 18, 21, 36, 660, 690, 387, calendar); -instance.since(argument, { largestUnit: "months" }); -assert.sameValue(calendar.dateUntilCallCount, 1, "dateUntil should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-plaindate-calendar.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-plaindate-calendar.js deleted file mode 100644 index 4ed21f10f71..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-plaindate-calendar.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: calendar.dateUntil() is passed PlainDate objects with the receiver's calendar -info: | - DifferenceISODateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, d2, h2, min2, s2, ms2, mus2, ns2, calendar, largestUnit [ , options ] ) - - 8. Let _date1_ be ? CreateTemporalDate(_balanceResult_.[[Year]], _balanceResult_.[[Month]], _balanceResult_.[[Day]], _calendar_). - 9. Let _date2_ be ? CreateTemporalDate(_y2_, _mon2_, _d2_, _calendar_). - 12. Let _dateDifference_ be ? CalendarDateUntil(_calendar_, _date1_, _date2_, _untilOptions_). -features: [Temporal] ----*/ - -class Calendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateUntil(d1, d2) { - assert.sameValue(d1.getCalendar(), this, "d1.calendar"); - assert.sameValue(d2.getCalendar(), this, "d2.calendar"); - return new Temporal.Duration(); - } -} -const calendar = new Calendar(); -const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -const later = new Temporal.PlainDateTime(2001, 6, 3, 13, 35, 57, 988, 655, 322, calendar); -const result = earlier.since(later); -assert(result instanceof Temporal.Duration, "result"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index 0f2b56f9af8..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: The options object passed to calendar.dateUntil has a largestUnit property with its value in the singular form -info: | - sec-temporal.plaindatetime.prototype.since step 14: - 14. Let _diff_ be ? DifferenceISODateTime(_other_.[[ISOYear]], _other_.[[ISOMonth]], _other_.[[ISODay]], _other_.[[ISOHour]], _other_.[[ISOMinute]], _other_.[[ISOSecond]], _other_.[[ISOMillisecond]], _other_.[[ISOMicrosecond]], _other_.[[ISONanosecond]], _dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], _dateTime_.[[Calendar]], _largestUnit_, _options_). - sec-temporal-differenceisodatetime steps 9–11: - 9. Let _dateLargestUnit_ be ! LargerOfTwoTemporalUnits(*"day"*, _largestUnit_). - 10. Let _untilOptions_ be ? MergeLargestUnitOption(_options_, _dateLargestUnit_). - 11. Let _dateDifference_ be ? CalendarDateUntil(_calendar_, _date1_, _date2_, _untilOptions_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); - const later = new Temporal.PlainDateTime(2001, 6, 3, 13, 35, 57, 988, 655, 322, calendar); - later.since(earlier, { largestUnit }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-fields-iterable.js deleted file mode 100644 index 18c2c6b911f..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindatetime.prototype.since step 3: - 3. Set _other_ to ? ToTemporalDateTime(_other_). - sec-temporal-totemporaldatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -datetime.since({ year: 2005, month: 6, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-temporal-object.js index 791434c927f..732deadf47f 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject); + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); datetime.since({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/constructor-in-calendar-fields.js deleted file mode 100644 index 37ae19eb2da..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js deleted file mode 100644 index 19c34416c28..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: Fail if the argument is a PlainDateTime with a different calendar -features: [Temporal] ----*/ - -const dt1 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0); -const dt2 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "custom", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); - -assert.throws( - RangeError, - () => dt1.since(dt2), - "different calendars not allowed" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/duplicate-calendar-fields.js deleted file mode 100644 index f43dfcb8331..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => instance.since(arg)); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js index df0236e7cc1..8fdccbdf0b2 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/order-of-operations.js @@ -11,30 +11,6 @@ features: [Temporal] const expected = [ // ToTemporalDateTime "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.dateFromFields", - "get other.calendar.fields", - "call other.calendar.fields", "get other.day", "get other.day.valueOf", "call other.day.valueOf", @@ -65,36 +41,23 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", - "call other.calendar.dateFromFields", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, ownCalendar); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, @@ -107,13 +70,11 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { millisecond: 250, microsecond: 500, nanosecond: 750, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { - // order is significant, due to iterating through properties in order to - // copy them to an internal null-prototype object: roundingIncrement, roundingMode, largestUnit, @@ -122,108 +83,7 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au }, "options"); } -// clear any observable things that happened while constructing the objects -actual.splice(0); - // basic order of observable operations with calendar call, without rounding: instance.since(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" })); -assert.compareArray(actual, expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", -]), "order of operations"); -actual.splice(0); // clear - -// short-circuit for identical objects: -const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 5, - monthCode: "M05", - day: 2, - hour: 12, - minute: 34, - second: 56, - millisecond: 987, - microsecond: 654, - nanosecond: 321, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); - -instance.since(identicalPropertyBag, createOptionsObserver()); -assert.compareArray(actual, expected, "order of operations with identical datetimes"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest year: -const expectedOpsForYearRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); +assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest year and skips a DateUntil call: -const otherDatePropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual, { - year: 2001, - month: 5, - monthCode: "M05", - day: 2, - hour: 12, - minute: 34, - second: 56, - millisecond: 987, - microsecond: 654, - nanosecond: 321, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); -const expectedOpsForYearRoundingSameMonth = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherDatePropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months/weeks"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest month: -const expectedOpsForMonthRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" })); -assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest week: -const expectedOpsForWeekRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateUntil", - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); -assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/proto-in-calendar-fields.js deleted file mode 100644 index 42a37ce6db9..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/read-time-fields-before-datefromfields.js deleted file mode 100644 index 9f7acc26d6a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.plaindatetime.prototype.since step 3: - 3. Set _other_ to ? ToTemporalDateTime(_other_). - sec-temporal-totemporaldatetime step 2.e: - e. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = new Temporal.PlainDateTime(2021, 3, 31, 12, 34, 56, 987, 654, 321); -const duration = datetime.since({ year: 2021, month: 3, day: 31, calendar }); - -TemporalHelpers.assertDuration(duration, 0, 0, 0, 0, 12, 34, 56, 987, 654, 321); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/result-mixed-sign.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/result-mixed-sign.js deleted file mode 100644 index 40961725d79..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/result-mixed-sign.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: > - RangeError when inconsistent custom calendar method causes mixed signs of - Duration components -features: [Temporal] ----*/ - -// Test case provided by André Bargull - -const cal = new (class extends Temporal.Calendar { - dateUntil(date, duration, options) { - return super.dateUntil(date, duration, options).negated(); - } -})("iso8601"); - -const one = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, cal); -const two = new Temporal.PlainDateTime(2020, 5, 10, 12, 12, 0, 0, 0, 0, cal); - -assert.throws(RangeError, () => two.since(one, { - largestUnit: "years", - smallestUnit: "hours" -})); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/rounding-zero-year-month-week-length.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/rounding-zero-year-month-week-length.js deleted file mode 100644 index e6154125b27..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/since/rounding-zero-year-month-week-length.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.since -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const dt1 = new Temporal.PlainDateTime(1970, 1, 1, 0, 0, 0, 0, 0, 0, cal); -const dt2 = new Temporal.PlainDateTime(1971, 1, 1, 0, 0, 0, 0, 0, 1, cal); - -assert.throws(RangeError, () => dt1.since(dt2, { smallestUnit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => dt1.since(dt2, { smallestUnit: "months" }), "zero month length handled correctly"); -assert.throws(RangeError, () => dt1.since(dt2, { smallestUnit: "weeks" }), "zero week length handled correctly"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 962a000bef8..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.subtract -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.subtract(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/calendar-dateadd.js b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/calendar-dateadd.js deleted file mode 100644 index 8e22137fc14..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/calendar-dateadd.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.subtract -description: PlainDateTime.prototype.subtract should call dateAdd with the appropriate values. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(plainDate, duration, options) { - ++calls; - TemporalHelpers.assertPlainDate(plainDate, 2020, 3, "M03", 14, "plainDate argument"); - TemporalHelpers.assertDuration(duration, 0, -10, 0, -1, 0, 0, 0, 0, 0, 0, "duration argument"); - assert.sameValue(typeof options, "object", "options argument: type"); - assert.sameValue(Object.getPrototypeOf(options), null, "options argument: prototype"); - return super.dateAdd(plainDate, duration, options); - } -} - -const plainDateTime = new Temporal.PlainDateTime(2020, 3, 14, 12, 34, 56, 987, 654, 321, new CustomCalendar()); -const result = plainDateTime.subtract({ months: 10, hours: 14 }); -TemporalHelpers.assertPlainDateTime(result, 2019, 5, "M05", 13, 22, 34, 56, 987, 654, 321); -assert.sameValue(calls, 1, "should have called dateAdd"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js index d58bbb9edd3..153d4b9a9fa 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/subtract/order-of-operations.js @@ -40,20 +40,13 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", - // AddDateTime -> AddDate - "get this.calendar.dateAdd", - "call this.calendar.dateAdd", - // inside Calendar.p.dateAdd "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); const fields = TemporalHelpers.propertyBagObserver(actual, { years: 1, @@ -74,51 +67,3 @@ instance.subtract(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -const noCalendarExpected = [ - // ToTemporalDurationRecord - "get fields.days", - "get fields.days.valueOf", - "call fields.days.valueOf", - "get fields.hours", - "get fields.hours.valueOf", - "call fields.hours.valueOf", - "get fields.microseconds", - "get fields.microseconds.valueOf", - "call fields.microseconds.valueOf", - "get fields.milliseconds", - "get fields.milliseconds.valueOf", - "call fields.milliseconds.valueOf", - "get fields.minutes", - "get fields.minutes.valueOf", - "call fields.minutes.valueOf", - "get fields.months", - "get fields.nanoseconds", - "get fields.nanoseconds.valueOf", - "call fields.nanoseconds.valueOf", - "get fields.seconds", - "get fields.seconds.valueOf", - "call fields.seconds.valueOf", - "get fields.weeks", - "get fields.years", - "get this.calendar.dateAdd", - // AddDateTime -> AddDate - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; - -const noCalendarFields = TemporalHelpers.propertyBagObserver(actual, { - days: 1, - hours: 1, - minutes: 1, - seconds: 1, - milliseconds: 1, - microseconds: 1, - nanoseconds: 1, -}, "fields"); - -instance.subtract(noCalendarFields, options); -assert.compareArray(actual, noCalendarExpected, "order of operations with no calendar operation"); - -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js deleted file mode 100644 index cc9cca96dce..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tojson -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.toJSON(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index e19393fd33a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tolocalestring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.toLocaleString(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/basic.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/basic.js index 5e5b7596a46..2930e0e76e3 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/basic.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/basic.js @@ -7,7 +7,6 @@ description: Checking the string form of an explicitly constructed instance with features: [Temporal] ---*/ -const calendar = Temporal.Calendar.from("iso8601"); -const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar); +const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); assert.sameValue(datetime.toString(), "1976-11-18T15:23:30.123456789", "check string value"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 2203f6dba1a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tostring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.toString(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js deleted file mode 100644 index a105b5f5136..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendar-tostring.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.protoype.tostring -description: Number of observable 'toString' calls on the calendar for each value of calendarName -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls; -const customCalendar = { - get id() { - ++calls; - return "custom"; - }, - toString() { - TemporalHelpers.assertUnreachable('toString should not be called'); - }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, customCalendar); -[ - ["always", "2000-05-02T12:34:56.987654321[u-ca=custom]", 1], - ["auto", "2000-05-02T12:34:56.987654321[u-ca=custom]", 1], - ["critical", "2000-05-02T12:34:56.987654321[!u-ca=custom]", 1], - ["never", "2000-05-02T12:34:56.987654321", 0], - [undefined, "2000-05-02T12:34:56.987654321[u-ca=custom]", 1], -].forEach(([calendarName, expectedResult, expectedCalls]) => { - calls = 0; - const result = date.toString({ calendarName }); - assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js index 53659c46445..e6faea1ea94 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-always.js @@ -7,39 +7,6 @@ description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1976-11-18T15:23:00[u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); - const result = date.toString({ calendarName: "always" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = always`); -} +const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0); +const result = date.toString({ calendarName: "always" }); +assert.sameValue(result, "1976-11-18T15:23:00[u-ca=iso8601]", `built-in ISO calendar for calendarName = always`); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js index 31f669617cc..80809b5b2fe 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js @@ -7,39 +7,6 @@ description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1976-11-18T15:23:00", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1976-11-18T15:23:00", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); - const result = date.toString({ calendarName: "auto" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); -} +const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0); +const result = date.toString({ calendarName: "auto" }); +assert.sameValue(result, "1976-11-18T15:23:00", `built-in ISO calendar for calendarName = auto`); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js index e3face2fc1e..506bf6aa00b 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js @@ -9,39 +9,6 @@ description: > features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1976-11-18T15:23:00[!u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1976-11-18T15:23:00[!u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1976-11-18T15:23:00[!u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1976-11-18T15:23:00[!u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1976-11-18T15:23:00[!u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); - const result = date.toString({ calendarName: "critical" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); -} +const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0); +const result = date.toString({ calendarName: "critical" }); +assert.sameValue(result, "1976-11-18T15:23:00[!u-ca=iso8601]", `built-in ISO calendar for calendarName = critical`); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js index 5cc5a4d24b2..7c3aa902cc6 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-never.js @@ -7,39 +7,6 @@ description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1976-11-18T15:23:00", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1976-11-18T15:23:00", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1976-11-18T15:23:00", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1976-11-18T15:23:00", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1976-11-18T15:23:00", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); - const result = date.toString({ calendarName: "never" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = never`); -} +const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0); +const result = date.toString({ calendarName: "never" }); +assert.sameValue(result, "1976-11-18T15:23:00", `built-in ISO calendar for calendarName = never`); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js index fee3b920053..9687ce048be 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js @@ -14,40 +14,7 @@ info: | features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1976-11-18T15:23:00", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1976-11-18T15:23:00", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1976-11-18T15:23:00[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); - const result = datetime.toString({ calendarName: undefined }); - assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); - // See options-object.js for {} and options-undefined.js for absent options arg -} +const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0); +const result = datetime.toString({ calendarName: undefined }); +assert.sameValue(result, "1976-11-18T15:23:00", `default calendarName option is auto with built-in ISO calendar`); +// See options-object.js for {} and options-undefined.js for absent options arg diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js index 2786a47bb43..ee4e68ec501 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js @@ -15,32 +15,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const calendar = { - id: "custom", - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); +const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", (calendarName) => datetime.toString({ calendarName }), - (result, descr) => assert.sameValue(result, "2000-05-02T12:34:56.987654321[u-ca=custom]", descr), + (result, descr) => assert.sameValue(result, "2000-05-02T12:34:56.987654321", descr), ); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-undefined.js deleted file mode 100644 index daa6083232d..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/options-undefined.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tostring -description: Verify that undefined options are handled correctly. -features: [Temporal] ----*/ - -const calendar = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "custom", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const datetime1 = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 650, 0); -const datetime2 = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 650, 0, calendar); - -[ - [datetime1, "2000-05-02T12:34:56.98765"], - [datetime2, "2000-05-02T12:34:56.98765[u-ca=custom]"], -].forEach(([datetime, expected]) => { - const explicit = datetime.toString(undefined); - assert.sameValue(explicit, expected, "default calendarName option is auto, precision is auto, and no rounding"); - - const propertyImplicit = datetime.toString({}); - assert.sameValue(propertyImplicit, expected, "default calendarName option is auto, precision is auto, and no rounding"); - - const implicit = datetime.toString(); - assert.sameValue(implicit, expected, "default calendarName option is auto, precision is auto, and no rounding"); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js index 231721be902..bc97b6884a9 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toString/order-of-operations.js @@ -21,12 +21,10 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", - "get this.calendar.id", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(1990, 11, 3, 15, 54, 37, 123, 456, 789, calendar); +const instance = new Temporal.PlainDateTime(1990, 11, 3, 15, 54, 37, 123, 456, 789, "iso8601"); // clear observable operations that occurred during the constructor call actual.splice(0); @@ -53,7 +51,6 @@ const expectedForFractionalSecondDigits = [ "get options.roundingMode.toString", "call options.roundingMode.toString", "get options.smallestUnit", - "get this.calendar.id", ]; instance.toString( diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/balance-negative-time-units.js deleted file mode 100644 index 2a0427c9c90..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/balance-negative-time-units.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: Negative time fields are balanced upwards -info: | - sec-temporal-balancetime steps 3–14: - 3. Set _microsecond_ to _microsecond_ + floor(_nanosecond_ / 1000). - 4. Set _nanosecond_ to _nanosecond_ modulo 1000. - 5. Set _millisecond_ to _millisecond_ + floor(_microsecond_ / 1000). - 6. Set _microsecond_ to _microsecond_ modulo 1000. - 7. Set _second_ to _second_ + floor(_millisecond_ / 1000). - 8. Set _millisecond_ to _millisecond_ modulo 1000. - 9. Set _minute_ to _minute_ + floor(_second_ / 60). - 10. Set _second_ to _second_ modulo 60. - 11. Set _hour_ to _hour_ + floor(_minute_ / 60). - 12. Set _minute_ to _minute_ modulo 60. - 13. Let _days_ be floor(_hour_ / 24). - 14. Set _hour_ to _hour_ modulo 24. - sec-temporal-addtime step 8: - 8. Return ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). - sec-temporal-adddatetime step 1: - 1. Let _timeResult_ be ? AddTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_). - sec-temporal-builtintimezonegetinstantfor step 13.a: - a. Let _earlier_ be ? AddDateTime(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], 0, 0, 0, 0, 0, 0, 0, 0, 0, −_nanoseconds_, *"constrain"*). - sec-temporal.plaindatetime.prototype.tozoneddatetime step 6: - 6. Let _instant_ be BuiltinTimeZoneGetInstantFor(_timeZone_, _dateTime_, _disambiguation_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const shiftInstant = new Temporal.Instant(3661_001_001_001n); -const tz = TemporalHelpers.oneShiftTimeZone(shiftInstant, 2); -const datetime = new Temporal.PlainDateTime(1970, 1, 1, 1, 1, 1, 1, 1, 1); - -// This code path is encountered if disambiguation is `earlier` and the shift is -// a spring-forward change -datetime.toZonedDateTime(tz, { disambiguation: "earlier" }); - -const expected = [ - "1970-01-01T01:01:01.001001001", - "1970-01-01T01:01:01.001000999", -]; -assert.compareArray(tz.getPossibleInstantsForCalledWith, expected); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/branding.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/branding.js index d58915e726c..47d7efb3aa1 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/branding.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/branding.js @@ -11,7 +11,7 @@ const toZonedDateTime = Temporal.PlainDateTime.prototype.toZonedDateTime; assert.sameValue(typeof toZonedDateTime, "function"); -const args = [new Temporal.TimeZone("UTC")]; +const args = ["UTC"]; assert.throws(TypeError, () => toZonedDateTime.apply(undefined, args), "undefined"); assert.throws(TypeError, () => toZonedDateTime.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/constant-offset.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/constant-offset.js new file mode 100644 index 00000000000..0f2fc191944 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/constant-offset.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: Result in time zone with constant UTC offset +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(2019, 2, 16, 23, 45); +["earlier", "later", "compatible", "reject"].forEach((disambiguation) => { + const result = instance.toZonedDateTime("+03:30", { disambiguation }); + assert.sameValue(result.epochNanoseconds, 1550348100_000_000_000n, "Result is 2019-02-16T20:15Z regardless of disambiguation"); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguate-empty-possible-instants-with-datetime-near-limits.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguate-empty-possible-instants-with-datetime-near-limits.js deleted file mode 100644 index 22d59e5e18f..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguate-empty-possible-instants-with-datetime-near-limits.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: > - Throws when at minimum resp. maximum value and possible instants is an empty List. -info: | - DisambiguatePossibleInstants ( possibleInstants, timeZone, dateTime, disambiguation ) - - ... - 9. If ! IsValidEpochNanoseconds(dayBeforeNs) is false, throw a RangeError exception. - ... - 12. If ! IsValidEpochNanoseconds(dayAfterNs) is false, throw a RangeError exception. - ... -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - getPossibleInstantsFor() { - return []; - } -} - -var tz = new TZ("UTC"); -var min = new Temporal.PlainDateTime(-271821, 4, 20); -var max = new Temporal.PlainDateTime(275760, 9, 13); - -assert.throws(RangeError, () => min.toZonedDateTime(tz), "minimum date-time"); -assert.throws(RangeError, () => max.toZonedDateTime(tz), "maximum date-time"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-invalid-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-invalid-string.js index ab7127ce59f..0c767c50e22 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-invalid-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-invalid-string.js @@ -15,12 +15,11 @@ features: [Temporal] ---*/ const datetime = new Temporal.PlainDateTime(2001, 9, 9, 1, 46, 40, 987, 654, 321); -const timeZone = new Temporal.TimeZone("UTC"); const invalidStrings = ["obviously bad", "", "EARLIER", "earlıer", "late\u0131r", "reject\0"]; invalidStrings.forEach((s) => { assert.throws( RangeError, - () => datetime.toZonedDateTime(timeZone, { disambiguation: s }), + () => datetime.toZonedDateTime("UTC", { disambiguation: s }), `invalid disambiguation string (${s})`); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-undefined.js deleted file mode 100644 index 9292987c471..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-undefined.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: Fallback value for disambiguation option -info: | - sec-getoption step 3: - 3. If _value_ is *undefined*, return _fallback_. - sec-temporal-totemporaldisambiguation step 1: - 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). - sec-temporal.plaindatetime.prototype.tozoneddatetime step 5: - 5. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const springForwardDatetime = new Temporal.PlainDateTime(2000, 4, 2, 2, 30); -const fallBackDatetime = new Temporal.PlainDateTime(2000, 10, 29, 1, 30); - -[ - [springForwardDatetime, 954671400_000_000_000n], - [fallBackDatetime, 972808200_000_000_000n], -].forEach(([datetime, expected]) => { - const explicit = datetime.toZonedDateTime(timeZone, { disambiguation: undefined }); - assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); - const implicit = datetime.toZonedDateTime(timeZone, {}); - assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-wrong-type.js index bf7d4dbb176..86a95283ed2 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-wrong-type.js @@ -16,8 +16,7 @@ features: [Temporal] ---*/ const datetime = new Temporal.PlainDateTime(2001, 9, 9, 1, 46, 40, 987, 654, 321); -const timeZone = new Temporal.TimeZone("UTC"); TemporalHelpers.checkStringOptionWrongType("disambiguation", "compatible", - (disambiguation) => datetime.toZonedDateTime(timeZone, { disambiguation }), + (disambiguation) => datetime.toZonedDateTime("UTC", { disambiguation }), (result, descr) => assert.sameValue(result.epochNanoseconds, 1_000_000_000_987_654_321n, descr), ); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation.js new file mode 100644 index 00000000000..de60676a8f7 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation.js @@ -0,0 +1,22 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: Basic tests for disambiguation option +features: [Temporal] +---*/ + +const dtm = new Temporal.PlainDateTime(2000, 10, 29, 1, 45); + +for (const disambiguation of ["compatible", "earlier", "later", "reject"]) { + const result = dtm.toZonedDateTime("UTC", { disambiguation }); + assert.sameValue(result.epochNanoseconds, 972783900_000_000_000n, "epoch nanoseconds remains constant"); + assert.sameValue(result.timeZoneId, "UTC", "time zone is adopted"); +} + +for (const disambiguation of ["compatible", "earlier", "later", "reject"]) { + const result = dtm.toZonedDateTime("+03:30", { disambiguation }); + assert.sameValue(result.epochNanoseconds, 972771300_000_000_000n, "epoch nanoseconds remains constant"); + assert.sameValue(result.timeZoneId, "+03:30", "time zone is adopted"); +} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/fixed-offset-near-date-time-limits.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/fixed-offset-near-date-time-limits.js new file mode 100644 index 00000000000..0bc7c7eb348 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/fixed-offset-near-date-time-limits.js @@ -0,0 +1,45 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: Values near the date/time limit and a fixed offset. +features: [Temporal, exponentiation] +---*/ + +const oneHour = 1n * 60n * 60n * 1000n**3n; + +const minDt = new Temporal.PlainDateTime(-271821, 4, 19, 1, 0, 0, 0, 0, 0); +const minValidDt = new Temporal.PlainDateTime(-271821, 4, 20, 0, 0, 0, 0, 0, 0); +const maxDt = new Temporal.PlainDateTime(275760, 9, 13, 0, 0, 0, 0, 0, 0); + +// Try the minimum date-time. +assert.throws(RangeError, () => minDt.toZonedDateTime("+00")); +assert.throws(RangeError, () => minDt.toZonedDateTime("+01")); +assert.throws(RangeError, () => minDt.toZonedDateTime("-01")); + +// Try the minimum valid date-time. +["earlier", "later"].forEach((disambiguation) => { + const zdt = minValidDt.toZonedDateTime("+00", { disambiguation }); + assert.sameValue(zdt.epochNanoseconds, -86_40000_00000_00000_00000n); +}); + +["earlier", "later"].forEach((disambiguation) => { + const zdt = minValidDt.toZonedDateTime("-01", { disambiguation }); + assert.sameValue(zdt.epochNanoseconds, -86_40000_00000_00000_00000n + oneHour); +}); + +assert.throws(RangeError, () => minValidDt.toZonedDateTime("+01")); + +// Try the maximum valid date-time. +["earlier", "later"].forEach((disambiguation) => { + const zdt = maxDt.toZonedDateTime("+00"); + assert.sameValue(zdt.epochNanoseconds, 86_40000_00000_00000_00000n); +}); + +["earlier", "later"].forEach((disambiguation) => { + const zdt = maxDt.toZonedDateTime("+01"); + assert.sameValue(zdt.epochNanoseconds, 86_40000_00000_00000_00000n - oneHour); +}); + +assert.throws(RangeError, () => maxDt.toZonedDateTime("-01")); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index 53556b5f629..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants can be at most 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - calls++; - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12 })]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.PlainDateTime(1970, 1, 1, 12); -instance.toZonedDateTime(timeZone); - -assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js deleted file mode 100644 index bb1925071a0..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.PlainDateTime(1970, 1, 1, 12); -assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 2bc8ae58d80..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 0, 0, 0, nonBuiltinISOCalendar); -instance.toZonedDateTime(timeZone); - -assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index e931969de51..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-maximum-backward-offset-shift.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - calls++; - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12 }), - utcInstant.add({ hours: 12 }) - ]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.PlainDateTime(1970, 1, 1, 12); -instance.toZonedDateTime(timeZone); - -assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index 0c0409494ea..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.PlainDateTime(1970, 1, 1, 12); -assert.throws(RangeError, () => instance.toZonedDateTime(timeZone), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/negative-year.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/negative-year.js new file mode 100644 index 00000000000..bc2a6d1e909 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/negative-year.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: Check result when Gregorian year is negative +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(-1000, 10, 29, 10, 46, 38, 271, 986, 102); +["earlier", "later", "compatible", "reject"].forEach((disambiguation) => { + const result = instance.toZonedDateTime("+06:00", { disambiguation }); + assert.sameValue(result.epochNanoseconds, -93698104401_728_013_898n, "Result is -001000-10-29T04:46:38.271986102Z regardless of disambiguation"); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-undefined.js deleted file mode 100644 index a5faffd4674..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/options-undefined.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindate.prototype.tozoneddatetime -includes: [temporalHelpers.js] -description: Verify that undefined options are handled correctly. -features: [BigInt, Temporal] ----*/ - -const datetimeEarlier = new Temporal.PlainDateTime(2000, 10, 29, 1, 34, 56, 987, 654, 321); -const datetimeLater = new Temporal.PlainDateTime(2000, 4, 2, 2, 34, 56, 987, 654, 321); -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -[ - [datetimeEarlier, 972808496987654321n], - [datetimeLater, 954671696987654321n], -].forEach(([datetime, expected]) => { - const explicit = datetime.toZonedDateTime(timeZone, undefined); - assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); - - const implicit = datetime.toZonedDateTime(timeZone); - assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/order-of-operations.js index 18c7b8fdd02..6699cbb5112 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/order-of-operations.js @@ -9,54 +9,17 @@ features: [Temporal] ---*/ const expected = [ - // ToTemporalTimeZoneSlotValue - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", // ToTemporalDisambiguation "get options.disambiguation", "get options.disambiguation.toString", "call options.disambiguation.toString", - // lookup in PlainDateTime.p.toZonedDateTime - "get timeZone.getOffsetNanosecondsFor", - "get timeZone.getPossibleInstantsFor", - // GetInstantFor - "call timeZone.getPossibleInstantsFor", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -const fallBackInstance = new Temporal.PlainDateTime(2000, 10, 29, 1, 30, 0, 0, 0, 0, calendar); -const springForwardInstance = new Temporal.PlainDateTime(2000, 4, 2, 2, 30, 0, 0, 0, 0, calendar); -// clear observable operations that occurred during the constructor calls -actual.splice(0); - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); const options = TemporalHelpers.propertyBagObserver(actual, { disambiguation: "compatible" }, "options"); -instance.toZonedDateTime(timeZone, options); -assert.compareArray(actual, expected, "order of operations at normal wall-clock time"); -actual.splice(0); // clear - -fallBackInstance.toZonedDateTime(timeZone, options); -assert.compareArray(actual, expected, "order of operations at repeated wall-clock time"); -actual.splice(0); // clear - -springForwardInstance.toZonedDateTime(timeZone, options); -assert.compareArray(actual, expected.concat([ - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getPossibleInstantsFor", -]), "order of operations at skipped wall-clock time"); -actual.splice(0); // clear - -const rejectOptions = TemporalHelpers.propertyBagObserver(actual, { disambiguation: "reject" }, "options"); -assert.throws(RangeError, () => springForwardInstance.toZonedDateTime(timeZone, rejectOptions)); -assert.compareArray(actual, expected, "order of operations at skipped wall-clock time with disambiguation: reject"); +instance.toZonedDateTime("UTC", options); +assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/plain-custom-timezone.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/plain-custom-timezone.js deleted file mode 100644 index ba2ad70da16..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/plain-custom-timezone.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: TimeZone.getPossibleInstantsFor called after processing timeZone and options -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - "get options.disambiguation", - "get options.disambiguation.toString", - "call options.disambiguation.toString", - "get timeZone.getOffsetNanosecondsFor", - "get timeZone.getPossibleInstantsFor", - "call timeZone.getPossibleInstantsFor", -]; - -Object.defineProperty(Temporal.TimeZone, "from", { - get() { - actual.push("get Temporal.TimeZone.from"); - return undefined; - }, -}); - -const dateTime = Temporal.PlainDateTime.from("1975-02-02T14:25:36.123456789"); -const instant = Temporal.Instant.fromEpochNanoseconds(-205156799012345679n); - -const options = TemporalHelpers.propertyBagObserver(actual, { disambiguation: "reject" }, "options"); - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getPossibleInstantsFor(dateTimeArg) { - assert.sameValue(dateTimeArg, dateTime); - return [instant]; - }, -}); - -const result = dateTime.toZonedDateTime(timeZone, options); -assert.sameValue(result.epochNanoseconds, instant.epochNanoseconds); -assert.sameValue(result.getTimeZone(), timeZone); - -assert.compareArray(actual, expected); - -assert.sameValue(result.getISOFields().calendar, dateTime.getISOFields().calendar); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index ffb7d32081d..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => datetime.toZonedDateTime(timeZone)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 8b45971743e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.toZonedDateTime(timeZone), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 098fe94e1b3..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => datetime.toZonedDateTime(timeZone)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 8000054804c..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(TypeError, () => datetime.toZonedDateTime(timeZone)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index e07be8d7d39..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.plaindatetime.prototype.tozoneddatetime step 6: - 6. Let _instant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _temporalDateTime_, *"compatible"*). - sec-temporal-builtintimezonegetinstantfor step 1: - 1. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-builtintimezonegetinstantfor step 14: - 14. Assert: _disambiguation_ is *"compatible"* or *"later"*. - sec-temporal-builtintimezonegetinstantfor step 16: - 16. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _later_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected1 = [ - "2000-05-02T12:34:56.987654321", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - datetime.toZonedDateTime(timeZone); -}, expected1); - -// Same, but test the other path where the time doesn't exist and -// GetPossibleInstantsFor is called again on a later time - -const expected2 = [ - "2030-01-01T00:30:00", - "2030-01-01T01:30:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.PlainDateTime(2030, 1, 1, 0, 30); - datetime.toZonedDateTime(timeZone); -}, expected2); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js index 07e48045a33..577199f9121 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string.js index c685234e9c5..c5c2300e526 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string.js @@ -4,33 +4,12 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tozoneddatetime description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.PlainDateTime(2000, 5, 2); ["UTC", "+01:30"].forEach((timeZone) => { const result = instance.toZonedDateTime(timeZone); - assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); + assert.sameValue(result.timeZoneId, timeZone, `time zone slot should store string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-wrong-type.js index 1caf19363d4..e0c7c084315 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plaindatetime.prototype.tozoneddatetime description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/two-digit-year.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/two-digit-year.js new file mode 100644 index 00000000000..13b6f2bc4f6 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/two-digit-year.js @@ -0,0 +1,16 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: > + Check result when Gregorian year is two digits (in case underlying + implementation uses Date and forgets to use setFullYear) +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(98, 10, 29, 10, 46, 38, 271, 986, 102); +["earlier", "later", "compatible", "reject"].forEach((disambiguation) => { + const result = instance.toZonedDateTime("+06:00", { disambiguation }); + assert.sameValue(result.epochNanoseconds, -59048507601_728_013_898n, "Result is 0098-10-29T04:46:38.271986102Z regardless of disambiguation"); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/year-zero.js b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/year-zero.js new file mode 100644 index 00000000000..afcc99c42ae --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/year-zero.js @@ -0,0 +1,23 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: > + Check result in Gregorian year zero (in case underlying + implementation uses Date and calls setFullYear on a non-leap year) +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDateTime(0, 10, 29, 10, 46, 38, 271, 986, 102); +["earlier", "later", "compatible", "reject"].forEach((disambiguation) => { + const result = instance.toZonedDateTime("+06:00", { disambiguation }); + assert.sameValue(result.epochNanoseconds, -62141109201_728_013_898n, "Result is 0000-10-29T04:46:38.271986102Z regardless of disambiguation"); +}); + +// leap day +const instanceLeap = new Temporal.PlainDateTime(0, 2, 29); +["earlier", "later", "compatible", "reject"].forEach((disambiguation) => { + const result = instanceLeap.toZonedDateTime("-00:01", { disambiguation }); + assert.sameValue(result.epochNanoseconds, -62162121540_000_000_000n, "Result is 0000-02-29T00:01Z regardless of disambiguation"); +}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index e0fec78cee5..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, calendar: "iso8601" }; -instance.until(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate.js index be3e5dc0683..e0efca7077d 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-plaindate.js @@ -14,8 +14,8 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date, calendar) => { - const datetime = new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 987, 654, 321, calendar); +TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => { + const datetime = new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 987, 654, 321, "iso8601"); const result = datetime.until(date); assert.sameValue(result.total({ unit: "nanoseconds" }), -987654321, "PlainDate is converted to midnight"); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-wrong-type.js index 0f1dd41ef12..05c7f85cb9e 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.plaindatetime.prototype.until description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js index 54102c1ab88..f17061ed4c9 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js @@ -35,9 +35,8 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); const diff = new Temporal.PlainDateTime(1970, 1, 1).until(datetime); -TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 1, 1, 1, 1, 0, 999); +TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 0, 59, 1, 1, 1, 1); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 01d9f07c85f..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.until(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 475c96d0b3e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => plain.until(zoned), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 06e66568957..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.until(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index eeeb0003869..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => plain.until(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 3bf1018a697..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.until(new Temporal.PlainDateTime(2001, 6, 13)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateadd-called-with-plaindate-instance.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateadd-called-with-plaindate-instance.js deleted file mode 100644 index 4f80b26c92f..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateadd-called-with-plaindate-instance.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: > - relativeTo parameters that are not ZonedDateTime or undefined, are always - converted to PlainDate for observable calendar calls -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddPlainDateInstance(); -const instance = new Temporal.PlainDateTime(1970, 1, 1, 0, 0, 0, 0, 0, 0, calendar); -instance.until(new Temporal.PlainDateTime(2000, 5, 2, 0, 0, 0, 0, 0, 0, calendar), { smallestUnit: "month" }); -assert(calendar.dateAddCallCount > 0, "assertions in calendar.dateAdd() should have been tested"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index e7c11b8ecbf..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.until(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-copy-of-options.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-copy-of-options.js deleted file mode 100644 index 3805a5ece4c..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-copy-of-options.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: The dateUntil() method on the calendar is called with a copy of the options bag -features: [Temporal] ----*/ - -const originalOptions = { - largestUnit: "year", - shouldBeCopied: {}, -}; -let called = false; - -class Calendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateUntil(d1, d2, options) { - called = true; - assert.notSameValue(options, originalOptions, "options bag should be a copy"); - assert.sameValue(options.shouldBeCopied, originalOptions.shouldBeCopied, "options bag should be a shallow copy"); - return new Temporal.Duration(); - } -} -const calendar = new Calendar(); -const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -const later = new Temporal.PlainDateTime(2001, 6, 3, 13, 35, 57, 988, 655, 322, calendar); -earlier.until(later, originalOptions); -assert(called, "calendar.dateUntil must be called"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js deleted file mode 100644 index 111ba10c35f..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: > - Calendar.dateUntil method is called with a null-prototype object as the - options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -const argument = new Temporal.PlainDateTime(2022, 6, 14, 18, 21, 36, 660, 690, 387, calendar); -instance.until(argument, { largestUnit: "months" }); -assert.sameValue(calendar.dateUntilCallCount, 1, "dateUntil should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-plaindate-calendar.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-plaindate-calendar.js deleted file mode 100644 index ba28347ed66..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-plaindate-calendar.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: calendar.dateUntil() is passed PlainDate objects with the receiver's calendar -info: | - DifferenceISODateTime ( y1, mon1, d1, h1, min1, s1, ms1, mus1, ns1, y2, mon2, d2, h2, min2, s2, ms2, mus2, ns2, calendar, largestUnit [ , options ] ) - - 8. Let _date1_ be ? CreateTemporalDate(_balanceResult_.[[Year]], _balanceResult_.[[Month]], _balanceResult_.[[Day]], _calendar_). - 9. Let _date2_ be ? CreateTemporalDate(_y2_, _mon2_, _d2_, _calendar_). - 12. Let _dateDifference_ be ? CalendarDateUntil(_calendar_, _date1_, _date2_, _untilOptions_). -features: [Temporal] ----*/ - -class Calendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateUntil(d1, d2) { - assert.sameValue(d1.getCalendar(), this, "d1.calendar"); - assert.sameValue(d2.getCalendar(), this, "d2.calendar"); - return new Temporal.Duration(); - } -} -const calendar = new Calendar(); -const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -const later = new Temporal.PlainDateTime(2001, 6, 3, 13, 35, 57, 988, 655, 322, calendar); -const result = earlier.until(later); -assert(result instanceof Temporal.Duration, "result"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index 5e444caf38a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: The options object passed to calendar.dateUntil has a largestUnit property with its value in the singular form -info: | - sec-temporal.plaindatetime.prototype.until step 13: - 13. Let _diff_ be ? DifferenceISODateTime(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], _other_.[[ISOYear]], _other_.[[ISOMonth]], _other_.[[ISODay]], _other_.[[ISOHour]], _other_.[[ISOMinute]], _other_.[[ISOSecond]], _other_.[[ISOMillisecond]], _other_.[[ISOMicrosecond]], _other_.[[ISONanosecond]], _dateTime_.[[Calendar]], _largestUnit_, _options_). - sec-temporal-differenceisodatetime steps 9–11: - 9. Let _dateLargestUnit_ be ! LargerOfTwoTemporalUnits(*"day"*, _largestUnit_). - 10. Let _untilOptions_ be ? MergeLargestUnitOption(_options_, _dateLargestUnit_). - 11. Let _dateDifference_ be ? CalendarDateUntil(_calendar_, _date1_, _date2_, _untilOptions_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); - const later = new Temporal.PlainDateTime(2001, 6, 3, 13, 35, 57, 988, 655, 322, calendar); - earlier.until(later, { largestUnit }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-fields-iterable.js deleted file mode 100644 index a65bc99b1dd..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindatetime.prototype.until step 3: - 3. Set _other_ to ? ToTemporalDateTime(_other_). - sec-temporal-totemporaldatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -datetime.until({ year: 2005, month: 6, day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-temporal-object.js index f3fd0477f2d..2e623c4f7d8 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, temporalObject); + const date = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); date.until({ year: 2005, month: 6, day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/constructor-in-calendar-fields.js deleted file mode 100644 index 36cd1428a07..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js deleted file mode 100644 index a644ccbd65a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: Using different calendars is not acceptable -features: [Temporal] ----*/ - -const dt1 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0); -const dt2 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "custom", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); - -assert.throws( - RangeError, - () => dt1.until(dt2), - "cannot use until with PDTs having different calendars" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/duplicate-calendar-fields.js deleted file mode 100644 index 19dd63b1164..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => instance.until(arg)); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js index d75480f4cdf..84d734ed5ad 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/order-of-operations.js @@ -11,30 +11,6 @@ features: [Temporal] const expected = [ // ToTemporalDateTime "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.dateFromFields", - "get other.calendar.fields", - "call other.calendar.fields", "get other.day", "get other.day.valueOf", "call other.day.valueOf", @@ -65,36 +41,23 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", - "call other.calendar.dateFromFields", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, ownCalendar); +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, @@ -107,8 +70,8 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { millisecond: 250, microsecond: 500, nanosecond: 750, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { @@ -122,108 +85,7 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au }, "options"); } -// clear any observable things that happened while constructing the objects -actual.splice(0); - // basic order of observable operations with calendar call, without rounding: instance.until(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years" })); -assert.compareArray(actual, expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", -]), "order of operations"); -actual.splice(0); // clear - -// short-circuit for identical objects: -const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 5, - monthCode: "M05", - day: 2, - hour: 12, - minute: 34, - second: 56, - millisecond: 987, - microsecond: 654, - nanosecond: 321, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); - -instance.until(identicalPropertyBag, createOptionsObserver()); -assert.compareArray(actual, expected, "order of operations with identical datetimes"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest year: -const expectedOpsForYearRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); +assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest year and skips a DateUntil call: -const otherDatePropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual, { - year: 2001, - month: 5, - monthCode: "M05", - day: 2, - hour: 12, - minute: 34, - second: 56, - millisecond: 987, - microsecond: 654, - nanosecond: 321, - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); -const expectedOpsForYearRoundingSameMonth = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherDatePropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months/weeks"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest month: -const expectedOpsForMonthRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" })); -assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = years"); -actual.splice(0); // clear - -// code path through RoundDuration that rounds to the nearest week: -const expectedOpsForWeekRounding = expected.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // CalendarDateUntil - "call this.calendar.dateUntil", - // RoundRelativeDuration - "call this.calendar.dateUntil", - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); -assert.compareArray(actual, expectedOpsForWeekRounding, "order of operations with smallestUnit = weeks"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/proto-in-calendar-fields.js deleted file mode 100644 index ecf8ff624ff..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - -assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/read-time-fields-before-datefromfields.js deleted file mode 100644 index bcd805bfc6a..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.plaindatetime.prototype.until step 3: - 3. Set _other_ to ? ToTemporalDateTime(_other_). - sec-temporal-totemporaldatetime step 2.e: - e. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = new Temporal.PlainDateTime(2021, 3, 31, 12, 34, 56, 987, 654, 321); -const duration = datetime.until({ year: 2021, month: 3, day: 31, calendar }); - -TemporalHelpers.assertDuration(duration, 0, 0, 0, 0, -12, -34, -56, -987, -654, -321); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/result-mixed-sign.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/result-mixed-sign.js deleted file mode 100644 index 1df299a3c24..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/result-mixed-sign.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: > - RangeError when inconsistent custom calendar method causes mixed signs of - Duration components -features: [Temporal] ----*/ - -// Test case provided by André Bargull - -const cal = new (class extends Temporal.Calendar { - dateUntil(date, duration, options) { - return super.dateUntil(date, duration, options).negated(); - } -})("iso8601"); - -const one = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, cal); -const two = new Temporal.PlainDateTime(2020, 5, 10, 12, 12, 0, 0, 0, 0, cal); - -assert.throws(RangeError, () => one.until(two, { - largestUnit: "years", - smallestUnit: "hours" -})); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/rounding-zero-year-month-week-length.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/rounding-zero-year-month-week-length.js deleted file mode 100644 index dc515ec0fc8..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/until/rounding-zero-year-month-week-length.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const dt1 = new Temporal.PlainDateTime(1970, 1, 1, 0, 0, 0, 0, 0, 0, cal); -const dt2 = new Temporal.PlainDateTime(1971, 1, 1, 0, 0, 0, 0, 0, 1, cal); - -assert.throws(RangeError, () => dt1.until(dt2, { smallestUnit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => dt1.until(dt2, { smallestUnit: "months" }), "zero month length handled correctly"); -assert.throws(RangeError, () => dt1.until(dt2, { smallestUnit: "weeks" }), "zero week length handled correctly"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/basic.js b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/basic.js index 6273dbc54cd..4d8c71fd684 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/basic.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/basic.js @@ -7,6 +7,5 @@ description: Checking week of year for a "normal" case (non-undefined, non-bound features: [Temporal] ---*/ -const calendar = Temporal.Calendar.from("iso8601"); -const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar); +const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); assert.sameValue(datetime.weekOfYear, 47, "check week of year information"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index ac2f66133ae..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.weekofyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const weekOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "weekOfYear"); -Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("weekOfYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.weekOfYear; - -Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", weekOfYearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js deleted file mode 100644 index f9b43f88afe..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.weekofyear -description: > - Temporal.PlainDateTime.prototype.weekOfYear returns undefined for all - custom calendars where weekOfYear() returns undefined. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - weekOfYear() { - return undefined; - } -} - -const calendar = new CustomCalendar(); -const customCalendarDate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); -assert.sameValue(customCalendarDate.weekOfYear, undefined); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom.js deleted file mode 100644 index 90cbf33fad6..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.weekofyear -description: Custom calendar tests for weekOfYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - weekOfYear(...args) { - ++calls; - assert.compareArray(args, [pdt], "weekOfYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.weekOfYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/validate-calendar-value.js deleted file mode 100644 index 69ff6a2c5ce..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/validate-calendar-value.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.weekofyear -description: Validate result returned from calendar weekOfYear() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - weekOfYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.weekOfYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 880de09a030..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainDateTime(2023, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.with({ day: 5 }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 27b0e439fe8..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); - }, -}); -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.with({ year: 2001 }); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-iterable.js deleted file mode 100644 index b509cd42736..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-iterable.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plaindatetime.prototype.with step 9: - 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -datetime.with({ year: 2005 }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index bb98828e7cb..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -instance.with({ day: 24 }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-merge-fields-returns-primitive.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-merge-fields-returns-primitive.js deleted file mode 100644 index 0aed6a31be1..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-merge-fields-returns-primitive.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: > - with() should throw a TypeError if mergeFields() returns a primitive, - without passing the value on to any other calendar methods -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Symbol, Temporal] ----*/ - -[undefined, null, true, 3.14159, "bad value", Symbol("no"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarMergeFieldsReturnsPrimitive(primitive); - const instance = new Temporal.PlainDateTime(2000, 5, 2, 15, 30, 45, 987, 654, 321, calendar); - assert.throws(TypeError, () => instance.with({ year: 2005 }), "bad return from mergeFields() throws"); - assert.sameValue(calendar.dateFromFieldsCallCount, 0, "dateFromFields() never called"); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js deleted file mode 100644 index bbfe4145be5..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: > - Calendar.mergeFields method is called with null-prototype fields objects -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckMergeFieldsPrototypePollution(); -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -instance.with({ day: 24 }); -assert.sameValue(calendar.mergeFieldsCallCount, 1, "mergeFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-options.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-options.js deleted file mode 100644 index 69a22591fae..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-options.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: > - The options argument is copied and the copy is passed to - Calendar#dateFromFields. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const options = { - extra: "property", -}; -let calledDateFromFields = 0; -class Calendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateFromFields(fields, optionsArg) { - ++calledDateFromFields; - assert.notSameValue(optionsArg, options, "should pass copied options object"); - assert.sameValue(optionsArg.extra, "property", "should copy all properties from options object"); - assert.sameValue(Object.getPrototypeOf(optionsArg), null, "Copy has null prototype"); - return super.dateFromFields(fields, optionsArg); - } -}; -const calendar = new Calendar(); -const plaindatetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); -const result = plaindatetime.with({ year: 2005 }, options); -TemporalHelpers.assertPlainDateTime(result, 2005, 5, "M05", 2, 12, 34, 56, 987, 654, 321); -assert.sameValue(calledDateFromFields, 1, "should have called overridden dateFromFields once"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/constructor-in-calendar-fields.js deleted file mode 100644 index 83c17c61423..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); - -assert.throws(RangeError, () => datetime.with({hour: 12})); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/copies-merge-fields-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/copies-merge-fields-object.js deleted file mode 100644 index 6b43351aa29..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/copies-merge-fields-object.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: The object returned from mergeFields() is copied before being passed to dateFromFields(). -info: | - sec-temporal.plaindatetime.prototype.with steps 13–15: - 13. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialDate_). - 14. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, «»). - 15. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields step 2: - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get day", - "get day.valueOf", - "call day.valueOf", - "get hour", - "get hour.valueOf", - "call hour.valueOf", - "get microsecond", - "get microsecond.valueOf", - "call microsecond.valueOf", - "get millisecond", - "get millisecond.valueOf", - "call millisecond.valueOf", - "get minute", - "get minute.valueOf", - "call minute.valueOf", - "get month", - "get month.valueOf", - "call month.valueOf", - "get monthCode", - "get monthCode.toString", - "call monthCode.toString", - "get nanosecond", - "get nanosecond.valueOf", - "call nanosecond.valueOf", - "get second", - "get second.valueOf", - "call second.valueOf", - "get year", - "get year.valueOf", - "call year.valueOf", -]; - -const calendar = TemporalHelpers.calendarMergeFieldsGetters(); -const datetime = new Temporal.PlainDateTime(2021, 3, 31, 12, 34, 56, 987, 654, 321, calendar); -datetime.with({ year: 2022 }); - -assert.compareArray(calendar.mergeFieldsReturnOperations, expected, "getters called on mergeFields return"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/duplicate-calendar-fields.js deleted file mode 100644 index 290ee6442d2..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['nanosecond'], ['second'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); - - assert.throws(RangeError, () => datetime.with({hour: 12})); -} diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/order-of-operations.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/order-of-operations.js index 7b32ae38884..9cf38b9cdaa 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/order-of-operations.js @@ -13,26 +13,9 @@ const expected = [ "get fields.calendar", "get fields.timeZone", // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", - "getOwnPropertyDescriptor options.extra", - "get options.extra", - // lookup - "get this.calendar.dateFromFields", - "get this.calendar.fields", - "get this.calendar.mergeFields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields on receiver - "get this.calendar.day", - "call this.calendar.day", - "get this.calendar.month", - "call this.calendar.month", - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", + "get options.overflow.toString", + "call options.overflow.toString", // PrepareTemporalFields on argument "get fields.day", "get fields.day.valueOf", @@ -64,16 +47,10 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", - // CalendarMergeFields - "call this.calendar.mergeFields", - // InterpretTemporalDateTimeFields - "get options.overflow.toString", - "call options.overflow.toString", - "call this.calendar.dateFromFields", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); +const calendar = "iso8601"; const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, calendar); // clear observable operations that occurred during the constructor call actual.splice(0); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/proto-in-calendar-fields.js deleted file mode 100644 index 2cdeb3356f9..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const datetime = new Temporal.PlainDateTime(2023, 5, 1, 0, 0, 0, 0, 0, 0, calendar); - -assert.throws(RangeError, () => datetime.with({hour: 12})); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/read-time-fields-before-datefromfields.js deleted file mode 100644 index e1bfefea9ee..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/with/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.plaindatetime.prototype.with step 15: - 15. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = new Temporal.PlainDateTime(2021, 3, 31, 12, 34, 56, 987, 654, 321, calendar); -const newDatetime = datetime.with({ year: 2022 }); - -assert.sameValue(newDatetime.hour, 12, "hour value"); -assert.sameValue(newDatetime.minute, 34, "minute value"); -assert.sameValue(newDatetime.second, 56, "second value"); -assert.sameValue(newDatetime.millisecond, 987, "millisecond value"); -assert.sameValue(newDatetime.microsecond, 654, "microsecond value"); -assert.sameValue(newDatetime.nanosecond, 321, "nanosecond value"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js deleted file mode 100644 index 249c69712f0..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.withcalendar -description: String argument, if it names a recognizable calendar, gets cast -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const calendar = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "something special", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - toString() { return "something special"; }, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar); -const result = dt.withCalendar("iso8601"); - -TemporalHelpers.assertPlainDateTime( - result, - 1976, 11, "M11", 18, 15, 23, 30, 123, 456, 789, - "'iso8601' is a recognizable calendar" -); - -assert.sameValue( - result.getISOFields().calendar, - "iso8601", - "underlying calendar has changed and calendar slot stores a string" -); - -assert.throws( - RangeError, - () => dt.withCalendar("this will fail"), - "unknown calendar throws" -); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/basic.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/basic.js index 3e5f2f4bc88..7ba356d3c6c 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/basic.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/basic.js @@ -9,7 +9,7 @@ includes: [temporalHelpers.js] ---*/ const dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789); -const calendar = new Temporal.Calendar("iso8601"); +const calendar = "iso8601"; const result = dt.withCalendar(calendar); @@ -19,4 +19,4 @@ TemporalHelpers.assertPlainDateTime( "works" ); -assert.sameValue(result.getCalendar(), calendar, "underlying calendar is unchanged"); +assert.sameValue(result.calendarId, calendar, "underlying calendar is unchanged"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/branding.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/branding.js index 911f96a77f9..7363ee09463 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/branding.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/branding.js @@ -11,7 +11,7 @@ const withCalendar = Temporal.PlainDateTime.prototype.withCalendar; assert.sameValue(typeof withCalendar, "function"); -const args = [new Temporal.Calendar("iso8601")]; +const args = ["iso8601"]; assert.throws(TypeError, () => withCalendar.apply(undefined, args), "undefined"); assert.throws(TypeError, () => withCalendar.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js deleted file mode 100644 index dda94fb31fa..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.withcalendar -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.withCalendar("iso8601"); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-case-insensitive.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-case-insensitive.js index 7545f4af257..2f7251ff8b9 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-case-insensitive.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-case-insensitive.js @@ -7,29 +7,7 @@ description: Calendar names are case-insensitive features: [Temporal] ---*/ -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); let arg = "iSo8601"; const result = instance.withCalendar(arg); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-iso-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-iso-string.js index b6f4899488d..6f5524a0d86 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-iso-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-iso-string.js @@ -7,29 +7,7 @@ description: An ISO 8601 string can be converted to a calendar ID in Calendar features: [Temporal] ---*/ -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); for (const arg of [ "2020-01-01", @@ -42,5 +20,5 @@ for (const arg of [ "2020-01[u-ca=iso8601]", ]) { const result = instance.withCalendar(arg); - assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); + assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); } diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-number.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-number.js index 6b333b46429..2ea12911744 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-number.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-number.js @@ -7,29 +7,7 @@ description: A number is not allowed to be a calendar features: [Temporal] ---*/ -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); const numbers = [ 1, diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-string-leap-second.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-string-leap-second.js index e6f877f4ab2..40b465ab20c 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-string-leap-second.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-string-leap-second.js @@ -7,29 +7,7 @@ description: Leap second is a valid ISO string for Calendar features: [Temporal] ---*/ -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); const arg = "2016-12-31T23:59:60"; const result = instance.withCalendar(arg); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-string.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-string.js index 6f570a53b7c..39abb858525 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-string.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-string.js @@ -7,31 +7,9 @@ description: A calendar ID is valid input for Calendar features: [Temporal] ---*/ -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); const arg = "iso8601"; const result = instance.withCalendar(arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-temporal-object.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-temporal-object.js index d7dc0898668..0118d0510d5 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-temporal-object.js @@ -3,7 +3,9 @@ /*--- esid: sec-temporal.plaindatetime.prototype.withcalendar -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots +description: > + Fast path for converting other Temporal objects to calendar ID by reading + internal slots info: | sec-temporal-totemporalcalendar step 1.b: b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then @@ -22,8 +24,6 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT const actual = []; const expected = []; - const calendar = arg.getISOFields().calendar; - Object.defineProperty(arg, "calendar", { get() { actual.push("get calendar"); @@ -31,31 +31,9 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT }, }); - const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); + const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); const result = instance.withCalendar(arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar"); assert.compareArray(actual, expected, "calendar getter not called"); }); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-wrong-type.js index 2d4c1958dd5..14aad0c9754 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/calendar-wrong-type.js @@ -5,33 +5,11 @@ esid: sec-temporal.plaindatetime.prototype.withcalendar description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar + for Calendar features: [BigInt, Symbol, Temporal] ---*/ -const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); const primitiveTests = [ [null, "null"], @@ -51,9 +29,8 @@ for (const [arg, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [arg, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/subclassing-ignored.js b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/subclassing-ignored.js index 2cff05a4dc4..23998a23909 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/subclassing-ignored.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withCalendar/subclassing-ignored.js @@ -8,40 +8,12 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const customCalendar = { - era() { return undefined; }, - eraYear() { return undefined; }, - year() { return 1900; }, - month() { return 2; }, - monthCode() { return "M02"; }, - day() { return 5; }, - id: "custom-calendar", - toString() { return "custom-calendar"; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - TemporalHelpers.checkSubclassingIgnored( Temporal.PlainDateTime, [2000, 5, 2, 12, 34, 56, 987, 654, 321], "withCalendar", - [customCalendar], + ["iso8601"], (result) => { - TemporalHelpers.assertPlainDateTime(result, 1900, 2, "M02", 5, 12, 34, 56, 987, 654, 321); - assert.sameValue(result.getCalendar(), customCalendar, "calendar result"); + TemporalHelpers.assertPlainDateTime(result, 2000, 5, "M05", 2, 12, 34, 56, 987, 654, 321); }, ); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js index ca5ae0e47a4..21d0c36972d 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js @@ -35,10 +35,9 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); const pdt = new Temporal.PlainDateTime(2000, 5, 2); const newpdt = pdt.withPlainTime(datetime); -TemporalHelpers.assertPlainDateTime(newpdt, 2000, 5, "M05", 2, 1, 1, 1, 1, 0, 999); +TemporalHelpers.assertPlainDateTime(newpdt, 2000, 5, "M05", 2, 0, 59, 1, 1, 1, 1); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 5698566e0ed..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.withplaintime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.withPlainTime(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index ea50ec95db1..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.withplaintime -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => plain.withPlainTime(zoned), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index f1e0c50e5f4..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.withplaintime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => plain.withPlainTime(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 0e7f04aa76e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.withplaintime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const plain = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); - const zoned = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => plain.withPlainTime(zoned)); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/year/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/year/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 0ed38f01ff0..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/year/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.year -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const yearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "year"); -Object.defineProperty(Temporal.Calendar.prototype, "year", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("year should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.year; - -Object.defineProperty(Temporal.Calendar.prototype, "year", yearOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/year/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/year/custom.js deleted file mode 100644 index 04f1b43ccb4..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/year/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.year -description: Custom calendar tests for year(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - year(...args) { - ++calls; - assert.compareArray(args, [pdt], "year arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.year; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/year/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/year/validate-calendar-value.js deleted file mode 100644 index e58780e1daa..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/year/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.year -description: Validate result returned from calendar year() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [NaN, RangeError], - ["string", TypeError], - [{}, TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, RangeError], - [-0.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - year() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.year, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - year() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.sameValue(instance.year, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/basic.js b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/basic.js index ec1a834b408..41f3aaf453b 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/basic.js +++ b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/basic.js @@ -7,6 +7,5 @@ description: Checking yearOfWeek for a "normal" case (non-undefined, non-boundar features: [Temporal] ---*/ -const calendar = Temporal.Calendar.from("iso8601"); -const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, calendar); +const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); assert.sameValue(datetime.yearOfWeek, 1976, "check yearOfWeek information"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js deleted file mode 100644 index b0ce17cc24e..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.yearofweek -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const yearOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearOfWeek"); -Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("yearOfWeek should not be looked up"); - }, -}); - -const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "iso8601"); -instance.yearOfWeek; - -Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", yearOfWeekOriginal); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js deleted file mode 100644 index 425b3a0360b..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.yearofweek -description: > - Temporal.PlainDateTime.prototype.yearOfWeek returns undefined for all - custom calendars where yearOfWeek() returns undefined. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearOfWeek() { - return undefined; - } -} - -const calendar = new CustomCalendar(); -const customCalendarDate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); -assert.sameValue(customCalendarDate.yearOfWeek, undefined); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom.js deleted file mode 100644 index 556ba8e5d59..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.yearofweek -description: Custom calendar tests for yearOfWeek(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearOfWeek(...args) { - ++calls; - assert.compareArray(args, [pdt], "yearOfWeek arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); -const result = pdt.yearOfWeek; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js b/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js deleted file mode 100644 index 0efa0075acb..00000000000 --- a/test/built-ins/Temporal/PlainDateTime/prototype/yearOfWeek/validate-calendar-value.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.yearofweek -description: Validate result returned from calendar yearOfWeek() method -features: [Temporal] ----*/ - -const badResults = [ - [Infinity, RangeError], - [-Infinity, RangeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [NaN, RangeError], - ["string", TypeError], - [{}, TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, RangeError], - [-0.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - yearOfWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.yearOfWeek, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - yearOfWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.sameValue(instance.yearOfWeek, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/calendar-iso-string.js b/test/built-ins/Temporal/PlainMonthDay/calendar-iso-string.js new file mode 100644 index 00000000000..9affdf732f2 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/calendar-iso-string.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.constructor +description: An ISO string is not valid input for a constructor's calendar param +features: [Temporal] +---*/ + +assert.throws( + RangeError, + () => new Temporal.PlainMonthDay(12, 15, "1997-12-04[u-ca=iso8601]", 1972), + "An ISO string is not a valid calendar ID for constructor parameter" +); diff --git a/test/built-ins/Temporal/PlainMonthDay/calendar-string.js b/test/built-ins/Temporal/PlainMonthDay/calendar-string.js index 222645121f7..110c7d4d4e6 100644 --- a/test/built-ins/Temporal/PlainMonthDay/calendar-string.js +++ b/test/built-ins/Temporal/PlainMonthDay/calendar-string.js @@ -10,4 +10,4 @@ features: [Temporal] const arg = "iso8601"; const result = new Temporal.PlainMonthDay(12, 15, arg, 1972); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/PlainMonthDay/calendar-temporal-object.js b/test/built-ins/Temporal/PlainMonthDay/calendar-temporal-object.js deleted file mode 100644 index fa1fa9ba33d..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/calendar-temporal-object.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const result = new Temporal.PlainMonthDay(12, 15, arg, 1972); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/calendar-undefined.js b/test/built-ins/Temporal/PlainMonthDay/calendar-undefined.js index 442da5e7350..e7790632288 100644 --- a/test/built-ins/Temporal/PlainMonthDay/calendar-undefined.js +++ b/test/built-ins/Temporal/PlainMonthDay/calendar-undefined.js @@ -9,12 +9,6 @@ features: [Temporal] const args = [5, 2]; -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - const dateExplicit = new Temporal.PlainMonthDay(...args, undefined); assert.sameValue(dateExplicit.calendarId, "iso8601"); diff --git a/test/built-ins/Temporal/PlainMonthDay/calendar-wrong-type.js b/test/built-ins/Temporal/PlainMonthDay/calendar-wrong-type.js index 5bd4a613e84..974ce17773d 100644 --- a/test/built-ins/Temporal/PlainMonthDay/calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainMonthDay/calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plainmonthday description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar + for Calendar features: [BigInt, Symbol, Temporal] ---*/ @@ -27,9 +27,8 @@ for (const [arg, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [arg, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 33d673966a3..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/from/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.from -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const arg = { monthCode: "M11", day: 23, calendar: "iso8601" }; -Temporal.PlainMonthDay.from(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-plainmonthday.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-plainmonthday.js index 760ae71fd1d..35c862ccc97 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/argument-plainmonthday.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-plainmonthday.js @@ -18,7 +18,7 @@ TemporalHelpers.assertPlainMonthDay( /* isoYear = */ 2000 ); -assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied"); +assert.sameValue(result.calendarId, orig.calendarId, "Calendar is copied"); assert.notSameValue( result, diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-iso-string.js index d19bf877cc0..249d41f1ff2 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-iso-string.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-iso-string.js @@ -21,5 +21,5 @@ for (const calendar of [ const arg = { monthCode: "M11", day: 18, calendar }; const result = Temporal.PlainMonthDay.from(arg); TemporalHelpers.assertPlainMonthDay(result, "M11", 18, `Calendar created from string "${calendar}"`); - assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); + assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); } diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-string.js index f1357d0c67a..12e37f53afa 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-string.js @@ -13,4 +13,4 @@ const calendar = "iso8601"; const arg = { monthCode: "M11", day: 18, calendar }; const result = Temporal.PlainMonthDay.from(arg); TemporalHelpers.assertPlainMonthDay(result, "M11", 18, `Calendar created from string "${calendar}"`); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-wrong-type.js index 8dc29c766d3..9d182cf6161 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-propertybag-calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plainmonthday.from description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ @@ -28,10 +28,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/from/basic.js b/test/built-ins/Temporal/PlainMonthDay/from/basic.js new file mode 100644 index 00000000000..77e4edec71e --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/basic.js @@ -0,0 +1,35 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: Returns correctly with valid data. +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const options = [ + { overflow: "constrain" }, + { overflow: "reject" }, + {}, + undefined, +]; +options.forEach((opt) => { + const optionsDesc = opt && JSON.stringify(opt); + result = Temporal.PlainMonthDay.from({ year: 2021, month: 7, day: 3 }, opt); + TemporalHelpers.assertPlainMonthDay(result, "M07", 3, `month 7, day 3, with year, options = ${optionsDesc}`); + result = Temporal.PlainMonthDay.from({ year: 2021, month: 12, day: 31 }, opt); + TemporalHelpers.assertPlainMonthDay(result, "M12", 31, `month 12, day 31, with year, options = ${optionsDesc}`); + result = Temporal.PlainMonthDay.from({ monthCode: "M07", day: 3 }, opt); + TemporalHelpers.assertPlainMonthDay(result, "M07", 3, `monthCode M07, day 3, options = ${optionsDesc}`); + result = Temporal.PlainMonthDay.from({ monthCode: "M12", day: 31 }, opt); + TemporalHelpers.assertPlainMonthDay(result, "M12", 31, `monthCode M12, day 31, options = ${optionsDesc}`); +}); + +TemporalHelpers.ISOMonths.forEach(({ month, monthCode, daysInMonth }) => { + result = Temporal.PlainMonthDay.from({ month, day: daysInMonth }); + TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, `month ${month}, day ${daysInMonth}`); + + result = Temporal.PlainMonthDay.from({ monthCode, day: daysInMonth }); + TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, `monthCode ${monthCode}, day ${daysInMonth}`); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainMonthDay/from/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 08f69497a29..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/from/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.from -description: > - Calendar.monthDayFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const arg = { monthCode: "M05", day: 2, calendar }; -Temporal.PlainMonthDay.from(arg); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1, "monthDayFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainMonthDay/from/calendar-fields-iterable.js deleted file mode 100644 index ad7c230d2a9..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/from/calendar-fields-iterable.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.from -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainmonthday.from step 3: - 3. Return ? ToTemporalMonthDay(_item_, _options_). - sec-temporal-totemporalmonthday step 2.f: - f. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -Temporal.PlainMonthDay.from({ monthCode: "M05", day: 2, calendar }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/calendar-monthdayfromfields-validates-fields.js b/test/built-ins/Temporal/PlainMonthDay/from/calendar-monthdayfromfields-validates-fields.js deleted file mode 100644 index 87e2b1048d5..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/from/calendar-monthdayfromfields-validates-fields.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.from -description: > - Calendar.monthDayFromFields method validates which fields must be present -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = new class extends Temporal.Calendar { - fields(fields) { - return fields.slice().concat("fnord"); - } - monthDayFromFields(fields) { - // accept everything except fnord - assert.sameValue(fields.fnord, undefined); - return new Temporal.PlainMonthDay(1, 1, this, 1972); - } -}("iso8601"); - -// This would throw on any non-ISO builtin calendar -const result = Temporal.PlainMonthDay.from({ month: 8, day: 16, calendar }); -TemporalHelpers.assertPlainMonthDay(result, "M01", 1, "monthDayFromFields determines what fields are necessary") - -assert.throws( - Test262Error, - () => Temporal.PlainMonthDay.from({ monthCode: "M09", day: 19, fnord: "fnord", calendar }), - "monthDayFromFields determines what fields are disallowed" -); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/calendar-temporal-object.js b/test/built-ins/Temporal/PlainMonthDay/from/calendar-temporal-object.js index 5746c980150..be2904b358a 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/calendar-temporal-object.js @@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.PlainMonthDay.from({ monthCode: "M05", day: 2, calendar: temporalObject }); - assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/from/constructor-in-calendar-fields.js deleted file mode 100644 index 2f79e1144ee..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/from/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.from -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg)); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/from/duplicate-calendar-fields.js deleted file mode 100644 index 858b0466f78..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/from/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.from -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - - assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg)); -} diff --git a/test/built-ins/Temporal/PlainMonthDay/from/fields-missing-properties.js b/test/built-ins/Temporal/PlainMonthDay/from/fields-missing-properties.js index 1b932bc599e..c268ccd0125 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/fields-missing-properties.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/fields-missing-properties.js @@ -9,6 +9,10 @@ features: [Temporal] assert.throws(TypeError, () => Temporal.PlainMonthDay.from({}), "No properties"); assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ day: 15 }), "Only day"); +assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ month: 12 }), "day is required with month"); assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ monthCode: 'M12' }), "Only monthCode"); assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ monthCode: undefined, day: 15 }), "monthCode undefined"); assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ months: 12, day: 31 }), "months plural"); +assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ year: 2021, month: 12 }), "day is required with year and month"); +assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ year: 2021, monthCode: "M12" }), "day is required with year and monthCode"); +assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ year: 2021, day: 17 }), "either month or monthCode is required"); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/fields-object.js b/test/built-ins/Temporal/PlainMonthDay/from/fields-object.js index 000ad58b1d5..20e4e1d3536 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/fields-object.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/fields-object.js @@ -18,8 +18,6 @@ const tests = [ [Temporal.PlainDate.from("2019-10-01"), "PlainDate object"], [{ monthCode: "M10", day: 1, calendar: "iso8601" }, "option bag with monthCode and explicit ISO calendar"], [{ month: 10, day: 1, calendar: "iso8601" }, "option bag with month and explicit ISO calendar"], - [{ monthCode: "M10", day: 1, calendar: Temporal.Calendar.from("iso8601") }, "option bag with monthCode and object ISO calendar"], - [{ month: 10, day: 1, calendar: Temporal.Calendar.from("iso8601") }, "option bag with month and object ISO calendar"], ]; for (const [argument, description = argument] of tests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/from/monthcode-invalid.js b/test/built-ins/Temporal/PlainMonthDay/from/monthcode-invalid.js new file mode 100644 index 00000000000..4957e521780 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/monthcode-invalid.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: Throw RangeError for an out-of-range, conflicting, or ill-formed monthCode +features: [Temporal] +---*/ + +["m1", "M1", "m01"].forEach((monthCode) => { + assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ monthCode, day: 17 }), + `monthCode '${monthCode}' is not well-formed`); +}); + +assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ year: 2021, month: 12, monthCode: "M11", day: 17 }), + "monthCode and month conflict"); + +["M00", "M19", "M99", "M13"].forEach((monthCode) => { + assert.throws(RangeError, () => Temporal.PlainMonthDay.from({ monthCode, day: 17 }), + `monthCode '${monthCode}' is not valid for ISO 8601 calendar`); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-primitive.js index 2dedb669b4c..281311983d4 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-primitive.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-primitive.js @@ -11,8 +11,6 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", @@ -26,11 +24,6 @@ assert.compareArray(actual, expected, "Successful call"); TemporalHelpers.assertPlainMonthDay(result, "M05", 17); actual.splice(0); // empty it for the next check -const failureExpected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", -]; assert.throws(TypeError, () => Temporal.PlainMonthDay.from(7, options)); -assert.compareArray(actual, failureExpected, "Failing call"); +assert.compareArray(actual, expected, "Failing call"); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-string-invalid.js index 297ea0dfd3f..fa3f1256b58 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-string-invalid.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/observable-get-overflow-argument-string-invalid.js @@ -9,9 +9,9 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", ]; let actual = []; diff --git a/test/built-ins/Temporal/PlainMonthDay/from/one-of-era-erayear-undefined.js b/test/built-ins/Temporal/PlainMonthDay/from/one-of-era-erayear-undefined.js new file mode 100644 index 00000000000..46fcbe0b914 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/one-of-era-erayear-undefined.js @@ -0,0 +1,15 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: Does not throw a RangeError if only one of era/eraYear fields is present +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const base = { year: 2000, month: 5, day: 2, era: 'ce' }; +TemporalHelpers.assertPlainMonthDay(Temporal.PlainMonthDay.from(base), 'M05', 2); + +const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 }; +TemporalHelpers.assertPlainMonthDay(Temporal.PlainMonthDay.from(base2), 'M05', 2); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js b/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js index 745a378bb56..8bea4600cb1 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/order-of-operations.js @@ -9,39 +9,10 @@ features: [Temporal] ---*/ const expected = [ - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", - "getOwnPropertyDescriptor options.extra", - "get options.extra", + "get options.overflow.toString", + "call options.overflow.toString", "get fields.calendar", - "has fields.calendar.dateAdd", - "has fields.calendar.dateFromFields", - "has fields.calendar.dateUntil", - "has fields.calendar.day", - "has fields.calendar.dayOfWeek", - "has fields.calendar.dayOfYear", - "has fields.calendar.daysInMonth", - "has fields.calendar.daysInWeek", - "has fields.calendar.daysInYear", - "has fields.calendar.fields", - "has fields.calendar.id", - "has fields.calendar.inLeapYear", - "has fields.calendar.mergeFields", - "has fields.calendar.month", - "has fields.calendar.monthCode", - "has fields.calendar.monthDayFromFields", - "has fields.calendar.monthsInYear", - "has fields.calendar.weekOfYear", - "has fields.calendar.year", - "has fields.calendar.yearMonthFromFields", - "has fields.calendar.yearOfWeek", - // lookup - "get fields.calendar.fields", - "get fields.calendar.monthDayFromFields", - // CalendarFields - "call fields.calendar.fields", // PrepareTemporalFields "get fields.day", "get fields.day.valueOf", @@ -55,11 +26,6 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", - // CalendarMonthDayFromFields - "call fields.calendar.monthDayFromFields", - // inside Calendar.p.monthDayFromFields - "get options.overflow.toString", - "call options.overflow.toString", ]; const actual = []; @@ -68,8 +34,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { month: 1.7, monthCode: "M01", day: 1.7, - calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), -}, "fields"); + calendar: "iso8601", +}, "fields", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", diff --git a/test/built-ins/Temporal/PlainMonthDay/from/overflow.js b/test/built-ins/Temporal/PlainMonthDay/from/overflow.js index 0db03be79a9..c0d2432deb1 100644 --- a/test/built-ins/Temporal/PlainMonthDay/from/overflow.js +++ b/test/built-ins/Temporal/PlainMonthDay/from/overflow.js @@ -36,3 +36,87 @@ assert.throws(RangeError, () => Temporal.PlainMonthDay.from("13-34", { overflow: "invalid ISO string: constrain"); assert.throws(RangeError, () => Temporal.PlainMonthDay.from("13-34", { overflow: "reject" }), "invalid ISO string: reject"); + +const opt = { overflow: "constrain" }; + +let result = Temporal.PlainMonthDay.from({ year: 2021, month: 13, day: 1 }, opt); +TemporalHelpers.assertPlainMonthDay(result, "M12", 1, "month 13 is constrained to 12"); + +result = Temporal.PlainMonthDay.from({ year: 2021, month: 999999, day: 500 }, opt); +TemporalHelpers.assertPlainMonthDay(result, "M12", 31, "month 999999 is constrained to 12 and day 500 is constrained to 31"); + +[-99999, -1, 0].forEach((month) => { + assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from({ year: 2021, month, day: 1 }, opt), + `Month ${month} is out of range for 2021 even with overflow: constrain` + ); +}); + +TemporalHelpers.ISOMonths.forEach(({ month, monthCode, daysInMonth }) => { + const day = daysInMonth + 1; + + result = Temporal.PlainMonthDay.from({ month, day }, opt); + TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, + `day is constrained from ${day} to ${daysInMonth} in month ${month}`); + + result = Temporal.PlainMonthDay.from({ month, day: 9001 }, opt); + TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, + `day is constrained to ${daysInMonth} in month ${month}`); + + result = Temporal.PlainMonthDay.from({ monthCode, day }, opt); + TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, + `day is constrained from ${day} to ${daysInMonth} in monthCode ${monthCode}`); + + result = Temporal.PlainMonthDay.from({ monthCode, day: 9001 }, opt); + TemporalHelpers.assertPlainMonthDay(result, monthCode, daysInMonth, + `day is constrained to ${daysInMonth} in monthCode ${monthCode}`); +}); + +[ ["month", 2], ["monthCode", "M02"] ].forEach(([ name, value ]) => { + result = Temporal.PlainMonthDay.from({ year: 2020, [name]: value, day: 30 }, opt); + TemporalHelpers.assertPlainMonthDay(result, "M02", 29, `${name} ${value} is constrained to 29 in leap year 2020`); + + result = Temporal.PlainMonthDay.from({ year: 2021, [name]: value, day: 29 }, opt); + TemporalHelpers.assertPlainMonthDay(result, "M02", 28, `${name} ${value} is constrained to 28 in common year 2021`); +}); + +[-1, 0, 13, 9995].forEach((month) => { + assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from({year: 2021, month, day: 5}, { overflow: "reject" }), + `Month ${month} is out of range for 2021 with overflow: reject` + ); +}); + +[-1, 0, 32, 999].forEach((day) => { + assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from({ year: 2021, month: 12, day }, { overflow: "reject" }), + `Day ${day} is out of range for 2021-12 with overflow: reject` + ); + assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from({ monthCode: "M12", day }, { overflow: "reject" }), + `Day ${day} is out of range for 2021-M12 with overflow: reject` + ); +}); + +TemporalHelpers.ISOMonths.forEach(({ month, monthCode, daysInMonth }) => { + const day = daysInMonth + 1; + assert.throws(RangeError, + () => Temporal.PlainMonthDay.from({ month, day }, { overflow: "reject" }), + `Day ${day} is out of range for month ${month} with overflow: reject`); + assert.throws(RangeError, + () => Temporal.PlainMonthDay.from({ monthCode, day }, { overflow: "reject" }), + `Day ${day} is out of range for monthCode ${monthCode} with overflow: reject`); +}); + +[ ["month", 2], ["monthCode", "M02"] ].forEach(([ name, value ]) => { + assert.throws(RangeError, + () => Temporal.PlainMonthDay.from({ year: 2020, [name]: value, day: 30 }, { overflow: "reject" }), + `Day 30 is out of range for ${name} ${value} in leap year 2020 with overflow: reject`); + assert.throws(RangeError, + () => Temporal.PlainMonthDay.from({ year: 2021, [name]: value, day: 29 }, { overflow: "reject" }), + `Day 29 is out of range for ${name} ${value} in common year 2021 with overflow: reject`); +}); diff --git a/test/built-ins/Temporal/PlainMonthDay/from/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/from/proto-in-calendar-fields.js deleted file mode 100644 index 5ca42aeb380..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/from/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.from -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainMonthDay.from(arg)); diff --git a/test/built-ins/Temporal/PlainMonthDay/infinity-throws-rangeerror.js b/test/built-ins/Temporal/PlainMonthDay/infinity-throws-rangeerror.js index a96544f0bd0..c4ba7795802 100644 --- a/test/built-ins/Temporal/PlainMonthDay/infinity-throws-rangeerror.js +++ b/test/built-ins/Temporal/PlainMonthDay/infinity-throws-rangeerror.js @@ -8,11 +8,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const isoCalendar = Temporal.Calendar.from('iso8601'); - assert.throws(RangeError, () => new Temporal.PlainMonthDay(Infinity, 1)); assert.throws(RangeError, () => new Temporal.PlainMonthDay(1, Infinity)); -assert.throws(RangeError, () => new Temporal.PlainMonthDay(1, 1, isoCalendar, Infinity)); +assert.throws(RangeError, () => new Temporal.PlainMonthDay(1, 1, "iso8601", Infinity)); const O = (primitiveValue, propertyName) => (calls) => TemporalHelpers.toPrimitiveObserver(calls, primitiveValue, propertyName); const tests = [ diff --git a/test/built-ins/Temporal/PlainMonthDay/negative-infinity-throws-rangeerror.js b/test/built-ins/Temporal/PlainMonthDay/negative-infinity-throws-rangeerror.js index 1944f9c6668..2908e327fb2 100644 --- a/test/built-ins/Temporal/PlainMonthDay/negative-infinity-throws-rangeerror.js +++ b/test/built-ins/Temporal/PlainMonthDay/negative-infinity-throws-rangeerror.js @@ -8,11 +8,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const isoCalendar = Temporal.Calendar.from('iso8601'); - assert.throws(RangeError, () => new Temporal.PlainMonthDay(-Infinity, 1)); assert.throws(RangeError, () => new Temporal.PlainMonthDay(1, -Infinity)); -assert.throws(RangeError, () => new Temporal.PlainMonthDay(1, 1, isoCalendar, -Infinity)); +assert.throws(RangeError, () => new Temporal.PlainMonthDay(1, 1, "iso8601", -Infinity)); const O = (primitiveValue, propertyName) => (calls) => TemporalHelpers.toPrimitiveObserver(calls, primitiveValue, propertyName); const tests = [ diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/calendarId/builtin-calendar-no-observable-calls.js deleted file mode 100644 index ebbc2bce1ad..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/calendarId/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.calendarid -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); -instance.calendarId; - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/day/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/day/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 60556142b01..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/day/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.day -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "day"); -Object.defineProperty(Temporal.Calendar.prototype, "day", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("day should not be looked up"); - }, -}); - -const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); -instance.day; - -Object.defineProperty(Temporal.Calendar.prototype, "day", dayOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/day/custom.js b/test/built-ins/Temporal/PlainMonthDay/prototype/day/custom.js deleted file mode 100644 index 749c64c1bf9..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/day/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainmonthday.prototype.day -description: Custom calendar tests for day(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - day(...args) { - ++calls; - assert.compareArray(args, [instance], "day arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.PlainMonthDay(8, 25, calendar); -const result = instance.day; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/day/validate-calendar-value.js b/test/built-ins/Temporal/PlainMonthDay/prototype/day/validate-calendar-value.js deleted file mode 100644 index 0c7ba2f379c..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/day/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainmonthday.prototype.day -description: Validate result returned from calendar day() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - day() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainMonthDay(12, 15, calendar); - assert.throws(error, () => instance.day, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 1e62a18e6c0..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.equals -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainMonthDay(5, 2); -const arg = { monthCode: "M11", day: 23, calendar: "iso8601" }; -instance.equals(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-wrong-type.js index 850d9008249..6350e1b08a5 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.plainmonthday.prototype.equals description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.PlainMonthDay(5, 2); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/builtin-calendar-no-observable-calls.js deleted file mode 100644 index d39d410525f..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.equals -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); -instance.equals(new Temporal.PlainMonthDay(5, 2)); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index b40660dd0e1..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.equals -description: > - Calendar.monthDayFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainMonthDay(5, 2); -const arg = { monthCode: "M05", day: 2, calendar }; -instance.equals(arg); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1, "monthDayFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-fields-iterable.js deleted file mode 100644 index f6780885cd8..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.equals -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainmonthday.prototype.equals step 3: - 3. Set _other_ to ? ToTemporalMonthDay(_other_). - sec-temporal-totemporalmonthday step 2.f: - f. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const date = new Temporal.PlainMonthDay(5, 2, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -date.equals({ monthCode: "M06", day: 2, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-monthdayfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-monthdayfromfields-called-with-options-undefined.js deleted file mode 100644 index bb347480e54..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-monthdayfromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.equals -description: > - Calendar.monthDayFromFields method is called with undefined as the options - value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -instance.equals({ monthCode: "M05", day: 3, calendar }); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-temporal-object.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-temporal-object.js index 0bf3b816bf7..b46601c68ae 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const monthday = new Temporal.PlainMonthDay(5, 2, temporalObject); + const monthday = new Temporal.PlainMonthDay(5, 2); monthday.equals({ monthCode: "M06", day: 2, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendars.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendars.js deleted file mode 100644 index 33ea1147069..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/calendars.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.equals -description: Basic tests for equals() calendar handling -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get calendar a.id", - "get calendar b.id", -]; -const actual = []; -const calendar = (id) => { - const c = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, - }; - TemporalHelpers.observeProperty(actual, c, "id", id, `calendar ${id}`); - return c; -}; - -const mdA = new Temporal.PlainMonthDay(2, 7, calendar("a")); -const mdB = new Temporal.PlainMonthDay(2, 7, calendar("b")); -const mdC = new Temporal.PlainMonthDay(2, 7, calendar("c"), 1974); -actual.splice(0); // disregard the HasProperty checks done in the constructor - -assert.sameValue(mdA.equals(mdC), false, "different year"); -assert.compareArray(actual, [], "Should not check calendar"); - -assert.sameValue(mdA.equals(mdB), false, "different calendar"); -assert.compareArray(actual, expected, "Should check calendar"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/constructor-in-calendar-fields.js deleted file mode 100644 index 4f4058f0c57..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.equals -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainMonthDay(5, 2, calendar); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/duplicate-calendar-fields.js deleted file mode 100644 index d7d9379c9cf..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.equals -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainMonthDay(5, 2, calendar); - - assert.throws(RangeError, () => instance.equals(arg)); -} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/proto-in-calendar-fields.js deleted file mode 100644 index 0e3a9f958f4..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.equals -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainMonthDay(5, 2, calendar); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/branding.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/branding.js deleted file mode 100644 index 91492e579c7..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getcalendar -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getCalendar = Temporal.PlainMonthDay.prototype.getCalendar; - -assert.sameValue(typeof getCalendar, "function"); - -assert.throws(TypeError, () => getCalendar.call(undefined), "undefined"); -assert.throws(TypeError, () => getCalendar.call(null), "null"); -assert.throws(TypeError, () => getCalendar.call(true), "true"); -assert.throws(TypeError, () => getCalendar.call(""), "empty string"); -assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getCalendar.call(1), "1"); -assert.throws(TypeError, () => getCalendar.call({}), "plain object"); -assert.throws(TypeError, () => getCalendar.call(Temporal.PlainMonthDay), "Temporal.PlainMonthDay"); -assert.throws(TypeError, () => getCalendar.call(Temporal.PlainMonthDay.prototype), "Temporal.PlainMonthDay.prototype"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/builtin.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/builtin.js deleted file mode 100644 index 8a80d453524..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getcalendar -description: > - Tests that Temporal.PlainMonthDay.prototype.getCalendar - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainMonthDay.prototype.getCalendar), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainMonthDay.prototype.getCalendar), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainMonthDay.prototype.getCalendar), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainMonthDay.prototype.getCalendar.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/length.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/length.js deleted file mode 100644 index a79f3e8b60c..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getcalendar -description: Temporal.PlainMonthDay.prototype.getCalendar.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainMonthDay.prototype.getCalendar, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/name.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/name.js deleted file mode 100644 index f02a73ddaf3..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getcalendar -description: Temporal.PlainMonthDay.prototype.getCalendar.name is "getCalendar". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainMonthDay.prototype.getCalendar, "name", { - value: "getCalendar", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/not-a-constructor.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/not-a-constructor.js deleted file mode 100644 index 54c34ebb593..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getcalendar -description: > - Temporal.PlainMonthDay.prototype.getCalendar does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainMonthDay.prototype.getCalendar(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainMonthDay.prototype.getCalendar), false, - "isConstructor(Temporal.PlainMonthDay.prototype.getCalendar)"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/prop-desc.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/prop-desc.js deleted file mode 100644 index 70da030514b..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getCalendar/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getcalendar -description: The "getCalendar" property of Temporal.PlainMonthDay.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainMonthDay.prototype.getCalendar, - "function", - "`typeof PlainMonthDay.prototype.getCalendar` is `function`" -); - -verifyProperty(Temporal.PlainMonthDay.prototype, "getCalendar", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/branding.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/branding.js deleted file mode 100644 index 9a9805250ce..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getISOFields = Temporal.PlainMonthDay.prototype.getISOFields; - -assert.sameValue(typeof getISOFields, "function"); - -assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); -assert.throws(TypeError, () => getISOFields.call(null), "null"); -assert.throws(TypeError, () => getISOFields.call(true), "true"); -assert.throws(TypeError, () => getISOFields.call(""), "empty string"); -assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getISOFields.call(1), "1"); -assert.throws(TypeError, () => getISOFields.call({}), "plain object"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainMonthDay), "Temporal.PlainMonthDay"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainMonthDay.prototype), "Temporal.PlainMonthDay.prototype"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/builtin.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/builtin.js deleted file mode 100644 index c42bb6002c2..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: > - Tests that Temporal.PlainMonthDay.prototype.getISOFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainMonthDay.prototype.getISOFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainMonthDay.prototype.getISOFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainMonthDay.prototype.getISOFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainMonthDay.prototype.getISOFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/custom.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/custom.js deleted file mode 100644 index 391c70850e5..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/custom.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: getISOFields does not call into user code. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarThrowEverything(); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -const result = instance.getISOFields(); - -assert.sameValue(result.isoYear, 1972, "isoYear result"); -assert.sameValue(result.isoMonth, 5, "isoMonth result"); -assert.sameValue(result.isoDay, 2, "isoDay result"); -assert.sameValue(result.calendar, calendar, "calendar result"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/field-names.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/field-names.js deleted file mode 100644 index 9b99f014e64..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/field-names.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: Correct field names on the object returned from getISOFields -features: [Temporal] ----*/ - -const md = new Temporal.PlainMonthDay(5, 2); - -const result = md.getISOFields(); -assert.sameValue(result.isoYear, 1972, "isoYear result"); -assert.sameValue(result.isoMonth, 5, "isoMonth result"); -assert.sameValue(result.isoDay, 2, "isoDay result"); -assert.sameValue(result.calendar, "iso8601", "calendar result"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/field-prop-desc.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/field-prop-desc.js deleted file mode 100644 index e74b10df94b..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/field-prop-desc.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: Properties on the returned object have the correct descriptor -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoMonth", - "isoYear", -]; - -const md = new Temporal.PlainMonthDay(5, 2); -const result = md.getISOFields(); - -for (const property of expected) { - verifyProperty(result, property, { - writable: true, - enumerable: true, - configurable: true, - }); -} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/field-traversal-order.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/field-traversal-order.js deleted file mode 100644 index 9d668403fe8..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/field-traversal-order.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: Properties added in correct order to object returned from getISOFields -includes: [compareArray.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoMonth", - "isoYear", -]; - -const md = new Temporal.PlainMonthDay(5, 2); -const result = md.getISOFields(); - -assert.compareArray(Object.keys(result), expected); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/length.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/length.js deleted file mode 100644 index 2777d1aa0db..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: Temporal.PlainMonthDay.prototype.getISOFields.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainMonthDay.prototype.getISOFields, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/name.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/name.js deleted file mode 100644 index 62b63c4be04..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: Temporal.PlainMonthDay.prototype.getISOFields.name is "getISOFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainMonthDay.prototype.getISOFields, "name", { - value: "getISOFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/not-a-constructor.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/not-a-constructor.js deleted file mode 100644 index 4d422b1df38..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: > - Temporal.PlainMonthDay.prototype.getISOFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainMonthDay.prototype.getISOFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainMonthDay.prototype.getISOFields), false, - "isConstructor(Temporal.PlainMonthDay.prototype.getISOFields)"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/prop-desc.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/prop-desc.js deleted file mode 100644 index 3edb7a1429c..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: The "getISOFields" property of Temporal.PlainMonthDay.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainMonthDay.prototype.getISOFields, - "function", - "`typeof PlainMonthDay.prototype.getISOFields` is `function`" -); - -verifyProperty(Temporal.PlainMonthDay.prototype, "getISOFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/prototype.js b/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/prototype.js deleted file mode 100644 index dc43ace9a74..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/getISOFields/prototype.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.getisofields -description: Correct prototype on the object returned from getISOFields -features: [Temporal] ----*/ - -const instance = new Temporal.PlainMonthDay(5, 2); -const result = instance.getISOFields(); -assert.sameValue(Object.getPrototypeOf(result), Object.prototype, "prototype"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 2c94c80eaa6..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.monthcode -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthCode should not be looked up"); - }, -}); - -const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); -instance.monthCode; - -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/custom.js b/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/custom.js deleted file mode 100644 index 4952cca6bb1..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainmonthday.prototype.monthcode -description: Custom calendar tests for monthCode(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthCode(...args) { - ++calls; - assert.compareArray(args, [instance], "monthCode arguments"); - return "M01"; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.PlainMonthDay(8, 25, calendar); -const result = instance.monthCode; -assert.sameValue(result, "M01", "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/validate-calendar-value.js b/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/validate-calendar-value.js deleted file mode 100644 index f3d72db678a..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/validate-calendar-value.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainmonthday.prototype.monthcode -description: Validate result returned from calendar monthCode() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [Symbol("foo"), TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, TypeError], - [{toString() { return "M01"; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - monthCode() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainMonthDay(12, 15, calendar); - assert.throws(error, () => instance.monthCode, `${typeof result} ${String(result)} not converted to string`); -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 7355f1c3885..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.tojson -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); -instance.toJSON(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js deleted file mode 100644 index d5606782a70..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.protoype.tojson -description: toJSON doesn't take calendarName into account. -features: [Temporal] ----*/ - -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "05-02"], - [[{ id: "custom", ...calendarMethods }], "1972-05-02[u-ca=custom]"], - [[{ id: "iso8601", ...calendarMethods }], "05-02"], - [[{ id: "ISO8601", ...calendarMethods }], "1972-05-02[u-ca=ISO8601]"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1972-05-02[u-ca=\u0131so8601]"], // dotless i -]; -const options = { - get calendarName() { - TemporalHelpers.assertUnreachable("calendarName should not be accessed"); - return ""; - } -}; - -for (const [args, expected] of tests) { - const monthday = new Temporal.PlainMonthDay(5, 2, ...args); - const result = monthday.toJSON(options); - assert.sameValue(result, expected); -} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/year-format.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/year-format.js deleted file mode 100644 index ebe40ba1738..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toJSON/year-format.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.tojson -description: Verify that the year is appropriately formatted as 4 or 6 digits -features: [Temporal] ----*/ - -// For PlainMonthDay, the ISO reference year is only present in the string if -// the calendar is not ISO 8601 -class NotISO extends Temporal.Calendar { - constructor() { super("iso8601"); } - get id() { return "not-iso"; } -} -const calendar = new NotISO(); - -let instance = new Temporal.PlainMonthDay(12, 3, calendar, -100000); -assert.sameValue(instance.toJSON(), "-100000-12-03[u-ca=not-iso]", "large negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(4, 5, calendar, -10000); -assert.sameValue(instance.toJSON(), "-010000-04-05[u-ca=not-iso]", "smallest 5-digit negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(6, 7, calendar, -9999); -assert.sameValue(instance.toJSON(), "-009999-06-07[u-ca=not-iso]", "largest 4-digit negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(8, 9, calendar, -1000); -assert.sameValue(instance.toJSON(), "-001000-08-09[u-ca=not-iso]", "smallest 4-digit negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(10, 9, calendar, -999); -assert.sameValue(instance.toJSON(), "-000999-10-09[u-ca=not-iso]", "largest 3-digit negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(8, 7, calendar, -1); -assert.sameValue(instance.toJSON(), "-000001-08-07[u-ca=not-iso]", "year -1 formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(6, 5, calendar, 0); -assert.sameValue(instance.toJSON(), "0000-06-05[u-ca=not-iso]", "year 0 formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(4, 3, calendar, 1); -assert.sameValue(instance.toJSON(), "0001-04-03[u-ca=not-iso]", "year 1 formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(2, 10, calendar, 999); -assert.sameValue(instance.toJSON(), "0999-02-10[u-ca=not-iso]", "largest 3-digit positive year formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(1, 23, calendar, 1000); -assert.sameValue(instance.toJSON(), "1000-01-23[u-ca=not-iso]", "smallest 4-digit positive year formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(4, 5, calendar, 9999); -assert.sameValue(instance.toJSON(), "9999-04-05[u-ca=not-iso]", "largest 4-digit positive year formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(6, 7, calendar, 10000); -assert.sameValue(instance.toJSON(), "+010000-06-07[u-ca=not-iso]", "smallest 5-digit positive year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(8, 9, calendar, 100000); -assert.sameValue(instance.toJSON(), "+100000-08-09[u-ca=not-iso]", "large positive year formatted as 6-digit"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toLocaleString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 7e5758ba462..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toLocaleString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.tolocalestring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); -instance.toLocaleString(undefined, { calendar: "iso8601" }); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/argument-not-object.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/argument-not-object.js index a64f4d2fbb3..0d3105b561c 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/argument-not-object.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/argument-not-object.js @@ -3,13 +3,11 @@ /*--- esid: sec-temporal.plainmonthday.prototype.toplaindate -description: Throws a TypeError if the argument is not an Object, before any other observable actions -includes: [compareArray.js, temporalHelpers.js] +description: Throws a TypeError if the argument is not an Object features: [BigInt, Symbol, Temporal] ---*/ [null, undefined, true, 3.1416, "a string", Symbol("symbol"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarThrowEverything(); - const plainMonthDay = new Temporal.PlainMonthDay(5, 2, calendar); + const plainMonthDay = new Temporal.PlainMonthDay(5, 2); assert.throws(TypeError, () => plainMonthDay.toPlainDate(primitive)); }); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 8f758f3f346..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainMonthDay(5, 1, "iso8601"); -instance.toPlainDate({ year: 2005 }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/builtin-calendar-no-observable-calls.js deleted file mode 100644 index ced79860243..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); - }, -}); -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); -instance.toPlainDate({ year: 2002 }); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fields-iterable.js deleted file mode 100644 index 69211482090..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fields-iterable.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainmonthday.prototype.toplaindate step 4: - 4. Let _receiverFieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"monthCode"* »). - sec-temporal.plainmonthday.prototype.toplaindate step 7: - 7. Let _inputFieldNames_ be ? CalendarFields(_calendar_, « *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected1 = [ - "day", - "monthCode", -]; -const expected2 = [ - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const monthday = new Temporal.PlainMonthDay(5, 2, calendar); -monthday.toPlainDate({ year: 1997 }); - -assert.sameValue(calendar.fieldsCallCount, 2, "fields() method called twice"); -assert.compareArray(calendar.fieldsCalledWith[0], expected1, "fields() method called first time with correct args"); -assert.compareArray(calendar.fieldsCalledWith[1], expected2, "fields() method called second time with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole first iterable"); -assert(calendar.iteratorExhausted[1], "iterated through the whole second iterable"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index a5014f3f51d..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -instance.toPlainDate({ year: 2019 }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js deleted file mode 100644 index a28e2208b67..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: Calendar.dateFromFields method is called with undefined options -features: [Temporal] ----*/ - -let count = 0; - -const calendar = new class extends Temporal.Calendar { - dateFromFields(fields, options) { - count++; - assert.sameValue(options, undefined, "dateFromFields should be called with undefined options"); - return super.dateFromFields(fields, options); - } -}("iso8601"); - -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -instance.toPlainDate({ year: 2019 }); -assert.sameValue(count, 1, "dateFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-merge-fields-returns-primitive.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-merge-fields-returns-primitive.js deleted file mode 100644 index 307cb68a81e..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-merge-fields-returns-primitive.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: > - with() should throw a TypeError if mergeFields() returns a primitive, - without passing the value on to any other calendar methods -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Symbol, Temporal] ----*/ - -[undefined, null, true, 3.14159, "bad value", Symbol("no"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarMergeFieldsReturnsPrimitive(primitive); - const instance = new Temporal.PlainMonthDay(5, 2, calendar); - assert.throws(TypeError, () => instance.toPlainDate({ year: 2005 }), "bad return from mergeFields() throws"); - assert.sameValue(calendar.dateFromFieldsCallCount, 0, "dateFromFields() never called"); -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-mergefields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-mergefields-called-with-null-prototype-fields.js deleted file mode 100644 index 6561cef7f35..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-mergefields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: > - Calendar.mergeFields method is called with null-prototype fields objects -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckMergeFieldsPrototypePollution(); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -instance.toPlainDate({ year: 2019 }); -assert.sameValue(calendar.mergeFieldsCallCount, 1, "mergeFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/constructor-in-calendar-fields.js deleted file mode 100644 index eddae70a34f..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const md = new Temporal.PlainMonthDay(5, 1, calendar); - -assert.throws(RangeError, () => md.toPlainDate({year: 2023})); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/copies-merge-fields-object.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/copies-merge-fields-object.js deleted file mode 100644 index 3c0f4b69b5a..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/copies-merge-fields-object.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: The object returned from mergeFields() is copied before being passed to monthDayFromFields(). -info: | - sec-temporal.plainmonthday.prototype.toplaindate steps 9 and 11: - 9. Let _mergedFields_ be ? CalendarMergeFields(_calendar_, _fields_, _inputFields_). - 11. Set _mergedFields_ to ? PrepareTemporalFields(_mergedFields_, _mergedFieldNames_, «»). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get day", - "get day.valueOf", - "call day.valueOf", - "get monthCode", - "get monthCode.toString", - "call monthCode.toString", - "get year", - "get year.valueOf", - "call year.valueOf", -]; - -const calendar = TemporalHelpers.calendarMergeFieldsGetters(); -const monthday = new Temporal.PlainMonthDay(3, 31, calendar); -monthday.toPlainDate({ year: 2000 }); - -assert.compareArray(calendar.mergeFieldsReturnOperations, expected, "getters called on mergeFields return"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/duplicate-calendar-fields.js deleted file mode 100644 index 9f0ce3c6881..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const md = new Temporal.PlainMonthDay(5, 1, calendar); - - assert.throws(RangeError, () => md.toPlainDate({year: 2023})); -} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/proto-in-calendar-fields.js deleted file mode 100644 index 160fe30df9c..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.toplaindate -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const md = new Temporal.PlainMonthDay(5, 1, calendar); - -assert.throws(RangeError, () => md.toPlainDate({year: 2023})); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 1879aaeb162..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.tostring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); -instance.toString(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js deleted file mode 100644 index f48201eb7d0..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendar-tostring.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.protoype.tostring -description: Number of observable 'toString' calls on the calendar for each value of calendarName -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls; -const customCalendar = { - get id() { - ++calls; - return "custom"; - }, - toString() { - TemporalHelpers.assertUnreachable('toString should not be called'); - }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const monthday = new Temporal.PlainMonthDay(5, 2, customCalendar); -[ - ["always", "1972-05-02[u-ca=custom]", 1], - ["auto", "1972-05-02[u-ca=custom]", 1], - ["critical", "1972-05-02[!u-ca=custom]", 1], - ["never", "1972-05-02", 1], - [undefined, "1972-05-02[u-ca=custom]", 1], -].forEach(([calendarName, expectedResult, expectedCalls]) => { - calls = 0; - const result = monthday.toString({ calendarName }); - assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js index c5a3fe2d169..e3e8affe440 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js @@ -7,39 +7,6 @@ description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1972-05-02[u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1972-05-02[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1972-05-02[u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1972-05-02[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1972-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const monthday = new Temporal.PlainMonthDay(5, 2, ...args); - const result = monthday.toString({ calendarName: "always" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = always`); -} +const monthday = new Temporal.PlainMonthDay(5, 2); +const result = monthday.toString({ calendarName: "always" }); +assert.sameValue(result, "1972-05-02[u-ca=iso8601]", `built-in ISO calendar for calendarName = always`); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js index 7ab7659c840..7d9266b3d56 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js @@ -7,39 +7,6 @@ description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "05-02", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1972-05-02[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "05-02", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1972-05-02[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1972-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const monthday = new Temporal.PlainMonthDay(5, 2, ...args); - const result = monthday.toString({ calendarName: "auto" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); -} +const monthday = new Temporal.PlainMonthDay(5, 2); +const result = monthday.toString({ calendarName: "auto" }); +assert.sameValue(result, "05-02", `built-in ISO calendar for calendarName = auto`); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js index 60d26a57d01..a446d581b50 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js @@ -9,39 +9,6 @@ description: > features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1972-05-02[!u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1972-05-02[!u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1972-05-02[!u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1972-05-02[!u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1972-05-02[!u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const monthday = new Temporal.PlainMonthDay(5, 2, ...args); - const result = monthday.toString({ calendarName: "critical" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); -} +const monthday = new Temporal.PlainMonthDay(5, 2); +const result = monthday.toString({ calendarName: "critical" }); +assert.sameValue(result, "1972-05-02[!u-ca=iso8601]", `built-in ISO calendar for calendarName = critical`); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js index 50e04595763..09eb10f1693 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js @@ -7,39 +7,6 @@ description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "05-02", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1972-05-02", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "05-02", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1972-05-02", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1972-05-02", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const monthday = new Temporal.PlainMonthDay(5, 2, ...args); - const result = monthday.toString({ calendarName: "never" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = never`); -} +const monthday = new Temporal.PlainMonthDay(5, 2); +const result = monthday.toString({ calendarName: "never" }); +assert.sameValue(result, "05-02", `built-in ISO calendar for calendarName = never`); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js index 67c1d3a628d..7d963de36b7 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js @@ -14,40 +14,7 @@ info: | features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "05-02", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1972-05-02[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "05-02", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1972-05-02[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1972-05-02[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const monthday = new Temporal.PlainMonthDay(5, 2, ...args); - const result = monthday.toString({ calendarName: undefined }); - assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); - // See options-object.js for {} and options-undefined.js for absent options arg -} +const monthday = new Temporal.PlainMonthDay(5, 2); +const result = monthday.toString({ calendarName: undefined }); +assert.sameValue(result, "05-02", `default calendarName option is auto with built-in ISO calendar`); +// See options-object.js for {} and options-undefined.js for absent options arg diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js index efbc3a61386..03f8f6b2fb8 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js @@ -15,32 +15,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const calendar = { - id: "custom", - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const monthday = new Temporal.PlainMonthDay(5, 2, calendar); +const monthday = new Temporal.PlainMonthDay(5, 2, "iso8601"); TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", (calendarName) => monthday.toString({ calendarName }), - (result, descr) => assert.sameValue(result, "1972-05-02[u-ca=custom]", descr), + (result, descr) => assert.sameValue(result, "05-02", descr), ); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-undefined.js deleted file mode 100644 index 73b5c8361b1..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/options-undefined.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.tostring -description: Verify that undefined options are handled correctly. -features: [Temporal] ----*/ - -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "05-02"], - [[{ id: "custom", ...calendarMethods }], "1972-05-02[u-ca=custom]"], - [[{ id: "iso8601", ...calendarMethods }], "05-02"], - [[{ id: "ISO8601", ...calendarMethods }], "1972-05-02[u-ca=ISO8601]"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1972-05-02[u-ca=\u0131so8601]"], // dotless i -]; - -for (const [args, expected] of tests) { - const monthday = new Temporal.PlainMonthDay(5, 2, ...args); - const explicit = monthday.toString(undefined); - assert.sameValue(explicit, expected, "default calendarName option is auto"); - - const implicit = monthday.toString(); - assert.sameValue(implicit, expected, "default calendarName option is auto"); -} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js index 6bd221d57d8..cb6957378b7 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/order-of-operations.js @@ -12,14 +12,10 @@ const expected = [ "get options.calendarName", "get options.calendarName.toString", "call options.calendarName.toString", - "get this.calendar.id", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601"); const options = TemporalHelpers.propertyBagObserver(actual, { calendarName: "auto", diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/year-format.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toString/year-format.js deleted file mode 100644 index da4aaeb7cb3..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/toString/year-format.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.tostring -description: Verify that the year is appropriately formatted as 4 or 6 digits -features: [Temporal] ----*/ - -// For PlainMonthDay, the ISO reference year is only present in the string if -// the calendar is not ISO 8601 -class NotISO extends Temporal.Calendar { - constructor() { super("iso8601"); } - get id() { return "not-iso"; } -} -const calendar = new NotISO(); - -let instance = new Temporal.PlainMonthDay(12, 3, calendar, -100000); -assert.sameValue(instance.toString(), "-100000-12-03[u-ca=not-iso]", "large negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(4, 5, calendar, -10000); -assert.sameValue(instance.toString(), "-010000-04-05[u-ca=not-iso]", "smallest 5-digit negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(6, 7, calendar, -9999); -assert.sameValue(instance.toString(), "-009999-06-07[u-ca=not-iso]", "largest 4-digit negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(8, 9, calendar, -1000); -assert.sameValue(instance.toString(), "-001000-08-09[u-ca=not-iso]", "smallest 4-digit negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(10, 9, calendar, -999); -assert.sameValue(instance.toString(), "-000999-10-09[u-ca=not-iso]", "largest 3-digit negative year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(8, 7, calendar, -1); -assert.sameValue(instance.toString(), "-000001-08-07[u-ca=not-iso]", "year -1 formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(6, 5, calendar, 0); -assert.sameValue(instance.toString(), "0000-06-05[u-ca=not-iso]", "year 0 formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(4, 3, calendar, 1); -assert.sameValue(instance.toString(), "0001-04-03[u-ca=not-iso]", "year 1 formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(2, 10, calendar, 999); -assert.sameValue(instance.toString(), "0999-02-10[u-ca=not-iso]", "largest 3-digit positive year formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(1, 23, calendar, 1000); -assert.sameValue(instance.toString(), "1000-01-23[u-ca=not-iso]", "smallest 4-digit positive year formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(4, 5, calendar, 9999); -assert.sameValue(instance.toString(), "9999-04-05[u-ca=not-iso]", "largest 4-digit positive year formatted as 4-digit"); - -instance = new Temporal.PlainMonthDay(6, 7, calendar, 10000); -assert.sameValue(instance.toString(), "+010000-06-07[u-ca=not-iso]", "smallest 5-digit positive year formatted as 6-digit"); - -instance = new Temporal.PlainMonthDay(8, 9, calendar, 100000); -assert.sameValue(instance.toString(), "+100000-08-09[u-ca=not-iso]", "large positive year formatted as 6-digit"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 3745d15d859..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainMonthDay(5, 1, "iso8601"); -instance.with({ monthCode: "M04" }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 8fa4dfe27d9..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); - }, -}); -const monthDayFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthDayFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthDayFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainMonthDay(5, 2, "iso8601", 1972); -instance.with({ monthCode: "M06" }); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "monthDayFromFields", monthDayFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js deleted file mode 100644 index 0878abeb1cb..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-arguments.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: Correct options value is passed to calendar method -info: | - MonthDayFromFields ( calendar, fields [ , options ] ) - - 5. Let monthDay be ? Invoke(calendar, "monthDayFromFields", « fields, options »). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const options = { - extra: "property", -}; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthDayFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.notSameValue(args[1], options, "args[1] is a copy of options"); - assert.sameValue(args[1].extra, "property", "All properties are copied"); - assert.sameValue(Object.getPrototypeOf(args[1]), null, "Copy has null prototype"); - return super.monthDayFromFields(...args); - } -} -const plainMonthDay = new Temporal.PlainMonthDay(7, 2, new CustomCalendar()); -const result = plainMonthDay.with({ monthCode: "M05" }, options); -TemporalHelpers.assertPlainMonthDay(result, "M05", 2); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-iterable.js deleted file mode 100644 index cd4a94896fb..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-iterable.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainmonthday.prototype.with step 9: - 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const monthday = new Temporal.PlainMonthDay(5, 2, calendar); -monthday.with({ day: 6 }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index a69678363c7..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: > - Calendar.monthDayFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -instance.with({ day: 24 }); -assert.sameValue(calendar.monthDayFromFieldsCallCount, 1, "monthDayFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-merge-fields-returns-primitive.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-merge-fields-returns-primitive.js deleted file mode 100644 index 5cf1657accf..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-merge-fields-returns-primitive.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: > - with() should throw a TypeError if mergeFields() returns a primitive, - without passing the value on to any other calendar methods -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Symbol, Temporal] ----*/ - -[undefined, null, true, 3.14159, "bad value", Symbol("no"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarMergeFieldsReturnsPrimitive(primitive); - const instance = new Temporal.PlainMonthDay(5, 2, calendar); - assert.throws(TypeError, () => instance.with({ year: 2005 }), "bad return from mergeFields() throws"); - assert.sameValue(calendar.monthDayFromFieldsCallCount, 0, "monthDayFromFields() never called"); -}); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js deleted file mode 100644 index 0f2985bab66..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: > - Calendar.mergeFields method is called with null-prototype fields objects -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckMergeFieldsPrototypePollution(); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -instance.with({ day: 24 }); -assert.sameValue(calendar.mergeFieldsCallCount, 1, "mergeFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js deleted file mode 100644 index ba57169d68d..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const md = new Temporal.PlainMonthDay(5, 1, calendar); - -assert.throws(RangeError, () => md.with({day: 15})); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/copies-merge-fields-object.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/copies-merge-fields-object.js deleted file mode 100644 index ee7d3e41228..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/copies-merge-fields-object.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: The object returned from mergeFields() is copied before being passed to monthDayFromFields(). -info: | - sec-temporal.plainmonthday.prototype.with steps 13–15: - 13. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialMonthDay_). - 14. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, «»). - 15. Return ? MonthDayFromFields(_calendar_, _fields_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get day", - "get day.valueOf", - "call day.valueOf", - "get month", // PlainMonthDay.month property does not exist, no valueOf - "get monthCode", - "get monthCode.toString", - "call monthCode.toString", - "get year", // undefined, no valueOf -]; - -const calendar = TemporalHelpers.calendarMergeFieldsGetters(); -const monthday = new Temporal.PlainMonthDay(3, 31, calendar); -monthday.with({ day: 1 }); - -assert.compareArray(calendar.mergeFieldsReturnOperations, expected, "getters called on mergeFields return"); diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js deleted file mode 100644 index a3cc5a097dc..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['month'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const md = new Temporal.PlainMonthDay(5, 1, calendar); - - assert.throws(RangeError, () => md.with({day: 15})); -} diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js index 1fa2996016c..d133168362f 100644 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/order-of-operations.js @@ -12,23 +12,10 @@ const expected = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", + // GetTemporalOverflowOption "get options.overflow", - "getOwnPropertyDescriptor options.extra", - "get options.extra", - // lookup - "get this.calendar.fields", - "get this.calendar.mergeFields", - "get this.calendar.monthDayFromFields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields on receiver - "get this.calendar.day", - "call this.calendar.day", - "get this.calendar.monthCode", - "call this.calendar.monthCode", + "get options.overflow.toString", + "call options.overflow.toString", // PrepareTemporalFields on argument "get fields.day", "get fields.day.valueOf", @@ -42,20 +29,10 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", - // CalendarMergeFields - "call this.calendar.mergeFields", - // CalendarMonthDayFromFields - "call this.calendar.monthDayFromFields", - // inside Calendar.p.monthDayFromFields - "get options.overflow.toString", - "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainMonthDay(5, 2, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainMonthDay(5, 2, "iso8601"); const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7, diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js deleted file mode 100644 index 41d557ae566..00000000000 --- a/test/built-ins/Temporal/PlainMonthDay/prototype/with/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainmonthday.prototype.with -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const md = new Temporal.PlainMonthDay(5, 1, calendar); - -assert.throws(RangeError, () => md.with({day: 15})); diff --git a/test/built-ins/Temporal/PlainMonthDay/refisoyear-out-of-range.js b/test/built-ins/Temporal/PlainMonthDay/refisoyear-out-of-range.js index 63e7e9d4e01..4a6e63c73b1 100644 --- a/test/built-ins/Temporal/PlainMonthDay/refisoyear-out-of-range.js +++ b/test/built-ins/Temporal/PlainMonthDay/refisoyear-out-of-range.js @@ -7,7 +7,5 @@ description: referenceISOYear argument, if given, can cause RangeError features: [Temporal] ---*/ -const calendar = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => new Temporal.PlainMonthDay(9, 14, calendar, 275760), "after the maximum ISO date"); -assert.throws(RangeError, () => new Temporal.PlainMonthDay(4, 18, calendar, -271821), "before the minimum ISO date") +assert.throws(RangeError, () => new Temporal.PlainMonthDay(9, 14, "iso8601", 275760), "after the maximum ISO date"); +assert.throws(RangeError, () => new Temporal.PlainMonthDay(4, 18, "iso8601", -271821), "before the minimum ISO date") diff --git a/test/built-ins/Temporal/PlainMonthDay/refisoyear-undefined.js b/test/built-ins/Temporal/PlainMonthDay/refisoyear-undefined.js index f9671ba848b..d819b57df96 100644 --- a/test/built-ins/Temporal/PlainMonthDay/refisoyear-undefined.js +++ b/test/built-ins/Temporal/PlainMonthDay/refisoyear-undefined.js @@ -7,11 +7,12 @@ description: referenceISOYear argument defaults to 1972 if not given features: [Temporal] ---*/ -const calendar = new Temporal.Calendar("iso8601"); -const args = [5, 2, calendar]; +const args = [5, 2, "iso8601"]; const dateExplicit = new Temporal.PlainMonthDay(...args, undefined); -assert.sameValue(dateExplicit.getISOFields().isoYear, 1972, "default referenceISOYear is 1972"); +const isoYearExplicit = Number(dateExplicit.toString({ calendarName: "always" }).slice(0, 4)); +assert.sameValue(isoYearExplicit, 1972, "default referenceISOYear is 1972"); const dateImplicit = new Temporal.PlainMonthDay(...args); -assert.sameValue(dateImplicit.getISOFields().isoYear, 1972, "default referenceISOYear is 1972"); +const isoYearImplicit = Number(dateImplicit.toString({ calendarName: "always" }).slice(0, 4)); +assert.sameValue(isoYearImplicit, 1972, "default referenceISOYear is 1972"); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 72c5b1d431f..00000000000 --- a/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.compare -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, Infinity, -Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => Temporal.PlainTime.compare(datetime, time)); - assert.throws(RangeError, () => Temporal.PlainTime.compare(time, datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 50a9411a0ed..00000000000 --- a/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.compare -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.PlainTime.compare(datetime, time), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); - assert.throws( - TypeError, - () => Temporal.PlainTime.compare(time, datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 61ef5976d15..00000000000 --- a/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.compare -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - - assert.throws(RangeError, () => Temporal.PlainTime.compare(datetime, time)); - assert.throws(RangeError, () => Temporal.PlainTime.compare(time, datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index eafc91fe901..00000000000 --- a/test/built-ins/Temporal/PlainTime/compare/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.compare -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - - assert.throws(TypeError, () => Temporal.PlainTime.compare(datetime, time)); - assert.throws(TypeError, () => Temporal.PlainTime.compare(time, datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/compare/exhaustive.js b/test/built-ins/Temporal/PlainTime/compare/exhaustive.js index 05d36881215..1112f1c4889 100644 --- a/test/built-ins/Temporal/PlainTime/compare/exhaustive.js +++ b/test/built-ins/Temporal/PlainTime/compare/exhaustive.js @@ -7,109 +7,106 @@ description: Tests for compare() with each possible outcome features: [Temporal] ---*/ -const cal1 = "iso8601"; -const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601"); - assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(12, 15, 45, 333, 777, 111, cal1), - new Temporal.PlainTime(6, 15, 45, 333, 777, 111, cal2) + new Temporal.PlainTime(12, 15, 45, 333, 777, 111), + new Temporal.PlainTime(6, 15, 45, 333, 777, 111) ), 1, "hour >" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(6, 30, 15, 222, 444, 6, cal1), - new Temporal.PlainTime(22, 30, 15, 222, 444, 6, cal2) + new Temporal.PlainTime(6, 30, 15, 222, 444, 6), + new Temporal.PlainTime(22, 30, 15, 222, 444, 6) ), -1, "hour <" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(12, 45, 15, 333, 777, 111, cal1), - new Temporal.PlainTime(12, 15, 22, 333, 777, 111, cal2) + new Temporal.PlainTime(12, 45, 15, 333, 777, 111), + new Temporal.PlainTime(12, 15, 22, 333, 777, 111) ), 1, "minute >" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(6, 30, 15, 222, 444, 6, cal1), - new Temporal.PlainTime(6, 57, 15, 222, 444, 6, cal2) + new Temporal.PlainTime(6, 30, 15, 222, 444, 6), + new Temporal.PlainTime(6, 57, 15, 222, 444, 6) ), -1, "minute <" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(12, 15, 6, 333, 777, 111, cal1), - new Temporal.PlainTime(12, 15, 5, 333, 777, 111, cal2) + new Temporal.PlainTime(12, 15, 6, 333, 777, 111), + new Temporal.PlainTime(12, 15, 5, 333, 777, 111) ), 1, "second >" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(6, 30, 3, 222, 444, 6, cal1), - new Temporal.PlainTime(6, 30, 4, 222, 444, 6, cal2) + new Temporal.PlainTime(6, 30, 3, 222, 444, 6), + new Temporal.PlainTime(6, 30, 4, 222, 444, 6) ), -1, "second <" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(12, 15, 45, 6, 777, 111, cal1), - new Temporal.PlainTime(12, 15, 45, 5, 777, 111, cal2) + new Temporal.PlainTime(12, 15, 45, 6, 777, 111), + new Temporal.PlainTime(12, 15, 45, 5, 777, 111) ), 1, "millisecond >" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(6, 30, 15, 3, 444, 6, cal1), - new Temporal.PlainTime(6, 30, 15, 4, 444, 6, cal2) + new Temporal.PlainTime(6, 30, 15, 3, 444, 6), + new Temporal.PlainTime(6, 30, 15, 4, 444, 6) ), -1, "millisecond <" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(12, 15, 45, 333, 6, 111, cal1), - new Temporal.PlainTime(12, 15, 45, 333, 5, 111, cal2) + new Temporal.PlainTime(12, 15, 45, 333, 6, 111), + new Temporal.PlainTime(12, 15, 45, 333, 5, 111) ), 1, "microsecond >" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(6, 30, 15, 222, 3, 6, cal1), - new Temporal.PlainTime(6, 30, 15, 222, 4, 6, cal2) + new Temporal.PlainTime(6, 30, 15, 222, 3, 6), + new Temporal.PlainTime(6, 30, 15, 222, 4, 6) ), -1, "microsecond <" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(12, 15, 45, 333, 777, 999, cal1), - new Temporal.PlainTime(12, 15, 45, 333, 777, 111, cal2) + new Temporal.PlainTime(12, 15, 45, 333, 777, 999), + new Temporal.PlainTime(12, 15, 45, 333, 777, 111) ), 1, "nanosecond >" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(6, 30, 15, 222, 444, 0, cal1), - new Temporal.PlainTime(6, 30, 15, 222, 444, 6, cal2) + new Temporal.PlainTime(6, 30, 15, 222, 444, 0), + new Temporal.PlainTime(6, 30, 15, 222, 444, 6) ), -1, "nanosecond <" ); assert.sameValue( Temporal.PlainTime.compare( - new Temporal.PlainTime(12, 15, 45, 333, 777, 111, cal1), - new Temporal.PlainTime(12, 15, 45, 333, 777, 111, cal2) + new Temporal.PlainTime(12, 15, 45, 333, 777, 111), + new Temporal.PlainTime(12, 15, 45, 333, 777, 111) ), 0, "=" diff --git a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-balance-negative-time-units.js index a57ecf3740b..30ea672ab5c 100644 --- a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-balance-negative-time-units.js @@ -35,9 +35,8 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); const time = Temporal.PlainTime.from(datetime); -TemporalHelpers.assertPlainTime(time, 1, 1, 1, 1, 0, 999); +TemporalHelpers.assertPlainTime(time, 0, 59, 1, 1, 1, 1); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index db1149cc4cd..00000000000 --- a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.from -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => Temporal.PlainTime.from(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 49f9e6ef158..00000000000 --- a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plaintime.from -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.PlainTime.from(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index f9212b45f35..00000000000 --- a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.from -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => Temporal.PlainTime.from(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index ff20e6fefed..00000000000 --- a/test/built-ins/Temporal/PlainTime/from/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.from -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => Temporal.PlainTime.from(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js index af190427a88..f65e91c3288 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-balance-negative-time-units.js @@ -28,14 +28,12 @@ info: | ii. 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.plaintime.prototype.equals step 3: 3. Set _other_ to ? ToTemporalTime(_other_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); -assert(new Temporal.PlainTime(1, 1, 1, 1, 0, 999).equals(datetime)); +assert(new Temporal.PlainTime(0, 59, 1, 1, 1, 1).equals(datetime)); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index a903404fcd3..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.equals -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.equals(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 19415c0d152..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.equals -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => time.equals(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index ea8c4690241..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.equals -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.equals(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index be2ce0f1adc..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/equals/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.equals -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => time.equals(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/branding.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/branding.js deleted file mode 100644 index 523925b7b88..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getISOFields = Temporal.PlainTime.prototype.getISOFields; - -assert.sameValue(typeof getISOFields, "function"); - -assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); -assert.throws(TypeError, () => getISOFields.call(null), "null"); -assert.throws(TypeError, () => getISOFields.call(true), "true"); -assert.throws(TypeError, () => getISOFields.call(""), "empty string"); -assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getISOFields.call(1), "1"); -assert.throws(TypeError, () => getISOFields.call({}), "plain object"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainTime), "Temporal.PlainTime"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainTime.prototype), "Temporal.PlainTime.prototype"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/builtin.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/builtin.js deleted file mode 100644 index 352d8b55c0f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: > - Tests that Temporal.PlainTime.prototype.getISOFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainTime.prototype.getISOFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainTime.prototype.getISOFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainTime.prototype.getISOFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainTime.prototype.getISOFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/field-names.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/field-names.js deleted file mode 100644 index 4ea80a535fa..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/field-names.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: Correct field names on the object returned from getISOFields -features: [Temporal] ----*/ - -const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - -const result = time.getISOFields(); -assert.sameValue(result.isoHour, 12, "isoHour result"); -assert.sameValue(result.isoMinute, 34, "isoMinute result"); -assert.sameValue(result.isoSecond, 56, "isoSecond result"); -assert.sameValue(result.isoMillisecond, 987, "isoMillisecond result"); -assert.sameValue(result.isoMicrosecond, 654, "isoMicrosecond result"); -assert.sameValue(result.isoNanosecond, 321, "isoNanosecond result"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/field-prop-desc.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/field-prop-desc.js deleted file mode 100644 index 4b81951bf45..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/field-prop-desc.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: Properties on the returned object have the correct descriptor -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -const expected = [ - "isoHour", - "isoMicrosecond", - "isoMillisecond", - "isoMinute", - "isoNanosecond", - "isoSecond", -]; - -const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); -const result = time.getISOFields(); - -for (const property of expected) { - verifyProperty(result, property, { - writable: true, - enumerable: true, - configurable: true, - }); -} diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/field-traversal-order.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/field-traversal-order.js deleted file mode 100644 index 55afd2c4d85..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/field-traversal-order.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: Properties added in correct order to object returned from getISOFields -includes: [compareArray.js] -features: [Temporal] ----*/ - -const expected = [ - "isoHour", - "isoMicrosecond", - "isoMillisecond", - "isoMinute", - "isoNanosecond", - "isoSecond", -]; - -const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); -const result = time.getISOFields(); - -assert.compareArray(Object.keys(result), expected); diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/length.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/length.js deleted file mode 100644 index 8e71933c384..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: Temporal.PlainTime.prototype.getISOFields.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainTime.prototype.getISOFields, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/name.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/name.js deleted file mode 100644 index 9ad9e6438b5..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: Temporal.PlainTime.prototype.getISOFields.name is "getISOFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainTime.prototype.getISOFields, "name", { - value: "getISOFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/not-a-constructor.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/not-a-constructor.js deleted file mode 100644 index 1160d5f9e1f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: > - Temporal.PlainTime.prototype.getISOFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainTime.prototype.getISOFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainTime.prototype.getISOFields), false, - "isConstructor(Temporal.PlainTime.prototype.getISOFields)"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/prop-desc.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/prop-desc.js deleted file mode 100644 index 534c3d01721..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: The "getISOFields" property of Temporal.PlainTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainTime.prototype.getISOFields, - "function", - "`typeof PlainTime.prototype.getISOFields` is `function`" -); - -verifyProperty(Temporal.PlainTime.prototype, "getISOFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/prototype.js b/test/built-ins/Temporal/PlainTime/prototype/getISOFields/prototype.js deleted file mode 100644 index db4982a550d..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/getISOFields/prototype.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.getisofields -description: Correct prototype on the object returned from getISOFields -features: [Temporal] ----*/ - -const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); -const result = instance.getISOFields(); -assert.sameValue(Object.getPrototypeOf(result), Object.prototype, "prototype"); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js index af08e3d8fc4..de5e9539113 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-balance-negative-time-units.js @@ -35,9 +35,8 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); const diff = new Temporal.PlainTime().since(datetime); -TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, -1, -1, -1, -1, 0, -999); +TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 0, -59, -1, -1, -1, -1); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index c8230cbea46..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.since -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.since(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index fc92def025d..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.since -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => time.since(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 17ac3ab0db2..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.since -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.since(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 0f0a0686870..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/since/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.since -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => time.since(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js index c2cf9614bf3..a84c7670d59 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainTime/prototype/since/order-of-operations.js @@ -28,25 +28,17 @@ const expected = [ "get other.second", "get other.second.valueOf", "call other.second.valueOf", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; @@ -62,7 +54,7 @@ const other = TemporalHelpers.propertyBagObserver(actual, { microsecond: 1.7, nanosecond: 1.7, calendar: "iso8601", -}, "other"); +}, "other", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { roundingIncrement: 1, @@ -76,17 +68,3 @@ const result = instance.since(other, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -// short-circuit does not skip reading options -const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - hour: 12, - minute: 34, - second: 56, - millisecond: 987, - microsecond: 654, - nanosecond: 321, -}, "other"); -instance.since(identicalPropertyBag, options); -assert.compareArray(actual, expected, "order of operations with identical times"); - -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js index e6c212cb414..ca48ba74564 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-balance-negative-time-units.js @@ -35,9 +35,8 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); const diff = new Temporal.PlainTime().until(datetime); -TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 1, 1, 1, 1, 0, 999); +TemporalHelpers.assertDuration(diff, 0, 0, 0, 0, 0, 59, 1, 1, 1, 1); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 4c579f32554..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.until -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.until(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 047e1b48b1f..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.until -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => time.until(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 36ad9c9fb24..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.until -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => time.until(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 5fb897fa7ea..00000000000 --- a/test/built-ins/Temporal/PlainTime/prototype/until/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaintime.prototype.until -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => time.until(datetime)); -}); diff --git a/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js index 3c62047a1e0..31de91d60b7 100644 --- a/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainTime/prototype/until/order-of-operations.js @@ -28,25 +28,17 @@ const expected = [ "get other.second", "get other.second.valueOf", "call other.second.valueOf", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; @@ -62,7 +54,7 @@ const other = TemporalHelpers.propertyBagObserver(actual, { microsecond: 1.7, nanosecond: 1.7, calendar: "iso8601", -}, "other"); +}, "other", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { roundingIncrement: 1, diff --git a/test/built-ins/Temporal/PlainYearMonth/calendar-iso-string.js b/test/built-ins/Temporal/PlainYearMonth/calendar-iso-string.js new file mode 100644 index 00000000000..5373947175a --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/calendar-iso-string.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.constructor +description: An ISO string is not valid input for a constructor's calendar param +features: [Temporal] +---*/ + +assert.throws( + RangeError, + () => new Temporal.PlainYearMonth(2000, 5, "1997-12-04[u-ca=iso8601]", 1), + "An ISO string is not a valid calendar ID for constructor parameter" +); diff --git a/test/built-ins/Temporal/PlainYearMonth/calendar-string.js b/test/built-ins/Temporal/PlainYearMonth/calendar-string.js index d9f558955c0..31f26cea53e 100644 --- a/test/built-ins/Temporal/PlainYearMonth/calendar-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/calendar-string.js @@ -10,4 +10,4 @@ features: [Temporal] const arg = "iso8601"; const result = new Temporal.PlainYearMonth(2000, 5, arg, 1); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/PlainYearMonth/calendar-temporal-object.js b/test/built-ins/Temporal/PlainYearMonth/calendar-temporal-object.js deleted file mode 100644 index e9fb1c9c0ab..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/calendar-temporal-object.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const result = new Temporal.PlainYearMonth(2000, 5, arg, 1); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/calendar-undefined.js b/test/built-ins/Temporal/PlainYearMonth/calendar-undefined.js index d08947cec88..24c5832acfa 100644 --- a/test/built-ins/Temporal/PlainYearMonth/calendar-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/calendar-undefined.js @@ -9,12 +9,6 @@ features: [Temporal] const args = [2000, 5]; -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); - const dateExplicit = new Temporal.PlainYearMonth(...args, undefined); assert.sameValue(dateExplicit.calendarId, "iso8601"); diff --git a/test/built-ins/Temporal/PlainYearMonth/calendar-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/calendar-wrong-type.js index efe81bbdf66..c5205e5508b 100644 --- a/test/built-ins/Temporal/PlainYearMonth/calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plainyearmonth description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar + for Calendar features: [BigInt, Symbol, Temporal] ---*/ @@ -27,9 +27,8 @@ for (const [arg, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [arg, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 453c8e0d35b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/compare/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.compare -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const arg = { year: 2000, month: 5, calendar: "iso8601" }; -Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6)); -Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-string.js index cabd3995482..c6c04f6c6e1 100644 --- a/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-string.js @@ -4,19 +4,9 @@ /*--- esid: sec-temporal.plainyearmonth.compare description: A calendar ID is valid input for Calendar -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - const calendar = "iso8601"; const arg = { year: 2019, monthCode: "M06", calendar }; @@ -26,5 +16,3 @@ assert.sameValue(result1, 0, `Calendar created from string "${arg}" (first argum const result2 = Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg); assert.sameValue(result2, 0, `Calendar created from string "${arg}" (second argument)`); - -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-wrong-type.js index 73ecf05f88f..ad971ae72bc 100644 --- a/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-propertybag-calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plainyearmonth.compare description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ @@ -33,10 +33,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/compare/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 7ec6a02a7d0..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/compare/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.compare -description: > - Calendar.yearMonthFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const arg1 = { year: 2000, month: 5, calendar }; -const arg2 = new Temporal.PlainYearMonth(2019, 6); - -Temporal.PlainYearMonth.compare(arg1, arg2); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should be called on the property bag's calendar (first argument)"); - -calendar.yearMonthFromFieldsCallCount = 0; - -Temporal.PlainYearMonth.compare(arg2, arg1); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should be called on the property bag's calendar (second argument)"); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainYearMonth/compare/calendar-fields-iterable.js deleted file mode 100644 index d4776d70691..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/compare/calendar-fields-iterable.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.compare -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainyearmonth.compare steps 1–2: - 1. Set _one_ to ? ToTemporalYearMonth(_one_). - 2. Set _two_ to ? ToTemporalYearMonth(_two_). - sec-temporal-totemporalyearmonth step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -Temporal.PlainYearMonth.compare( - { year: 2000, month: 5, calendar: calendar1 }, - { year: 2001, month: 6, calendar: calendar2 }, -); - -assert.sameValue(calendar1.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar1.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar1.iteratorExhausted[0], "iterated through the whole iterable"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/compare/calendar-yearmonthfromfields-called-with-options-undefined.js deleted file mode 100644 index 6696ad2a868..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/compare/calendar-yearmonthfromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.compare -description: > - Calendar.yearMonthFromFields method is called with undefined as the options - value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -Temporal.PlainYearMonth.compare({ year: 2000, month: 5, calendar }, { year: 2000, month: 6, calendar }); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 2); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/compare-calendar.js b/test/built-ins/Temporal/PlainYearMonth/compare/compare-calendar.js deleted file mode 100644 index a3b91851184..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/compare/compare-calendar.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.compare -description: compare() does not take the calendar into account -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor(id) { - super("iso8601"); - this._id = id; - } - toString() { - return this._id; - } -} - -const ym1 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("a"), 1); -const ym2 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("b"), 1); -assert.sameValue(Temporal.PlainYearMonth.compare(ym1, ym2), 0); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/compare-reference-day.js b/test/built-ins/Temporal/PlainYearMonth/compare/compare-reference-day.js index 29a9c486611..d7e41068acd 100644 --- a/test/built-ins/Temporal/PlainYearMonth/compare/compare-reference-day.js +++ b/test/built-ins/Temporal/PlainYearMonth/compare/compare-reference-day.js @@ -7,7 +7,6 @@ description: compare() takes the reference day into account features: [Temporal] ---*/ -const iso = Temporal.Calendar.from("iso8601"); -const ym1 = new Temporal.PlainYearMonth(2000, 1, iso, 1); -const ym2 = new Temporal.PlainYearMonth(2000, 1, iso, 2); +const ym1 = new Temporal.PlainYearMonth(2000, 1, "iso8601", 1); +const ym2 = new Temporal.PlainYearMonth(2000, 1, "iso8601", 2); assert.sameValue(Temporal.PlainYearMonth.compare(ym1, ym2), -1); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/compare/constructor-in-calendar-fields.js deleted file mode 100644 index 12a8f3eddbb..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/compare/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.compare -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6))); -assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/compare/duplicate-calendar-fields.js deleted file mode 100644 index 9227ce04aaf..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/compare/duplicate-calendar-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.compare -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - - -for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - - assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6))); - assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg)); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/exhaustive.js b/test/built-ins/Temporal/PlainYearMonth/compare/exhaustive.js deleted file mode 100644 index 99ad5ca2001..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/compare/exhaustive.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.compare -description: Tests for compare() with each possible outcome -features: [Temporal] ----*/ - -const cal1 = "iso8601"; -const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601"); - -assert.sameValue( - Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(1987, 5, cal2)), - 1, - "year >" -); -assert.sameValue( - Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 12, cal1), new Temporal.PlainYearMonth(2048, 12, cal2)), - -1, - "year <" -); -assert.sameValue( - Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(2000, 3, cal2)), - 1, - "month >" -); -assert.sameValue( - Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 4, cal1), new Temporal.PlainYearMonth(1981, 12, cal2)), - -1, - "month <" -); -assert.sameValue( - Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1, 30), new Temporal.PlainYearMonth(2000, 5, cal2, 14)), - 1, - "reference day >" -); -assert.sameValue( - Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 4, cal1, 1), new Temporal.PlainYearMonth(1981, 4, cal2, 12)), - -1, - "reference day <" -); -assert.sameValue( - Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(2000, 5, cal2)), - 0, - "=" -); diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/compare/proto-in-calendar-fields.js deleted file mode 100644 index 5291744de9d..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/compare/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.compare -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(arg, new Temporal.PlainYearMonth(2019, 6))); -assert.throws(RangeError, () => Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2019, 6), arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index c2a2cbfcbbe..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/from/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 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: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const arg = { year: 2000, month: 5, calendar: "iso8601" }; -Temporal.PlainYearMonth.from(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-plaindate.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-plaindate.js index 9923c808ebc..e9784ce21ba 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/argument-plaindate.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-plaindate.js @@ -11,8 +11,5 @@ features: [Temporal] const plainDate = Temporal.PlainDate.from("1976-11-18"); const plainYearMonth = Temporal.PlainYearMonth.from(plainDate); TemporalHelpers.assertPlainYearMonth(plainYearMonth, 1976, 11, "M11"); -const fields = plainYearMonth.getISOFields(); -assert.sameValue(fields.calendar, "iso8601", "calendar slot should store a string"); -assert.sameValue(fields.isoDay, 1, "isoDay"); -assert.sameValue(fields.isoMonth, 11, "isoMonth"); -assert.sameValue(fields.isoYear, 1976, "isoYear"); +assert.sameValue(plainYearMonth.calendarId, "iso8601", "calendar string should be iso8601"); +assert.sameValue(plainYearMonth.toString({ calendarName: "always" }), "1976-11-01[u-ca=iso8601]", "iso reference date"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-plainyearmonth.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-plainyearmonth.js index 9dd8f55b377..fa59a100fab 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/argument-plainyearmonth.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-plainyearmonth.js @@ -18,7 +18,7 @@ TemporalHelpers.assertPlainYearMonth( /* era = */ undefined, /* eraYear = */ undefined, /* isoDay = */ 7 ); -assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "Calendar is copied"); +assert.sameValue(result.calendarId, orig.calendarId, "Calendar is copied"); assert.notSameValue( result, diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-iso-string.js index 152900e85fb..026be305bbe 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-iso-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-iso-string.js @@ -21,5 +21,5 @@ for (const calendar of [ const arg = { year: 2019, monthCode: "M06", calendar }; const result = Temporal.PlainYearMonth.from(arg); TemporalHelpers.assertPlainYearMonth(result, 2019, 6, "M06", `Calendar created from string "${calendar}"`); - assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); + assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); } diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-string.js index a98c2b5567f..24ac2ac93ef 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-string.js @@ -13,4 +13,4 @@ const calendar = "iso8601"; const arg = { year: 2019, monthCode: "M06", calendar }; const result = Temporal.PlainYearMonth.from(arg); TemporalHelpers.assertPlainYearMonth(result, 2019, 6, "M06", `Calendar created from string "${calendar}"`); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-wrong-type.js index 96f03d09865..13f11f91dee 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-propertybag-calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.plainyearmonth.from description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ @@ -28,10 +28,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-string.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-string.js index dc897c34ddd..75c40c9a3f7 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/argument-string.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-string.js @@ -11,20 +11,13 @@ features: [Temporal] for (const input of TemporalHelpers.ISO.plainYearMonthStringsValid()) { const plainYearMonth = Temporal.PlainYearMonth.from(input); TemporalHelpers.assertPlainYearMonth(plainYearMonth, 1976, 11, "M11"); - const fields = plainYearMonth.getISOFields(); - assert.sameValue(fields.calendar, "iso8601", "calendar slot should store a string"); - assert.sameValue(fields.isoDay, 1, "isoDay"); - assert.sameValue(fields.isoMonth, 11, "isoMonth"); - assert.sameValue(fields.isoYear, 1976, "isoYear"); + assert.sameValue(plainYearMonth.calendarId, "iso8601", "calendar string should be iso8601"); + assert.sameValue(plainYearMonth.toString({ calendarName: "always" }), "1976-11-01[u-ca=iso8601]", "iso reference date"); } for (const input of TemporalHelpers.ISO.plainYearMonthStringsValidNegativeYear()) { const plainYearMonth = Temporal.PlainYearMonth.from(input); TemporalHelpers.assertPlainYearMonth(plainYearMonth, -9999, 11, "M11"); - const fields = plainYearMonth.getISOFields(); - assert.sameValue(fields.calendar, "iso8601", "calendar slot should store a string"); - assert.sameValue(fields.isoDay, 1, "isoDay"); - assert.sameValue(fields.isoMonth, 11, "isoMonth"); - assert.sameValue(fields.isoYear, -9999, "isoYear"); - assert.sameValue(plainYearMonth.toString(), "-009999-11"); + assert.sameValue(plainYearMonth.calendarId, "iso8601", "calendar string should be iso8601"); + assert.sameValue(plainYearMonth.toString({ calendarName: "always" }), "-009999-11-01[u-ca=iso8601]", "iso reference date"); } diff --git a/test/built-ins/Temporal/PlainYearMonth/from/basic.js b/test/built-ins/Temporal/PlainYearMonth/from/basic.js new file mode 100644 index 00000000000..12b56cd9530 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/basic.js @@ -0,0 +1,30 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.from +description: Returns correctly with valid data +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +let result = Temporal.PlainYearMonth.from({ year: 2021, month: 7 }); +TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "year 2021, month 7"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 12 }); +TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "year 2021, month 12"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M07" }); +TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "year 2021, monthCode M07"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M12" }); +TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "year 2021, monthCode M12"); + +["constrain", "reject"].forEach((overflow) => { + const opt = { overflow }; + result = Temporal.PlainYearMonth.from({ year: 2021, month: 7 }, opt); + TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", `year 2021, month 7, overflow ${overflow}`); + result = Temporal.PlainYearMonth.from({ year: 2021, month: 12 }, opt); + TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", `year 2021, month 12, overflow ${overflow}`); + result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M07" }, opt); + TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", `year 2021, monthCode M07, overflow ${overflow}`); + result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M12" }, opt); + TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", `year 2021, monthCode M12, overflow ${overflow}`); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/from/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 2db044e3fe8..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/from/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 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: > - Calendar.yearMonthFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const arg = { year: 2000, month: 5, calendar }; -Temporal.PlainYearMonth.from(arg); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainYearMonth/from/calendar-fields-iterable.js deleted file mode 100644 index 4676d5ab08b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/from/calendar-fields-iterable.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 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: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainyearmonth.from step 3: - 3. Return ? ToTemporalYearMonth(_item_, _options_). - sec-temporal-totemporalyearmonth step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -Temporal.PlainYearMonth.from({ year: 2000, month: 5, calendar }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/calendar-temporal-object.js b/test/built-ins/Temporal/PlainYearMonth/from/calendar-temporal-object.js index 050e990a0ff..c84863db1e5 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/calendar-temporal-object.js @@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.PlainYearMonth.from({ year: 2000, month: 5, calendar: temporalObject }); - assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/from/constructor-in-calendar-fields.js deleted file mode 100644 index 26574f87ee2..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/from/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.from -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainYearMonth.from(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/from/duplicate-calendar-fields.js deleted file mode 100644 index 03f93d3a10a..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/from/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.from -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - - -for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - - assert.throws(RangeError, () => Temporal.PlainYearMonth.from(arg)); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/from/fields-missing-properties.js b/test/built-ins/Temporal/PlainYearMonth/from/fields-missing-properties.js new file mode 100644 index 00000000000..fbb68678d23 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/fields-missing-properties.js @@ -0,0 +1,12 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.from +description: Throws TypeError with incorrect input data type +features: [Temporal] +---*/ + +assert.throws(TypeError, () => Temporal.PlainYearMonth.from({}), "at least one correctly spelled property is required"); +assert.throws(TypeError, () => Temporal.PlainYearMonth.from({ month: 1 }), "year is required"); +assert.throws(TypeError, () => Temporal.PlainYearMonth.from({ year: 2021 }), "month or monthCode is required"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/missing-properties.js b/test/built-ins/Temporal/PlainYearMonth/from/missing-properties.js new file mode 100644 index 00000000000..8ca897742cc --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/missing-properties.js @@ -0,0 +1,24 @@ +// Copyright (C) 2022 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: Errors due to missing properties on fields object are thrown in the correct order +features: [Temporal] +---*/ + +let getMonth = false; +let getMonthCode = false; +const missingYearAndMonth = { + get month() { + getMonth = true; + }, + get monthCode() { + getMonthCode = true; + }, +}; +assert.throws(TypeError, () => Temporal.PlainYearMonth.from(missingYearAndMonth), "year should be checked after fetching but before resolving the month"); +assert(getMonth, "year is fetched after month"); +assert(getMonthCode, "year is fetched after monthCode"); + +assert.throws(TypeError, () => Temporal.PlainYearMonth.from({ year: 2000 }), "month should be resolved last"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/monthcode-invalid.js b/test/built-ins/Temporal/PlainYearMonth/from/monthcode-invalid.js new file mode 100644 index 00000000000..84357f8890f --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/monthcode-invalid.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.from +description: Throw RangeError for an out-of-range, conflicting, or ill-formed monthCode +features: [Temporal] +---*/ + +["m1", "M1", "m01"].forEach((monthCode) => { + assert.throws(RangeError, () => Temporal.PlainYearMonth.from({ year: 2021, monthCode }), + `monthCode '${monthCode}' is not well-formed`); +}); + +assert.throws(RangeError, () => Temporal.PlainYearMonth.from({ year: 2021, month: 12, monthCode: "M11" }), + "monthCode and month conflict"); + +["M00", "M19", "M99", "M13"].forEach((monthCode) => { + assert.throws(RangeError, () => Temporal.PlainYearMonth.from({ year: 2021, monthCode }), + `monthCode '${monthCode}' is not valid for year 2021`); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-primitive.js index 66eeb90b341..1714a0a4603 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-primitive.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-primitive.js @@ -9,8 +9,6 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", @@ -25,9 +23,9 @@ TemporalHelpers.assertPlainYearMonth(result, 2021, 5, "M05"); actual.splice(0); // empty it for the next check const failureExpected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", ]; assert.throws(TypeError, () => Temporal.PlainYearMonth.from(7, options)); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-string-invalid.js index 7fa6807b3ec..774824f76b0 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-string-invalid.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/observable-get-overflow-argument-string-invalid.js @@ -9,9 +9,9 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", ]; let actual = []; diff --git a/test/built-ins/Temporal/PlainYearMonth/from/one-of-era-erayear-undefined.js b/test/built-ins/Temporal/PlainYearMonth/from/one-of-era-erayear-undefined.js new file mode 100644 index 00000000000..524b01f9ecd --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/one-of-era-erayear-undefined.js @@ -0,0 +1,15 @@ +// Copyright (C) 2023 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: Does not throw a RangeError if only one of era/eraYear fields is present +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const base = { year: 2000, month: 5, day: 2, era: 'ce' }; +TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from(base), 2000, 5, 'M05'); + +const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 }; +TemporalHelpers.assertPlainYearMonth(Temporal.PlainYearMonth.from(base2), 2000, 5, 'M05'); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js index 2c875417e8b..92451a2f5aa 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/order-of-operations.js @@ -10,39 +10,11 @@ features: [Temporal] const expected = [ // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", - "getOwnPropertyDescriptor options.extra", - "get options.extra", + "get options.overflow.toString", + "call options.overflow.toString", // GetTemporalCalendarSlotValueWithISODefault "get fields.calendar", - "has fields.calendar.dateAdd", - "has fields.calendar.dateFromFields", - "has fields.calendar.dateUntil", - "has fields.calendar.day", - "has fields.calendar.dayOfWeek", - "has fields.calendar.dayOfYear", - "has fields.calendar.daysInMonth", - "has fields.calendar.daysInWeek", - "has fields.calendar.daysInYear", - "has fields.calendar.fields", - "has fields.calendar.id", - "has fields.calendar.inLeapYear", - "has fields.calendar.mergeFields", - "has fields.calendar.month", - "has fields.calendar.monthCode", - "has fields.calendar.monthDayFromFields", - "has fields.calendar.monthsInYear", - "has fields.calendar.weekOfYear", - "has fields.calendar.year", - "has fields.calendar.yearMonthFromFields", - "has fields.calendar.yearOfWeek", - // lookup - "get fields.calendar.fields", - "get fields.calendar.yearMonthFromFields", - // CalendarFields - "call fields.calendar.fields", // PrepareTemporalFields "get fields.month", "get fields.month.valueOf", @@ -53,11 +25,6 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", - // CalendarYearMonthFromFields - "call fields.calendar.yearMonthFromFields", - // inside Calendar.p.yearMonthFromFields - "get options.overflow.toString", - "call options.overflow.toString", ]; const actual = []; @@ -65,8 +32,8 @@ const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7, month: 1.7, monthCode: "M01", - calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), -}, "fields"); + calendar: "iso8601", +}, "fields", ["calendar"]); const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain", diff --git a/test/built-ins/Temporal/PlainYearMonth/from/overflow-constrain.js b/test/built-ins/Temporal/PlainYearMonth/from/overflow-constrain.js index c1cacdf6196..5bda3f57b66 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/overflow-constrain.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/overflow-constrain.js @@ -12,3 +12,75 @@ const propertyBag = { year: 2000, month: 13 }; const plainYearMonth = Temporal.PlainYearMonth.from(propertyBag, { overflow: "constrain" }); TemporalHelpers.assertPlainYearMonth(plainYearMonth, 2000, 12, "M12", "default overflow is constrain"); +const opt = { overflow: "constrain" }; + +let result = Temporal.PlainYearMonth.from({ year: 2021, month: 1 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 1, "M01", "month 1 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 2 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 2, "M02", "month 2 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 3 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 3, "M03", "month 3 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 4 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 4, "M04", "month 4 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 5 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 5, "M05", "month 5 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 6 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 6, "M06", "month 6 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 7 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "month 7 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 8 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 8, "M08", "month 8 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 9 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 9, "M09", "month 9 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 10 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 10, "M10", "month 10 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 11 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 11, "M11", "month 11 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 12 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "month 12 with overflow constrain"); + +assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from({ year: 2021, month: -99999 }, opt), + "negative month -99999 is out of range even with overflow constrain" +) +assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from({ year: 2021, month: -1 }, opt), + "negative month -1 is out of range even with overflow constrain" +) +assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from({ year: 2021, month: 0 }, opt), + "month zero is out of range even with overflow constrain" +) + +result = Temporal.PlainYearMonth.from({ year: 2021, month: 13 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "month 13 is constrained to 12"); +result = Temporal.PlainYearMonth.from({ year: 2021, month: 99999 }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "month 99999 is constrained to 12"); + +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M01" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 1, "M01", "monthCode M01 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M02" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 2, "M02", "monthCode M02 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M03" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 3, "M03", "monthCode M03 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M04" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 4, "M04", "monthCode M04 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M05" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 5, "M05", "monthCode M05 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M06" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 6, "M06", "monthCode M06 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M07" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 7, "M07", "monthCode M07 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M08" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 8, "M08", "monthCode M08 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M09" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 9, "M09", "monthCode M09 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M10" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 10, "M10", "monthCode M10 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M11" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 11, "M11", "monthCode M11 with overflow constrain"); +result = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M12" }, opt); +TemporalHelpers.assertPlainYearMonth(result, 2021, 12, "M12", "monthCode M12 with overflow constrain"); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/overflow-reject.js b/test/built-ins/Temporal/PlainYearMonth/from/overflow-reject.js index 86e4151cd53..64d6d082d1e 100644 --- a/test/built-ins/Temporal/PlainYearMonth/from/overflow-reject.js +++ b/test/built-ins/Temporal/PlainYearMonth/from/overflow-reject.js @@ -9,3 +9,11 @@ features: [Temporal] const bad = { year: 2019, month: 13 }; assert.throws(RangeError, () => Temporal.PlainYearMonth.from(bad, { overflow: "reject" })); + +[-1, 0, 13, 9995].forEach((month) => { + assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from({year: 2021, month, day: 5}, { overflow: "reject" }), + `Month ${month} is out of range for 2021 with overflow: reject` + ); +}); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/from/proto-in-calendar-fields.js deleted file mode 100644 index c816a8e31f8..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/from/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.from -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; - -assert.throws(RangeError, () => Temporal.PlainYearMonth.from(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/from/reference-day.js b/test/built-ins/Temporal/PlainYearMonth/from/reference-day.js new file mode 100644 index 00000000000..d8500272c4f --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/reference-day.js @@ -0,0 +1,36 @@ +// Copyright (C) 2023 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: Reference ISO day is chosen to be the first of the calendar month +info: | + 6.d. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, *1*𝔽). + e. Let _result_ be ? CalendarDateToISO(_calendar_.[[Identifier]], _fields_, _options_). +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const result1 = Temporal.PlainYearMonth.from({ year: 2023, monthCode: "M01", day: 13 }); +TemporalHelpers.assertPlainYearMonth( + result1, + 2023, 1, "M01", + "reference day is 1 even if day is given", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 +); + +const result2 = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "constrain" }); +TemporalHelpers.assertPlainYearMonth( + result2, + 2021, 2, "M02", + "reference day is 1 even if day is out of range (overflow constrain)", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 +); + +const result3 = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "reject" }); +TemporalHelpers.assertPlainYearMonth( + result3, + 2021, 2, "M02", + "reference day is 1 even if day is out of range (overflow reject)", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 1 +); diff --git a/test/built-ins/Temporal/PlainYearMonth/infinity-throws-rangeerror.js b/test/built-ins/Temporal/PlainYearMonth/infinity-throws-rangeerror.js index b81f09b70ef..521c631489c 100644 --- a/test/built-ins/Temporal/PlainYearMonth/infinity-throws-rangeerror.js +++ b/test/built-ins/Temporal/PlainYearMonth/infinity-throws-rangeerror.js @@ -8,11 +8,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const isoCalendar = Temporal.Calendar.from('iso8601'); - assert.throws(RangeError, () => new Temporal.PlainYearMonth(Infinity, 1)); assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, Infinity)); -assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, 1, isoCalendar, Infinity)); +assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, 1, "iso8601", Infinity)); const O = (primitiveValue, propertyName) => (calls) => TemporalHelpers.toPrimitiveObserver(calls, primitiveValue, propertyName); const tests = [ diff --git a/test/built-ins/Temporal/PlainYearMonth/negative-infinity-throws-rangeerror.js b/test/built-ins/Temporal/PlainYearMonth/negative-infinity-throws-rangeerror.js index 0f65524ae8c..b49d79c0777 100644 --- a/test/built-ins/Temporal/PlainYearMonth/negative-infinity-throws-rangeerror.js +++ b/test/built-ins/Temporal/PlainYearMonth/negative-infinity-throws-rangeerror.js @@ -8,11 +8,10 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const isoCalendar = Temporal.Calendar.from('iso8601'); assert.throws(RangeError, () => new Temporal.PlainYearMonth(-Infinity, 1)); assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, -Infinity)); -assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, 1, isoCalendar, -Infinity)); +assert.throws(RangeError, () => new Temporal.PlainYearMonth(1970, 1, "iso8601", -Infinity)); const O = (primitiveValue, propertyName) => (calls) => TemporalHelpers.toPrimitiveObserver(calls, primitiveValue, propertyName); const tests = [ diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/builtin-calendar-no-array-iteration.js deleted file mode 100644 index b16d66c4ff9..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainYearMonth(2023, 5, "iso8601"); -instance.add({ years: 5, months: 2 }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/builtin-calendar-no-observable-calls.js deleted file mode 100644 index b6058315ed6..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.add(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments-extra-options.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments-extra-options.js deleted file mode 100644 index 73786913835..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments-extra-options.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: PlainYearMonth.prototype.add should pass extra fields in copied options objects. -info: | - YearMonthFromFields ( calendar, fields [ , options ] ) - - 5. Let yearMonth be ? Invoke(calendar, "yearMonthFromFields", « fields, options »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.extra", - "get options.extra", - // Temporal.Calendar.prototype.dateAdd - "get options.overflow", - // overwriting property in custom calendar dateAdd - "getOwnPropertyDescriptor options.overflow", -]; -const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options"); - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(date, duration, options) { - const result = super.dateAdd(date, duration, options); - options.overflow = 'meatloaf'; - return result; - } - yearMonthFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.notSameValue(args[1], options, "args[1]"); - return super.yearMonthFromFields(...args); - } -} -const plainYearMonth = new Temporal.PlainYearMonth(2000, 3, new CustomCalendar()); -const result = plainYearMonth.add({ months: 5 }, options); -TemporalHelpers.assertPlainYearMonth(result, 2000, 8, "M08"); -assert.compareArray(actual, expected, "extra field options object order of operations"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments.js deleted file mode 100644 index e8d97940e79..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-arguments.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: PlainYearMonth.prototype.add should respect calendar arguments and pass copied options objects. -info: | - YearMonthFromFields ( calendar, fields [ , options ] ) - - 5. Let yearMonth be ? Invoke(calendar, "yearMonthFromFields", « fields, options »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", - // Temporal.Calendar.prototype.dateAdd - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", - // overwriting property in custom calendar dateAdd - "getOwnPropertyDescriptor options.overflow", - // Temporal.Calendar.prototype.yearMonthFromFields (toPrimitiveObserver copied but not options object) - "get options.overflow.toString", - "call options.overflow.toString", -]; -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(date, duration, options) { - const result = super.dateAdd(date, duration, options); - options.overflow = 'meatloaf'; - return result; - } - yearMonthFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.notSameValue(args[1], options, "args[1]"); - return super.yearMonthFromFields(...args); - } -} - -const plainYearMonth = new Temporal.PlainYearMonth(2000, 3, new CustomCalendar()); -const result = plainYearMonth.add({ months: 10 }, options); -TemporalHelpers.assertPlainYearMonth(result, 2001, 1, "M01"); -assert.compareArray(actual, expected, "copied options object order of operations"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-dateadd-called-with-plaindate-instance.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-dateadd-called-with-plaindate-instance.js deleted file mode 100644 index 036c9b06341..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-dateadd-called-with-plaindate-instance.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: Duration addition to PlainYearMonth calls Calendar.dateAdd the right number of times -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddPlainDateInstance(); -const instance = new Temporal.PlainYearMonth(1983, 3, calendar); -TemporalHelpers.assertPlainYearMonth(instance.add({weeks: 5}), 1983, 4, 'M04', "Adding 5 weeks to March in is8601 calendar") -assert.sameValue(calendar.dateAddCallCount, 1, "dateAdd called once with positive add"); - -calendar.dateAddCallCount = 0; -TemporalHelpers.assertPlainYearMonth(instance.add({weeks: -5}), 1983, 2, 'M02', "Adding -5 weeks to March in is8601 calendar") -assert.sameValue(calendar.dateAddCallCount, 2, "dateAdd called 2 times with negative add"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-dateadd.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-dateadd.js deleted file mode 100644 index 130d2e0f93b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-dateadd.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: PlainYearMonth.prototype.add should call dateAdd with the appropriate values. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(plainDate, duration, options) { - ++calls; - TemporalHelpers.assertPlainDate(plainDate, 2000, 3, "M03", 1, "plainDate argument"); - TemporalHelpers.assertDuration(duration, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, "duration argument"); - assert.sameValue(typeof options, "object", "options argument: type"); - assert.sameValue(Object.getPrototypeOf(options), null, "options argument: prototype"); - return super.dateAdd(plainDate, duration, options); - } -} - -const plainYearMonth = new Temporal.PlainYearMonth(2000, 3, new CustomCalendar()); -const result = plainYearMonth.add({ months: 10 }); -TemporalHelpers.assertPlainYearMonth(result, 2001, 1, "M01"); -assert.sameValue(calls, 1, "should have called dateAdd"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-datefromfields-called.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-datefromfields-called.js deleted file mode 100644 index 07b5c6b115b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-datefromfields-called.js +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: > - Calls calendar's dateFromFields method to obtain a start date for the - operation, based on the sign of the duration -info: | - 8. Let _fields_ be ? PrepareTemporalFields(_yearMonth_, _fieldNames_, «»). - 9. Let _sign_ be ! DurationSign(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _balanceResult_.[[Days]], 0, 0, 0, 0, 0, 0). - 10. If _sign_ < 0, then - a. Let _dayFromCalendar_ be ? CalendarDaysInMonth(_calendar_, _yearMonth_). - b. Let _day_ be ? ToPositiveInteger(_dayFromCalendar_). - 11. Else, - a. Let _day_ be 1. - 12. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, _day_). - 13. Let _date_ be ? DateFromFields(_calendar_, _fields_, *undefined*). -includes: [deepEqual.js, temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.dateFromFieldsCalls = []; - } - year(date) { - // years in this calendar start and end on the same day as ISO 8601 years - return date.getISOFields().isoYear; - } - month(date) { - // this calendar has 10 months of 36 days each, plus an 11th month of 5 or 6 - const { isoYear, isoMonth, isoDay } = date.getISOFields(); - const isoDate = new Temporal.PlainDate(isoYear, isoMonth, isoDay); - return Math.floor((isoDate.dayOfYear - 1) / 36) + 1; - } - monthCode(date) { - return "M" + this.month(date).toString().padStart(2, "0"); - } - day(date) { - return (date.dayOfYear - 1) % 36 + 1; - } - daysInMonth(date) { - if (this.month(date) < 11) return 36; - return this.daysInYear(date) - 360; - } - _dateFromFieldsImpl({ year, month, monthCode, day }) { - if (year === undefined) throw new TypeError("year required"); - if (month === undefined && monthCode === undefined) throw new TypeError("one of month or monthCode required"); - if (month !== undefined && month < 1) throw new RangeError("month < 1"); - if (day === undefined) throw new TypeError("day required"); - - if (monthCode !== undefined) { - const numberPart = +(monthCode.slice(1)); - if ("M" + `${numberPart}`.padStart(2, "0") !== monthCode) throw new RangeError("invalid monthCode"); - if (month === undefined) { - month = numberPart; - } else if (month !== numberPart) { - throw new RangeError("month and monthCode must match"); - } - } - - const isoDayOfYear = (month - 1) * 36 + day; - return new Temporal.PlainDate(year, 1, 1).add({ days: isoDayOfYear - 1 }).withCalendar(this); - } - dateFromFields(...args) { - this.dateFromFieldsCalls.push(args); - return this._dateFromFieldsImpl(...args); - } - yearMonthFromFields(fields, options) { - const { isoYear, isoMonth, isoDay } = this._dateFromFieldsImpl({ ...fields, day: 1 }, options).getISOFields(); - return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); - } - monthDayFromFields(fields, options) { - const { isoYear, isoMonth, isoDay } = this._dateFromFieldsImpl({ ...fields, year: 2000 }, options).getISOFields(); - return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); - } - dateAdd(date, duration, options) { - const {isoYear, isoMonth, isoDay} = date.getISOFields(); - let {years, months, weeks, days} = duration; - let iter = new Temporal.PlainDate(isoYear + years, isoMonth, isoDay, "iso8601"); - const monthsDays = months * 36; - if (iter.dayOfYear + monthsDays > iter.daysInYear || iter.dayOfYear + monthsDays < 1) - throw new Error("complicated addition not implemented in this test"); - return iter.add({ weeks, days: monthsDays + days }).withCalendar(this); - } - toString() { - return "thirty-six"; - } -} - -const calendar = new CustomCalendar(); -const month2 = Temporal.PlainYearMonth.from({ year: 2022, month: 2, calendar }); -const lessThanOneMonth = new Temporal.Duration(0, 0, 0, 35); -const oneMonth = new Temporal.Duration(0, 0, 0, 36); - -// Reference ISO dates in the custom calendar: -// M01 = 01-01 -// M02 = 02-06 -// M03 = 03-14 - -calendar.dateFromFieldsCalls = []; -TemporalHelpers.assertPlainYearMonth( - month2.add(lessThanOneMonth), - 2022, 2, "M02", - "adding positive less than one month's worth of days yields the same month", - /* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 6 -); -assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called"); -assert.deepEqual( - calendar.dateFromFieldsCalls[0][0], - { year: 2022, monthCode: "M02", day: 1 }, - "first day of month 2 passed to dateFromFields when adding positive duration" -); -assert.sameValue(calendar.dateFromFieldsCalls[0][1], undefined, "undefined options passed"); - -calendar.dateFromFieldsCalls = []; -TemporalHelpers.assertPlainYearMonth( - month2.add(oneMonth), - 2022, 3, "M03", - "adding positive one month's worth of days yields the following month", - /* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 14 -); -assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called"); -assert.deepEqual( - calendar.dateFromFieldsCalls[0][0], - { year: 2022, monthCode: "M02", day: 1 }, - "first day of month 2 passed to dateFromFields when adding positive duration" -); -assert.sameValue(calendar.dateFromFieldsCalls[0][1], undefined, "undefined options passed"); - -calendar.dateFromFieldsCalls = []; -TemporalHelpers.assertPlainYearMonth( - month2.add(lessThanOneMonth.negated()), - 2022, 2, "M02", - "adding negative less than one month's worth of days yields the same month", - /* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 6 -); -assert.sameValue(calendar.dateFromFieldsCalls.length, 2, "dateFromFields was called twice"); -assert.deepEqual( - calendar.dateFromFieldsCalls[1][0], - { year: 2022, monthCode: "M02", day: 36 }, - "last day of month 2 passed to dateFromFields when adding negative duration" -); -assert.sameValue(calendar.dateFromFieldsCalls[0][1], undefined, "undefined options passed"); - -calendar.dateFromFieldsCalls = []; -TemporalHelpers.assertPlainYearMonth( - month2.add(oneMonth.negated()), - 2022, 1, "M01", - "adding negative one month's worth of days yields the previous month", - /* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 1 -); -assert.sameValue(calendar.dateFromFieldsCalls.length, 2, "dateFromFields was called twice"); -assert.deepEqual( - calendar.dateFromFieldsCalls[1][0], - { year: 2022, monthCode: "M02", day: 36 }, - "last day of month 2 passed to dateFromFields when adding negative duration" -); -assert.sameValue(calendar.dateFromFieldsCalls[0][1], undefined, "undefined options passed"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-fields-iterable.js deleted file mode 100644 index bc7a4053dac..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-fields-iterable.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainyearmonth.prototype.add step 8: - 8. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar); -yearmonth.add({ months: 1 }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 97f0737b67c..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.add(new Temporal.Duration(1)); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should have been called on the calendar"); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-yearmonthfromfields-called-with-null-prototype-options.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-yearmonthfromfields-called-with-null-prototype-options.js deleted file mode 100644 index 1f5a94efc26..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-yearmonthfromfields-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: > - Calendar.yearMonthFromFields method is called with a null-prototype object - as the options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2019, 6, calendar); -const argument = new Temporal.Duration(1, 1); -instance.add(argument); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should be called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/constructor-in-calendar-fields.js deleted file mode 100644 index f85b7eded5f..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - -assert.throws(RangeError, () => ym.add({days: 123})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/custom-daysInMonth-irrelevant.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/custom-daysInMonth-irrelevant.js deleted file mode 100644 index e1834e58b5c..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/custom-daysInMonth-irrelevant.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: Addition of a negative duration to a PlainYearMonth is not influenced by the implementation of daysInMonth() -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInMonth(ym, ...args) { - return 15; - } -} - -const customCalendar = new CustomCalendar(); -const instance = new Temporal.PlainYearMonth(2023, 3, customCalendar); - -TemporalHelpers.assertPlainYearMonth(instance.add({days: -30}), 2023, 3, 'M03', "Adding -30 days from calendar reimplementing daysinMonth()") diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/duplicate-calendar-fields.js deleted file mode 100644 index 0cc84dbd968..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - - assert.throws(RangeError, () => ym.add({days: 123})); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/end-of-month-out-of-range.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/end-of-month-out-of-range.js index bdae83c18b9..af1dbfc2b05 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/end-of-month-out-of-range.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/end-of-month-out-of-range.js @@ -20,11 +20,3 @@ const duration = new Temporal.Duration(0, 0, 0, -1); // Calendar addition result is out of range assert.throws(RangeError, () => new Temporal.PlainYearMonth(275760, 9).add(duration), "Addition of 1 month to receiver out of range"); - -// Calendar addition succeeds, but subtracting 1 day gives out of range result -const cal = new class extends Temporal.Calendar { - dateAdd() { - return new Temporal.PlainDate(-271821, 4, 19); - } -}("iso8601"); -assert.throws(RangeError, () => new Temporal.PlainYearMonth(2000, 1, cal).add(duration), "Subtraction of 1 day from next month out of range"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/options-undefined.js deleted file mode 100644 index c13d1ca8424..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/options-undefined.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: Verify that undefined options are handled correctly. -features: [Temporal] ----*/ - -// overflow option has no effect on addition in the ISO calendar, so verify this -// with a custom calendar -class CheckedAdd extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(date, duration, options, constructor) { - this.called = true; - assert.notSameValue(options, undefined, "options not undefined"); - return super.dateAdd(date, duration, options, constructor); - } -} -const calendar = new CheckedAdd(); - -const yearmonth = new Temporal.PlainYearMonth(2000, 1, calendar); -const duration = { months: 1 }; - -yearmonth.add(duration, undefined); -yearmonth.add(duration); - -assert(calendar.called); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js index 00d50ea89fe..0045f2fb5c6 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/order-of-operations.js @@ -40,48 +40,14 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateFromFields", - "get this.calendar.day", - "get this.calendar.fields", - "get this.calendar.yearMonthFromFields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields on receiver - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - // CalendarDateFromFields - "call this.calendar.dateFromFields", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", + // GetTemporalOverflowOption "get options.overflow", - // CalendarDateAdd - "call this.calendar.dateAdd", - // inside Calendar.p.dateAdd - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", - // PrepareTemporalFields on added date - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - // CalendarYearMonthFromFields - "call this.calendar.yearMonthFromFields", - // inside Calendar.p.yearMonthFromFields "get options.overflow.toString", "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainYearMonth(2000, 5); const fields = TemporalHelpers.propertyBagObserver(actual, { years: 1, @@ -102,79 +68,3 @@ instance.add(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -const noCalendarExpected = [ - // ToTemporalDuration - "get fields.days", - "get fields.days.valueOf", - "call fields.days.valueOf", - "get fields.hours", - "get fields.hours.valueOf", - "call fields.hours.valueOf", - "get fields.microseconds", - "get fields.microseconds.valueOf", - "call fields.microseconds.valueOf", - "get fields.milliseconds", - "get fields.milliseconds.valueOf", - "call fields.milliseconds.valueOf", - "get fields.minutes", - "get fields.minutes.valueOf", - "call fields.minutes.valueOf", - "get fields.months", - "get fields.nanoseconds", - "get fields.nanoseconds.valueOf", - "call fields.nanoseconds.valueOf", - "get fields.seconds", - "get fields.seconds.valueOf", - "call fields.seconds.valueOf", - "get fields.weeks", - "get fields.years", - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateFromFields", - "get this.calendar.day", - "get this.calendar.fields", - "get this.calendar.yearMonthFromFields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields on receiver - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - // CalendarDateFromFields - "call this.calendar.dateFromFields", - // SnapshotOwnProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", - // AddDate - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", - // PrepareTemporalFields on added date - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - // CalendarYearMonthFromFields - "call this.calendar.yearMonthFromFields", - // inside Calendar.p.yearMonthFromFields - "get options.overflow.toString", - "call options.overflow.toString", -]; - -const noCalendarFields = TemporalHelpers.propertyBagObserver(actual, { - days: 1, - hours: 1, - minutes: 1, - seconds: 1, - milliseconds: 1, - microseconds: 1, - nanoseconds: 1, -}, "fields"); - -instance.add(noCalendarFields, options); -assert.compareArray(actual, noCalendarExpected, "order of operations with no calendar units"); - -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/overflow-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/overflow-wrong-type.js index 41937f230cd..6bc39ff5b7e 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/overflow-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/overflow-wrong-type.js @@ -33,13 +33,9 @@ assert.throws(RangeError, () => yearmonth.add(duration, { overflow: 2 }), "numbe assert.throws(RangeError, () => yearmonth.add(duration, { overflow: 2n }), "bigint"); assert.throws(RangeError, () => yearmonth.add(duration, { overflow: {} }), "plain object"); -// toString property is read once by Calendar.dateAdd() and then once again by -// calendar.yearMonthFromFields(). const expected = [ "get overflow.toString", "call overflow.toString", - "get overflow.toString", - "call overflow.toString", ]; const actual = []; const observer = TemporalHelpers.toPrimitiveObserver(actual, "constrain", "overflow"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/proto-in-calendar-fields.js deleted file mode 100644 index 79adbbe2782..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/add/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.add -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - -assert.throws(RangeError, () => ym.add({days: 123})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/calendarId/builtin-calendar-no-observable-calls.js deleted file mode 100644 index ab0323f1bef..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/calendarId/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.calendarid -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.calendarId; - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 516cffbb41c..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.daysinmonth -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInMonthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInMonth"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInMonth should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.daysInMonth; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", daysInMonthOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/custom.js b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/custom.js deleted file mode 100644 index e9beb6bf10f..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.daysinmonth -description: Custom calendar tests for daysInMonth(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInMonth(...args) { - ++calls; - assert.compareArray(args, [instance], "daysInMonth arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.PlainYearMonth(1830, 8, calendar); -const result = instance.daysInMonth; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/validate-calendar-value.js b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/validate-calendar-value.js deleted file mode 100644 index d49e36c7e65..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.daysinmonth -description: Validate result returned from calendar daysInMonth() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInMonth() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.throws(error, () => instance.daysInMonth, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 87c59cd9a01..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.daysinyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInYear"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.daysInYear; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", daysInYearOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/custom.js b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/custom.js deleted file mode 100644 index ecef88da8d7..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.daysinyear -description: Custom calendar tests for daysInYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInYear(...args) { - ++calls; - assert.compareArray(args, [instance], "daysInYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.PlainYearMonth(1830, 8, calendar); -const result = instance.daysInYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/validate-calendar-value.js deleted file mode 100644 index 741075aa414..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.daysinyear -description: Validate result returned from calendar daysInYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.throws(error, () => instance.daysInYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 3808eea38de..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.equals -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainYearMonth(2000, 5); -const arg = { year: 2000, month: 5, calendar: "iso8601" }; -instance.equals(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-wrong-type.js index e55cb3cee8d..e6851f931a2 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.plainyearmonth.prototype.equals description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.PlainYearMonth(2000, 5); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 2bd1798fd43..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.equals -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.equals(new Temporal.PlainYearMonth(2000, 5)); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 7383d68086e..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.equals -description: > - Calendar.yearMonthFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5); -const arg = { year: 2000, month: 5, calendar }; -instance.equals(arg); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-fields-iterable.js deleted file mode 100644 index 90b1c8c53f9..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-fields-iterable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.equals -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainyearmonth.prototype.equals step 3: - 3. Set _other_ to ? ToTemporalYearMonth(_other_). - sec-temporal-totemporalyearmonth step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -yearmonth.equals({ year: 2005, month: 6, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-temporal-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-temporal-object.js index 9af511590ed..ddb0afea37e 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, temporalObject); + const yearmonth = new Temporal.PlainYearMonth(2000, 5); yearmonth.equals({ year: 2005, month: 6, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-yearmonthfromfields-called-with-options-undefined.js deleted file mode 100644 index b69dc74fe57..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/calendar-yearmonthfromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.equals -description: > - Calendar.yearMonthFromFields method is called with undefined as the options - value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -let instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.equals({ year: 2000, month: 6, calendar }); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js deleted file mode 100644 index 90244edacac..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.equals -description: equals() takes the calendar into account -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -class CustomCalendar extends Temporal.Calendar { - constructor(id) { - super("iso8601"); - this._id = id; - } - get id() { - actual.push(this._id); - return this._id; - } - toString() { - TemporalHelpers.assertUnreachable("should not call toString"); - } -} - -const sharedCalendar = new CustomCalendar("a"); -const ym1 = new Temporal.PlainYearMonth(2000, 1, sharedCalendar, 1); -const ym2 = new Temporal.PlainYearMonth(2000, 1, sharedCalendar, 1); -assert.sameValue(ym1.equals(ym2), true); -assert.compareArray(actual, [], "should not call toString if objects are equal"); - -const ym3 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("b"), 1); -const ym4 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("c"), 2); -assert.sameValue(ym3.equals(ym4), false); -assert.compareArray(actual, [], "should not call toString if ISO dates differ"); - -const ym5 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("d"), 1); -const ym6 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("e"), 1); -assert.sameValue(ym5.equals(ym6), false); -assert.compareArray(actual, ["d", "e"], "order of operations"); - -actual.splice(0); // empty it for the next check -const ym7 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("f"), 1); -const ym8 = new Temporal.PlainYearMonth(2000, 1, new CustomCalendar("f"), 1); -assert.sameValue(ym7.equals(ym8), true); -assert.compareArray(actual, ["f", "f"], "order of operations"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-reference-day.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-reference-day.js index 3c40f5031ee..8cf550fa4be 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-reference-day.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/compare-reference-day.js @@ -7,7 +7,6 @@ description: equals() takes the reference day into account features: [Temporal] ---*/ -const iso = Temporal.Calendar.from("iso8601"); -const ym1 = new Temporal.PlainYearMonth(2000, 1, iso, 1); -const ym2 = new Temporal.PlainYearMonth(2000, 1, iso, 2); +const ym1 = new Temporal.PlainYearMonth(2000, 1, "iso8601", 1); +const ym2 = new Temporal.PlainYearMonth(2000, 1, "iso8601", 2); assert.sameValue(ym1.equals(ym2), false); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/constructor-in-calendar-fields.js deleted file mode 100644 index 48fc21d6cdc..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.equals -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/duplicate-calendar-fields.js deleted file mode 100644 index ae7a132a0c4..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.equals -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - - assert.throws(RangeError, () => instance.equals(arg)); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/proto-in-calendar-fields.js deleted file mode 100644 index d299fd21bc9..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.equals -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/branding.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/branding.js deleted file mode 100644 index 86293ae2500..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getcalendar -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getCalendar = Temporal.PlainYearMonth.prototype.getCalendar; - -assert.sameValue(typeof getCalendar, "function"); - -assert.throws(TypeError, () => getCalendar.call(undefined), "undefined"); -assert.throws(TypeError, () => getCalendar.call(null), "null"); -assert.throws(TypeError, () => getCalendar.call(true), "true"); -assert.throws(TypeError, () => getCalendar.call(""), "empty string"); -assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getCalendar.call(1), "1"); -assert.throws(TypeError, () => getCalendar.call({}), "plain object"); -assert.throws(TypeError, () => getCalendar.call(Temporal.PlainYearMonth), "Temporal.PlainYearMonth"); -assert.throws(TypeError, () => getCalendar.call(Temporal.PlainYearMonth.prototype), "Temporal.PlainYearMonth.prototype"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/builtin.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/builtin.js deleted file mode 100644 index a83fbdabe30..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getcalendar -description: > - Tests that Temporal.PlainYearMonth.prototype.getCalendar - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainYearMonth.prototype.getCalendar), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainYearMonth.prototype.getCalendar), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainYearMonth.prototype.getCalendar), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainYearMonth.prototype.getCalendar.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/length.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/length.js deleted file mode 100644 index 3105dd5b7e7..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getcalendar -description: Temporal.PlainYearMonth.prototype.getCalendar.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainYearMonth.prototype.getCalendar, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/name.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/name.js deleted file mode 100644 index f12a2525d75..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getcalendar -description: Temporal.PlainYearMonth.prototype.getCalendar.name is "getCalendar". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainYearMonth.prototype.getCalendar, "name", { - value: "getCalendar", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/not-a-constructor.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/not-a-constructor.js deleted file mode 100644 index a5fd3b5306a..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getcalendar -description: > - Temporal.PlainYearMonth.prototype.getCalendar does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainYearMonth.prototype.getCalendar(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainYearMonth.prototype.getCalendar), false, - "isConstructor(Temporal.PlainYearMonth.prototype.getCalendar)"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/prop-desc.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/prop-desc.js deleted file mode 100644 index 7a2db16e2cf..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getCalendar/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getcalendar -description: The "getCalendar" property of Temporal.PlainYearMonth.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainYearMonth.prototype.getCalendar, - "function", - "`typeof PlainYearMonth.prototype.getCalendar` is `function`" -); - -verifyProperty(Temporal.PlainYearMonth.prototype, "getCalendar", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/branding.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/branding.js deleted file mode 100644 index 88fe8f8e852..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getISOFields = Temporal.PlainYearMonth.prototype.getISOFields; - -assert.sameValue(typeof getISOFields, "function"); - -assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); -assert.throws(TypeError, () => getISOFields.call(null), "null"); -assert.throws(TypeError, () => getISOFields.call(true), "true"); -assert.throws(TypeError, () => getISOFields.call(""), "empty string"); -assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getISOFields.call(1), "1"); -assert.throws(TypeError, () => getISOFields.call({}), "plain object"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainYearMonth), "Temporal.PlainYearMonth"); -assert.throws(TypeError, () => getISOFields.call(Temporal.PlainYearMonth.prototype), "Temporal.PlainYearMonth.prototype"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/builtin.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/builtin.js deleted file mode 100644 index 190136a05cd..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: > - Tests that Temporal.PlainYearMonth.prototype.getISOFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.PlainYearMonth.prototype.getISOFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.PlainYearMonth.prototype.getISOFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.PlainYearMonth.prototype.getISOFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.PlainYearMonth.prototype.getISOFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/custom.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/custom.js deleted file mode 100644 index 64041f162a9..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/custom.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: getISOFields does not call into user code. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarThrowEverything(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -const result = instance.getISOFields(); - -assert.sameValue(result.isoYear, 2000, "isoYear result"); -assert.sameValue(result.isoMonth, 5, "isoMonth result"); -assert.sameValue(result.isoDay, 1, "isoDay result"); -assert.sameValue(result.calendar, calendar, "calendar result"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/field-names.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/field-names.js deleted file mode 100644 index 9684bb591e2..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/field-names.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: Correct field names on the object returned from getISOFields -features: [Temporal] ----*/ - -const ym = new Temporal.PlainYearMonth(2000, 5); - -const result = ym.getISOFields(); -assert.sameValue(result.isoYear, 2000, "isoYear result"); -assert.sameValue(result.isoMonth, 5, "isoMonth result"); -assert.sameValue(result.isoDay, 1, "isoDay result"); -assert.sameValue(result.calendar, "iso8601", "calendar result"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/field-prop-desc.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/field-prop-desc.js deleted file mode 100644 index 260fb52982b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/field-prop-desc.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: Properties on the returned object have the correct descriptor -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoMonth", - "isoYear", -]; - -const ym = new Temporal.PlainYearMonth(2000, 5); -const result = ym.getISOFields(); - -for (const property of expected) { - verifyProperty(result, property, { - writable: true, - enumerable: true, - configurable: true, - }); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/field-traversal-order.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/field-traversal-order.js deleted file mode 100644 index e2b1099f1b7..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/field-traversal-order.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: Properties added in correct order to object returned from getISOFields -includes: [compareArray.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoMonth", - "isoYear", -]; - -const ym = new Temporal.PlainYearMonth(2000, 5); -const result = ym.getISOFields(); - -assert.compareArray(Object.keys(result), expected); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/length.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/length.js deleted file mode 100644 index 4037863e6e7..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: Temporal.PlainYearMonth.prototype.getISOFields.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainYearMonth.prototype.getISOFields, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/name.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/name.js deleted file mode 100644 index 5b38b8809a0..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: Temporal.PlainYearMonth.prototype.getISOFields.name is "getISOFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.PlainYearMonth.prototype.getISOFields, "name", { - value: "getISOFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/not-a-constructor.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/not-a-constructor.js deleted file mode 100644 index ee99732e401..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: > - Temporal.PlainYearMonth.prototype.getISOFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.PlainYearMonth.prototype.getISOFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.PlainYearMonth.prototype.getISOFields), false, - "isConstructor(Temporal.PlainYearMonth.prototype.getISOFields)"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/prop-desc.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/prop-desc.js deleted file mode 100644 index ae6d5240779..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: The "getISOFields" property of Temporal.PlainYearMonth.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.PlainYearMonth.prototype.getISOFields, - "function", - "`typeof PlainYearMonth.prototype.getISOFields` is `function`" -); - -verifyProperty(Temporal.PlainYearMonth.prototype, "getISOFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/prototype.js b/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/prototype.js deleted file mode 100644 index 6df88521034..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/getISOFields/prototype.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.getisofields -description: Correct prototype on the object returned from getISOFields -features: [Temporal] ----*/ - -const instance = new Temporal.PlainYearMonth(2000, 5); -const result = instance.getISOFields(); -assert.sameValue(Object.getPrototypeOf(result), Object.prototype, "prototype"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index a7e7f144410..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.inleapyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const inLeapYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "inLeapYear"); -Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("inLeapYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.inLeapYear; - -Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", inLeapYearOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/custom.js b/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/custom.js deleted file mode 100644 index b69dcd55443..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.inleapyear -description: Custom calendar tests for inLeapYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - inLeapYear(...args) { - ++calls; - assert.compareArray(args, [instance], "inLeapYear arguments"); - return true; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.PlainYearMonth(1830, 8, calendar); -const result = instance.inLeapYear; -assert.sameValue(result, true, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/validate-calendar-value.js deleted file mode 100644 index 4663070e795..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/validate-calendar-value.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.inleapyear -description: Validate result returned from calendar inLeapYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [0, TypeError], - [-0, TypeError], - [42, TypeError], - [7.1, TypeError], - [NaN, TypeError], - [Infinity, TypeError], - [-Infinity, TypeError], - ["", TypeError], - ["a string", TypeError], - ["0", TypeError], - [Symbol("foo"), TypeError], - [0n, TypeError], - [42n, TypeError], - [{}, TypeError], - [{valueOf() { return false; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - inLeapYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.throws(error, () => instance.inLeapYear, `${typeof result} ${String(result)} not converted to boolean`); -}); - -const preservedResults = [ - true, - false, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - inLeapYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.sameValue(instance.inLeapYear, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/month/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/month/builtin-calendar-no-observable-calls.js deleted file mode 100644 index d89b0851827..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/month/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.month -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "month"); -Object.defineProperty(Temporal.Calendar.prototype, "month", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("month should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.month; - -Object.defineProperty(Temporal.Calendar.prototype, "month", monthOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/month/custom.js b/test/built-ins/Temporal/PlainYearMonth/prototype/month/custom.js deleted file mode 100644 index c681b232e79..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/month/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.month -description: Custom calendar tests for month(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - month(...args) { - ++calls; - assert.compareArray(args, [instance], "month arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.PlainYearMonth(1830, 8, calendar); -const result = instance.month; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/month/validate-calendar-value.js b/test/built-ins/Temporal/PlainYearMonth/prototype/month/validate-calendar-value.js deleted file mode 100644 index 2e3cc50a593..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/month/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.month -description: Validate result returned from calendar month() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - month() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.throws(error, () => instance.month, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 0961724c40c..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.monthcode -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthCode should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.monthCode; - -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/custom.js b/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/custom.js deleted file mode 100644 index c0977f29a1b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.monthcode -description: Custom calendar tests for monthCode(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthCode(...args) { - ++calls; - assert.compareArray(args, [instance], "monthCode arguments"); - return "M01"; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.PlainYearMonth(1830, 8, calendar); -const result = instance.monthCode; -assert.sameValue(result, "M01", "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/validate-calendar-value.js b/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/validate-calendar-value.js deleted file mode 100644 index 5ca35ceb9e4..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/validate-calendar-value.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.monthcode -description: Validate result returned from calendar monthCode() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [Symbol("foo"), TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, TypeError], - [{toString() { return "M01"; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - monthCode() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.throws(error, () => instance.monthCode, `${typeof result} ${String(result)} not converted to string`); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index afbc4769079..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.monthsinyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthsInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthsInYear"); -Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthsInYear should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.monthsInYear; - -Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", monthsInYearOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/custom.js b/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/custom.js deleted file mode 100644 index aa5accd0c9f..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.monthsinyear -description: Custom calendar tests for monthsInYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthsInYear(...args) { - ++calls; - assert.compareArray(args, [instance], "monthsInYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.PlainYearMonth(1830, 8, calendar); -const result = instance.monthsInYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/validate-calendar-value.js b/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/validate-calendar-value.js deleted file mode 100644 index e5338eae9ef..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.monthsinyear -description: Validate result returned from calendar monthsInYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - monthsInYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.throws(error, () => instance.monthsInYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index c29d8f10296..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainYearMonth(2000, 5); -const arg = { year: 2000, month: 5, calendar: "iso8601" }; -instance.since(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-wrong-type.js index 1368ad4ebd6..b09dd909916 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/argument-propertybag-calendar-wrong-type.js @@ -9,7 +9,6 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); const instance = new Temporal.PlainYearMonth(2000, 5); const primitiveTests = [ @@ -31,10 +30,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 3e8120ac117..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.since(new Temporal.PlainYearMonth(1999, 4)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-dateadd-called-with-plaindate-instance.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-dateadd-called-with-plaindate-instance.js deleted file mode 100644 index 20d22acfc90..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-dateadd-called-with-plaindate-instance.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: > - relativeTo parameters that are not ZonedDateTime or undefined, are always - converted to PlainDate for observable calendar calls -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddPlainDateInstance(); -const instance = new Temporal.PlainYearMonth(1970, 1, calendar); -instance.since(new Temporal.PlainYearMonth(2000, 5, calendar), { smallestUnit: "year" }); -assert(calendar.dateAddCallCount > 0, "assertions in calendar.dateAdd() should have been tested"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 3d595c0512b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: > - Calendar.yearMonthFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5); -const arg = { year: 2000, month: 5, calendar }; -instance.since(arg); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 9001d3afede..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.since({ year: 2000, month: 6, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 2); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js deleted file mode 100644 index b9fde52d1c4..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: > - Calendar.dateUntil method is called with a null-prototype object as the - options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -const argument = new Temporal.PlainYearMonth(2022, 6, calendar); -instance.since(argument); -assert.sameValue(calendar.dateUntilCallCount, 1, "dateUntil should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index e4bf11cd734..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: The options object passed to calendar.dateUntil has a largestUnit property with its value in the singular form -info: | - sec-temporal.plainyearmonth.prototype.since steps 21–22: - 21. Let _untilOptions_ be ? MergeLargestUnitOption(_options_, _largestUnit_). - 22. Let _result_ be ? CalendarDateUntil(_calendar_, _thisDate_, _otherDate_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.PlainYearMonth(2000, 5, calendar); - const later = new Temporal.PlainYearMonth(2001, 6, calendar); - later.since(earlier, { largestUnit }); - }, - { - years: ["year"], - months: ["month"] - } -); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-fields-iterable.js deleted file mode 100644 index c7b4938043f..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-fields-iterable.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainyearmonth.prototype.since step 3: - 3. Set _other_ to ? ToTemporalYearMonth(_other_). - sec-temporal.plainyearmonth.prototype.since step 14: - 14. Let fieldNames be ? CalendarFields(_calendar_, « *"monthCode"*, *"year"* »). - sec-temporal-totemporalyearmonth step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected1 = [ - "monthCode", - "year", -]; -const expected2 = [ - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -yearmonth.since({ year: 2005, month: 6, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 1, "fields() method not called"); -assert.compareArray(calendar1.fieldsCalledWith[0], expected1, "fields() method called with correct args"); -assert(calendar1.iteratorExhausted[0], "iterated through the whole iterable"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected2, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index cd68ce8b431..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.since(new Temporal.PlainYearMonth(2019, 2)); -assert.sameValue(calendar.dateFromFieldsCallCount, 2, "dateFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-temporal-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-temporal-object.js index b4804389c9e..ed3d42972c6 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, temporalObject); + const yearmonth = new Temporal.PlainYearMonth(2000, 5); yearmonth.since({ year: 2005, month: 6, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-yearmonthfromfields-called-with-options-undefined.js deleted file mode 100644 index 17a7687b4fa..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-yearmonthfromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: > - Calendar.yearMonthFromFields method is called with undefined as the options - value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -let instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.since({ year: 2000, month: 6, calendar }); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/constructor-in-calendar-fields.js deleted file mode 100644 index ad7c8ca7080..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - -assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/duplicate-calendar-fields.js deleted file mode 100644 index 209f708b630..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - - assert.throws(RangeError, () => instance.since(arg)); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js deleted file mode 100644 index 8dfa5fb1392..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: Mixed calendars throw as invalid -features: [Temporal] ----*/ - -class customCal extends Temporal.Calendar { - constructor () { - super('iso8601'); - } - - get id() { - return "I am a secret cal."; - } -} - -const ym1 = new Temporal.PlainYearMonth(2000, 1); -const ym2 = new Temporal.PlainYearMonth(2000, 1, new customCal()); - -assert.throws(RangeError, () => ym1.since(ym2), 'since throws with different calendars'); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js index 1ffc7cc9aeb..84d3bfd6cea 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/order-of-operations.js @@ -8,33 +8,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expectedMinimal = [ +const expected = [ // ToTemporalYearMonth "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.fields", - "get other.calendar.yearMonthFromFields", - "call other.calendar.fields", "get other.month", "get other.month.valueOf", "call other.month.valueOf", @@ -44,72 +20,33 @@ const expectedMinimal = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", - "call other.calendar.yearMonthFromFields", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; - -const expected = expectedMinimal.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateFromFields", - "get this.calendar.dateUntil", - "get this.calendar.fields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields / CalendarDateFromFields (receiver) - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - "call this.calendar.dateFromFields", - // PrepareTemporalFields / CalendarDateFromFields (argument) - "get other.calendar.monthCode", - "call other.calendar.monthCode", - "get other.calendar.year", - "call other.calendar.year", - "call this.calendar.dateFromFields", - // CalendarDateUntil - "call this.calendar.dateUntil", -]); const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, ownCalendar, 1); +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); const otherYearMonthPropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, month: 6, monthCode: "M06", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601", +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { - // order is significant, due to iterating through properties in order to - // copy them to an internal null-prototype object: roundingIncrement, roundingMode, largestUnit, @@ -118,55 +55,6 @@ function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", }, "options"); } -// clear any observable things that happened while constructing the objects -actual.splice(0); - -// code path that skips RoundDuration: instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 })); assert.compareArray(actual, expected, "order of operations with no rounding"); actual.splice(0); // clear - -// short-circuit for identical objects: -const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 5, - monthCode: "M05", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); - -instance.since(identicalPropertyBag, createOptionsObserver()); -assert.compareArray(actual, expectedMinimal, "order of operations with identical year-months"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest year: -const expectedOpsForYearRounding = expected.concat([ - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest year and skips a DateUntil call -const otherYearMonthPropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual, { - year: 2001, - month: 5, - monthCode: "M05", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); -const expectedOpsForYearRoundingSameMonth = expected.concat([ - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.since(otherYearMonthPropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest month: -const expectedOpsForMonthRounding = expected.concat([ - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", // BubbleRelativeDuration -]); -instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 2 })); -assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/proto-in-calendar-fields.js deleted file mode 100644 index dd597d4f8d6..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - -assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/rounding-zero-year-month-length.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/rounding-zero-year-month-length.js deleted file mode 100644 index 83e48ebe3db..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/since/rounding-zero-year-month-length.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.since -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const ym1 = new Temporal.PlainYearMonth(1970, 1, cal); -const ym2 = new Temporal.PlainYearMonth(1971, 1, cal); - -assert.throws(RangeError, () => ym1.since(ym2, { smallestUnit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => ym1.since(ym2, { smallestUnit: "months", roundingIncrement: 2 }), "zero month length handled correctly"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 18fb32df5d9..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.subtract(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments-extra-options.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments-extra-options.js deleted file mode 100644 index 931a89a0475..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments-extra-options.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: plainyearmonth.prototype.subtract should pass extra fields in copied options objects. -info: | - YearMonthFromFields ( calendar, fields [ , options ] ) - - 5. Let yearMonth be ? Invoke(calendar, "yearMonthFromFields", « fields, options »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.extra", - "get options.extra", - // Temporal.Calendar.prototype.dateAdd - "get options.overflow", - // overwriting property in custom calendar dateAdd - "getOwnPropertyDescriptor options.overflow", -]; -const options = TemporalHelpers.propertyBagObserver(actual, { extra: 5 }, "options"); - -let dateAddCalls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(date, duration, options) { - const result = super.dateAdd(date, duration, options); - dateAddCalls++; - if (dateAddCalls == 2) - options.overflow = 'meatloaf'; - return result; - } - yearMonthFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.notSameValue(args[1], options, "args[1]"); - return super.yearMonthFromFields(...args); - } -} -const plainYearMonth = new Temporal.PlainYearMonth(2000, 3, new CustomCalendar()); -const result = plainYearMonth.subtract({ months: 5 }, options); -TemporalHelpers.assertPlainYearMonth(result, 1999, 10, "M10"); -assert.compareArray(actual, expected, "extra field options object order of operations"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments.js deleted file mode 100644 index c8608a67d81..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-arguments.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: plainyearmonth.prototype.subtract should respect calendar arguments and pass copied options objects. -info: | - YearMonthFromFields ( calendar, fields [ , options ] ) - - 5. Let yearMonth be ? Invoke(calendar, "yearMonthFromFields", « fields, options »). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", - // Temporal.Calendar.prototype.dateAdd - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", - // overwriting property in custom calendar dateAdd - "getOwnPropertyDescriptor options.overflow", - // Temporal.Calendar.prototype.yearMonthFromFields (toPrimitiveObserver copied but not options object) - "get options.overflow.toString", - "call options.overflow.toString", -]; -const options = TemporalHelpers.propertyBagObserver(actual, { overflow: "constrain" }, "options"); - -let dateAddCalls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(date, duration, options) { - const result = super.dateAdd(date, duration, options); - dateAddCalls++; - if (dateAddCalls == 2) - options.overflow = 'meatloaf'; - return result; - } - yearMonthFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.notSameValue(args[1], options, "args[1]"); - return super.yearMonthFromFields(...args); - } -} -const plainYearMonth = new Temporal.PlainYearMonth(2000, 7, new CustomCalendar()); -const result = plainYearMonth.subtract({ months: 9 }, options); -TemporalHelpers.assertPlainYearMonth(result, 1999, 10, "M10"); -assert.compareArray(actual, expected, "copied options object order of operations"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-dateadd-called-with-plaindate-instance.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-dateadd-called-with-plaindate-instance.js deleted file mode 100644 index 6ebde0028eb..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-dateadd-called-with-plaindate-instance.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: Duration subtraction from PlainYearMonth calls Calendar.dateAdd the right number of times -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddPlainDateInstance(); -const instance = new Temporal.PlainYearMonth(1983, 3, calendar); -TemporalHelpers.assertPlainYearMonth(instance.subtract({weeks: 5}), 1983, 2, 'M02', "Removing 5 weeks from March in is8601 calendar") -assert.sameValue(calendar.dateAddCallCount, 2, "dateAdd called 2 times with positive subtract"); - -calendar.dateAddCallCount = 0; -TemporalHelpers.assertPlainYearMonth(instance.subtract({weeks: -5}), 1983, 4, 'M04', "Removing -5 weeks from March in is8601 calendar") -assert.sameValue(calendar.dateAddCallCount, 1, "dateAdd called once with negative subtract"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-dateadd.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-dateadd.js deleted file mode 100644 index 5219b3ab511..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-dateadd.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: PlainYearMonth.prototype.subtract should call dateAdd with the appropriate values. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(plainDate, duration, options) { - ++calls; - if (calls == 2) { - TemporalHelpers.assertPlainDate(plainDate, 2000, 3, "M03", 31, "plainDate argument"); - TemporalHelpers.assertDuration(duration, 0, -10, 0, 0, 0, 0, 0, 0, 0, 0, "duration argument"); - assert.sameValue(typeof options, "object", "options argument: type"); - assert.sameValue(Object.getPrototypeOf(options), null, "options argument: prototype"); - } - return super.dateAdd(plainDate, duration, options); - } -} - -const plainYearMonth = new Temporal.PlainYearMonth(2000, 3, new CustomCalendar()); -const result = plainYearMonth.subtract({ months: 10 }); -TemporalHelpers.assertPlainYearMonth(result, 1999, 5, "M05"); -assert.sameValue(calls, 2, "should have called dateAdd 2 times"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-datefromfields-called.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-datefromfields-called.js deleted file mode 100644 index 080c12eba8d..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-datefromfields-called.js +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: > - Calls calendar's dateFromFields method to obtain a start date for the - operation, based on the sign of the duration -info: | - 9. Let _fields_ be ? PrepareTemporalFields(_yearMonth_, _fieldNames_, «»). - 10. Let _sign_ be ! DurationSign(_duration_.[[Years]], _duration_.[[Months]], _duration_.[[Weeks]], _balanceResult_.[[Days]], 0, 0, 0, 0, 0, 0). - 11. If _sign_ < 0, then - a. Let _dayFromCalendar_ be ? CalendarDaysInMonth(_calendar_, _yearMonth_). - b. Let _day_ be ? ToPositiveInteger(_dayFromCalendar_). - 12. Else, - a. Let _day_ be 1. - 13. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, _day_). - 14. Let _date_ be ? DateFromFields(_calendar_, _fields_, *undefined*). -includes: [deepEqual.js, temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.dateFromFieldsCalls = []; - } - year(date) { - // years in this calendar start and end on the same day as ISO 8601 years - return date.getISOFields().isoYear; - } - month(date) { - // this calendar has 10 months of 36 days each, plus an 11th month of 5 or 6 - const { isoYear, isoMonth, isoDay } = date.getISOFields(); - const isoDate = new Temporal.PlainDate(isoYear, isoMonth, isoDay); - return Math.floor((isoDate.dayOfYear - 1) / 36) + 1; - } - monthCode(date) { - return "M" + this.month(date).toString().padStart(2, "0"); - } - day(date) { - return (date.dayOfYear - 1) % 36 + 1; - } - daysInMonth(date) { - if (this.month(date) < 11) return 36; - return this.daysInYear(date) - 360; - } - _dateFromFieldsImpl({ year, month, monthCode, day }) { - if (year === undefined) throw new TypeError("year required"); - if (month === undefined && monthCode === undefined) throw new TypeError("one of month or monthCode required"); - if (month !== undefined && month < 1) throw new RangeError("month < 1"); - if (day === undefined) throw new TypeError("day required"); - - if (monthCode !== undefined) { - const numberPart = +(monthCode.slice(1)); - if ("M" + `${numberPart}`.padStart(2, "0") !== monthCode) throw new RangeError("invalid monthCode"); - if (month === undefined) { - month = numberPart; - } else if (month !== numberPart) { - throw new RangeError("month and monthCode must match"); - } - } - - const isoDayOfYear = (month - 1) * 36 + day; - return new Temporal.PlainDate(year, 1, 1).add({ days: isoDayOfYear - 1 }).withCalendar(this); - } - dateFromFields(...args) { - this.dateFromFieldsCalls.push(args); - return this._dateFromFieldsImpl(...args); - } - yearMonthFromFields(fields, options) { - const { isoYear, isoMonth, isoDay } = this._dateFromFieldsImpl({ ...fields, day: 1 }, options).getISOFields(); - return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); - } - monthDayFromFields(fields, options) { - const { isoYear, isoMonth, isoDay } = this._dateFromFieldsImpl({ ...fields, year: 2000 }, options).getISOFields(); - return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); - } - dateAdd(date, duration, options) { - const {isoYear, isoMonth, isoDay} = date.getISOFields(); - let {years, months, weeks, days} = duration; - let iter = new Temporal.PlainDate(isoYear + years, isoMonth, isoDay, "iso8601"); - const monthsDays = months * 36; - if (iter.dayOfYear + monthsDays > iter.daysInYear || iter.dayOfYear + monthsDays < 1) - throw new Error("complicated addition not implemented in this test"); - return iter.add({ weeks, days: monthsDays + days }).withCalendar(this); - } - toString() { - return "thirty-six"; - } -} - -const calendar = new CustomCalendar(); -const month2 = Temporal.PlainYearMonth.from({ year: 2022, month: 2, calendar }); -const lessThanOneMonth = new Temporal.Duration(0, 0, 0, 35); -const oneMonth = new Temporal.Duration(0, 0, 0, 36); - -// Reference ISO dates in the custom calendar: -// M01 = 01-01 -// M02 = 02-06 -// M03 = 03-14 - -calendar.dateFromFieldsCalls = []; -TemporalHelpers.assertPlainYearMonth( - month2.subtract(lessThanOneMonth), - 2022, 2, "M02", - "subtracting positive less than one month's worth of days yields the same month", - /* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 6 -); -assert.sameValue(calendar.dateFromFieldsCalls.length, 2, "dateFromFields was called twice"); -assert.deepEqual( - calendar.dateFromFieldsCalls[1][0], - { year: 2022, monthCode: "M02", day: 36 }, - "last day of month 2 passed to dateFromFields when subtracting positive duration" -); -assert.sameValue(calendar.dateFromFieldsCalls[0][1], undefined, "undefined options passed"); - -calendar.dateFromFieldsCalls = []; -TemporalHelpers.assertPlainYearMonth( - month2.subtract(oneMonth), - 2022, 1, "M01", - "subtracting positive one month's worth of days yields the previous month", - /* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 1 -); -assert.sameValue(calendar.dateFromFieldsCalls.length, 2, "dateFromFields was called twice"); -assert.deepEqual( - calendar.dateFromFieldsCalls[1][0], - { year: 2022, monthCode: "M02", day: 36 }, - "last day of month 2 passed to dateFromFields when subtracting positive duration" -); -assert.sameValue(calendar.dateFromFieldsCalls[0][1], undefined, "undefined options passed"); - -calendar.dateFromFieldsCalls = []; -TemporalHelpers.assertPlainYearMonth( - month2.subtract(lessThanOneMonth.negated()), - 2022, 2, "M02", - "subtracting negative less than one month's worth of days yields the same month", - /* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 6 -); -assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called"); -assert.deepEqual( - calendar.dateFromFieldsCalls[0][0], - { year: 2022, monthCode: "M02", day: 1 }, - "first day of month 2 passed to dateFromFields when subtracting negative duration" -); -assert.sameValue(calendar.dateFromFieldsCalls[0][1], undefined, "undefined options passed"); - -calendar.dateFromFieldsCalls = []; -TemporalHelpers.assertPlainYearMonth( - month2.subtract(oneMonth.negated()), - 2022, 3, "M03", - "subtracting negative one month's worth of days yields the following month", - /* era = */ undefined, /* eraYear = */ undefined, /* referenceISODay = */ 14 -); -assert.sameValue(calendar.dateFromFieldsCalls.length, 1, "dateFromFields was called"); -assert.deepEqual( - calendar.dateFromFieldsCalls[0][0], - { year: 2022, monthCode: "M02", day: 1 }, - "first day of month 2 passed to dateFromFields when subtracting negative duration" -); -assert.sameValue(calendar.dateFromFieldsCalls[0][1], undefined, "undefined options passed"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-fields-iterable.js deleted file mode 100644 index 8329c5b6f58..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-fields-iterable.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainyearmonth.prototype.subtract step 8: - 8. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar); -yearmonth.subtract({ months: 1 }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 885716b52a0..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.subtract(new Temporal.Duration(1)); -assert.sameValue(calendar.dateFromFieldsCallCount, 2, "dateFromFields should have been called twice on the calendar"); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-yearmonthfromfields-called-with-null-prototype-options.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-yearmonthfromfields-called-with-null-prototype-options.js deleted file mode 100644 index 6cef4aa2b1e..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-yearmonthfromfields-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: > - Calendar.yearMonthFromFields method is called with a null-prototype object - as the options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2019, 6, calendar); -const argument = new Temporal.Duration(1, 1); -instance.subtract(argument); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should be called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/constructor-in-calendar-fields.js deleted file mode 100644 index fe1ddcc8d77..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - -assert.throws(RangeError, () => ym.subtract({days: 123})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/custom-daysInMonth-irrelevant.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/custom-daysInMonth-irrelevant.js deleted file mode 100644 index 147fa5fa384..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/custom-daysInMonth-irrelevant.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: Subtraction of positive duration to a PlainYearMonth is not influenced by the implementation of daysInMonth() -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInMonth(ym, ...args) { - return 15; - } -} - -const customCalendar = new CustomCalendar(); -const instance = new Temporal.PlainYearMonth(2023, 3, customCalendar); - -TemporalHelpers.assertPlainYearMonth(instance.subtract({days: 30}), 2023, 3, 'M03', "Subtracting 30 days from calendar reimplementing daysinMonth()") diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/duplicate-calendar-fields.js deleted file mode 100644 index bcbbdd57cdc..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - - assert.throws(RangeError, () => ym.subtract({days: 123})); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/end-of-month-out-of-range.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/end-of-month-out-of-range.js index 36117a5b454..935ee2efd4e 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/end-of-month-out-of-range.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/end-of-month-out-of-range.js @@ -20,11 +20,3 @@ const duration = new Temporal.Duration(0, 0, 0, 1); // Calendar addition result is out of range assert.throws(RangeError, () => new Temporal.PlainYearMonth(275760, 9).subtract(duration), "Addition of 1 month to receiver out of range"); - -// Calendar addition succeeds, but subtracting 1 day gives out of range result -const cal = new class extends Temporal.Calendar { - dateAdd() { - return new Temporal.PlainDate(-271821, 4, 19); - } -}("iso8601"); -assert.throws(RangeError, () => new Temporal.PlainYearMonth(2000, 1, cal).subtract(duration), "Subtraction of 1 day from next month out of range"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-undefined.js deleted file mode 100644 index b0cf9bd9d4b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/options-undefined.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: Verify that undefined options are handled correctly. -features: [Temporal] ----*/ - -// overflow option has no effect on addition in the ISO calendar, so verify this -// with a custom calendar -class CheckedAdd extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.called = 0; - } - dateAdd(date, duration, options, constructor) { - this.called += 1; - if (this.called == 2) - assert.notSameValue(options, undefined, "options not undefined"); - return super.dateAdd(date, duration, options, constructor); - } -} -const calendar = new CheckedAdd(); - -const yearmonth = new Temporal.PlainYearMonth(2000, 3, calendar); -const duration = { months: 1 }; - -yearmonth.subtract(duration, undefined); -assert.sameValue(calendar.called, 2, "dateAdd should have been called twice"); - -calendar.called = 0; -yearmonth.subtract(duration); -assert.sameValue(calendar.called, 2, "dateAdd should have been called twice"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js index e1138a853d2..b376925ae6c 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/order-of-operations.js @@ -40,51 +40,13 @@ const expected = [ "get fields.years", "get fields.years.valueOf", "call fields.years.valueOf", - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateFromFields", - "get this.calendar.day", - "get this.calendar.fields", - "get this.calendar.yearMonthFromFields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields on receiver - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - // calculate last day of month - "call this.calendar.dateFromFields", - "call this.calendar.dateAdd", - "call this.calendar.day", - "call this.calendar.dateFromFields", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", - // CalendarDateAdd - "call this.calendar.dateAdd", - // inside Calendar.p.dateAdd - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", - // PrepareTemporalFields on added date - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - // CalendarYearMonthFromFields - "call this.calendar.yearMonthFromFields", - // inside Calendar.p.yearMonthFromFields "get options.overflow.toString", "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601"); const fields = TemporalHelpers.propertyBagObserver(actual, { years: 1, @@ -105,83 +67,3 @@ instance.subtract(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -const noCalendarExpected = [ - // ToTemporalDuration - "get fields.days", - "get fields.days.valueOf", - "call fields.days.valueOf", - "get fields.hours", - "get fields.hours.valueOf", - "call fields.hours.valueOf", - "get fields.microseconds", - "get fields.microseconds.valueOf", - "call fields.microseconds.valueOf", - "get fields.milliseconds", - "get fields.milliseconds.valueOf", - "call fields.milliseconds.valueOf", - "get fields.minutes", - "get fields.minutes.valueOf", - "call fields.minutes.valueOf", - "get fields.months", - "get fields.nanoseconds", - "get fields.nanoseconds.valueOf", - "call fields.nanoseconds.valueOf", - "get fields.seconds", - "get fields.seconds.valueOf", - "call fields.seconds.valueOf", - "get fields.weeks", - "get fields.years", - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateFromFields", - "get this.calendar.day", - "get this.calendar.fields", - "get this.calendar.yearMonthFromFields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields on receiver - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - // CalendarDateFromFields - "call this.calendar.dateFromFields", - // calculate last day of month - "call this.calendar.dateAdd", - "call this.calendar.day", - "call this.calendar.dateFromFields", - // SnapshotOwnProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", - // AddDate - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", - // PrepareTemporalFields on added date - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - // CalendarYearMonthFromFields - "call this.calendar.yearMonthFromFields", - // inside Calendar.p.yearMonthFromFields - "get options.overflow.toString", - "call options.overflow.toString", -]; - -const noCalendarFields = TemporalHelpers.propertyBagObserver(actual, { - days: 1, - hours: 1, - minutes: 1, - seconds: 1, - milliseconds: 1, - microseconds: 1, - nanoseconds: 1, -}, "fields"); - -instance.subtract(noCalendarFields, options); -assert.compareArray(actual, noCalendarExpected, "order of operations with no calendar units"); - -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/overflow-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/overflow-wrong-type.js index f683dfbd4c1..1d0bfdc326f 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/overflow-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/overflow-wrong-type.js @@ -33,13 +33,9 @@ assert.throws(RangeError, () => yearmonth.subtract(duration, { overflow: 2 }), " assert.throws(RangeError, () => yearmonth.subtract(duration, { overflow: 2n }), "bigint"); assert.throws(RangeError, () => yearmonth.subtract(duration, { overflow: {} }), "plain object"); -// toString property is read once by Calendar.dateAdd() and then once again by -// calendar.yearMonthFromFields(). const expected = [ "get overflow.toString", "call overflow.toString", - "get overflow.toString", - "call overflow.toString", ]; const actual = []; const observer = TemporalHelpers.toPrimitiveObserver(actual, "constrain", "overflow"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/proto-in-calendar-fields.js deleted file mode 100644 index a18f5a7c211..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.subtract -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - -assert.throws(RangeError, () => ym.subtract({days: 123})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toJSON/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 88557a40b87..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toJSON/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.tojson -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.toJSON(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toLocaleString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 474e4ce5bd7..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toLocaleString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.tolocalestring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.toLocaleString(undefined, { calendar: "iso8601" }); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/argument-not-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/argument-not-object.js index 16c1e063404..eb3860c8b71 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/argument-not-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/argument-not-object.js @@ -3,13 +3,11 @@ /*--- esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: Throws a TypeError if the argument is not an Object, before any other observable actions -includes: [compareArray.js, temporalHelpers.js] +description: Throws a TypeError if the argument is not an Object features: [BigInt, Symbol, Temporal] ---*/ [null, undefined, true, 3.1416, "a string", Symbol("symbol"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarThrowEverything(); - const plainYearMonth = new Temporal.PlainYearMonth(2000, 5, calendar); + const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); assert.throws(TypeError, () => plainYearMonth.toPlainDate(primitive)); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 654196318c6..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainYearMonth(2023, 5, "iso8601"); -instance.toPlainDate({ day: 5 }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 027fe0baf97..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); - }, -}); -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.toPlainDate({ day: 12 }); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fields-iterable.js deleted file mode 100644 index 7d990bf231c..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fields-iterable.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainyearmonth.prototype.toplaindate step 5: - 5. Let _receiverFieldNames_ be ? CalendarFields(_calendar_, « *"monthCode"*, *"year"* »). - sec-temporal.plainyearmonth.prototype.toplaindate step 7: - 7. Let _inputFieldNames_ be ? CalendarFields(_calendar_, « *"day"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected1 = [ - "monthCode", - "year", -]; -const expected2 = [ - "day", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar); -yearmonth.toPlainDate({ day: 15 }); - -assert.sameValue(calendar.fieldsCallCount, 2, "fields() method called twice"); -assert.compareArray(calendar.fieldsCalledWith[0], expected1, "fields() method called first time with correct args"); -assert.compareArray(calendar.fieldsCalledWith[1], expected2, "fields() method called second time with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole first iterable"); -assert(calendar.iteratorExhausted[1], "iterated through the whole second iterable"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 7bb1b1886c1..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.toPlainDate({ day: 24 }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js deleted file mode 100644 index 2b3f8fc8bf9..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fromfields-called-with-undefined-options.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: Calendar.dateFromFields method is called with undefined options -features: [Temporal] ----*/ - -let count = 0; - -const calendar = new class extends Temporal.Calendar { - dateFromFields(fields, options) { - count++; - assert.sameValue(options, undefined, "dateFromFields should be called with undefined options"); - return super.dateFromFields(fields, options); - } -}("iso8601"); - -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.toPlainDate({ day: 24 }); -assert.sameValue(count, 1, "dateFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-merge-fields-returns-primitive.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-merge-fields-returns-primitive.js deleted file mode 100644 index 0b083aaab02..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-merge-fields-returns-primitive.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: > - with() should throw a TypeError if mergeFields() returns a primitive, - without passing the value on to any other calendar methods -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Symbol, Temporal] ----*/ - -[undefined, null, true, 3.14159, "bad value", Symbol("no"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarMergeFieldsReturnsPrimitive(primitive); - const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - assert.throws(TypeError, () => instance.toPlainDate({ day: 2 }), "bad return from mergeFields() throws"); - assert.sameValue(calendar.dateFromFieldsCallCount, 0, "dateFromFields() never called"); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-mergefields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-mergefields-called-with-null-prototype-fields.js deleted file mode 100644 index 2b4f8fd901e..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-mergefields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: > - Calendar.mergeFields method is called with null-prototype fields objects -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckMergeFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.toPlainDate({ day: 24 }); -assert.sameValue(calendar.mergeFieldsCallCount, 1, "mergeFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/constructor-in-calendar-fields.js deleted file mode 100644 index b7eea31a283..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - -assert.throws(RangeError, () => ym.toPlainDate({day: 1})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/copies-merge-fields-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/copies-merge-fields-object.js deleted file mode 100644 index a8073321a9e..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/copies-merge-fields-object.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: The object returned from mergeFields() is copied before being passed to monthDayFromFields(). -info: | - sec-temporal.plainyearmonth.prototype.toplaindate steps 9 and 11: - 9. Let _mergedFields_ be ? CalendarMergeFields(_calendar_, _fields_, _inputFields_). - 11. Set _mergedFields_ to ? PrepareTemporalFields(_mergedFields_, _mergedFieldNames_, «»). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get day", - "get day.valueOf", - "call day.valueOf", - "get monthCode", - "get monthCode.toString", - "call monthCode.toString", - "get year", - "get year.valueOf", - "call year.valueOf", -]; - -const calendar = TemporalHelpers.calendarMergeFieldsGetters(); -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar); -yearmonth.toPlainDate({ day: 2 }); - -assert.compareArray(calendar.mergeFieldsReturnOperations, expected, "getters called on mergeFields return"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/duplicate-calendar-fields.js deleted file mode 100644 index 3e79b3a69d8..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['year'], ['day']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - - assert.throws(RangeError, () => ym.toPlainDate({day: 1})); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/proto-in-calendar-fields.js deleted file mode 100644 index efbf50d20ae..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.toplaindate -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - -assert.throws(RangeError, () => ym.toPlainDate({day: 1})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index e4b908dea57..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.tostring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.toString(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js deleted file mode 100644 index da23c65c5eb..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendar-tostring.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.protoype.tostring -description: Number of observable 'toString' calls on the calendar for each value of calendarName -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls; -const customCalendar = { - get id() { - ++calls; - return "custom"; - }, - toString() { - TemporalHelpers.assertUnreachable('toString should not be called'); - }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const yearmonth = new Temporal.PlainYearMonth(2000, 5, customCalendar); -[ - ["always", "2000-05-01[u-ca=custom]", 1], - ["auto", "2000-05-01[u-ca=custom]", 1], - ["critical", "2000-05-01[!u-ca=custom]", 1], - ["never", "2000-05-01", 1], - [undefined, "2000-05-01[u-ca=custom]", 1], -].forEach(([calendarName, expectedResult, expectedCalls]) => { - calls = 0; - const result = yearmonth.toString({ calendarName }); - assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js index 9aaf7f0d76f..e9fb1a7a1f5 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js @@ -7,39 +7,6 @@ description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05-01[u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-01[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05-01[u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-01[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-01[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); - const result = yearmonth.toString({ calendarName: "always" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = always`); -} +const yearmonth = new Temporal.PlainYearMonth(2000, 5); +const result = yearmonth.toString({ calendarName: "always" }); +assert.sameValue(result, "2000-05-01[u-ca=iso8601]", `built-in ISO calendar for calendarName = always`); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js index c940f67815e..a26310c7647 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js @@ -7,39 +7,6 @@ description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-01[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-01[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-01[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); - const result = yearmonth.toString({ calendarName: "auto" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); -} +const yearmonth = new Temporal.PlainYearMonth(2000, 5); +const result = yearmonth.toString({ calendarName: "auto" }); +assert.sameValue(result, "2000-05", `built-in ISO calendar for calendarName = auto`); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js index cc4aeaea3a0..864845d745a 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js @@ -9,39 +9,6 @@ description: > features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05-01[!u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-01[!u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05-01[!u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-01[!u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-01[!u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); - const result = yearmonth.toString({ calendarName: "critical" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); -} +const yearmonth = new Temporal.PlainYearMonth(2000, 5); +const result = yearmonth.toString({ calendarName: "critical" }); +assert.sameValue(result, "2000-05-01[!u-ca=iso8601]", `built-in ISO calendar for calendarName = critical`); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js index 9bfe45ec12a..57f8b5c0f5d 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js @@ -7,39 +7,6 @@ description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-01", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-01", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-01", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); - const result = yearmonth.toString({ calendarName: "never" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = never`); -} +const yearmonth = new Temporal.PlainYearMonth(2000, 5); +const result = yearmonth.toString({ calendarName: "never" }); +assert.sameValue(result, "2000-05", `built-in ISO calendar for calendarName = never`); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js index a8d9717eadf..33886ab4be0 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js @@ -14,40 +14,7 @@ info: | features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "2000-05", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "2000-05-01[u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "2000-05", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "2000-05-01[u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "2000-05-01[u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); - const result = yearmonth.toString({ calendarName: undefined }); - assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); - // See options-object.js for {} and options-undefined.js for absent options arg -} +const yearmonth = new Temporal.PlainYearMonth(2000, 5); +const result = yearmonth.toString({ calendarName: undefined }); +assert.sameValue(result, "2000-05", `default calendarName option is auto with built-in ISO calendar`); +// See options-object.js for {} and options-undefined.js for absent options arg diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js index df91dd657ca..e72752f4fcc 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js @@ -15,32 +15,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const calendar = { - id: "custom", - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar); +const yearmonth = new Temporal.PlainYearMonth(2000, 5, "iso8601"); TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", (calendarName) => yearmonth.toString({ calendarName }), - (result, descr) => assert.sameValue(result, "2000-05-01[u-ca=custom]", descr), + (result, descr) => assert.sameValue(result, "2000-05", descr), ); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-undefined.js deleted file mode 100644 index c84712f2e6c..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/options-undefined.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.tostring -description: Verify that undefined options are handled correctly. -features: [Temporal] ----*/ - -const calendar = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "custom", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const yearmonth1 = new Temporal.PlainYearMonth(2000, 5); -const yearmonth2 = new Temporal.PlainYearMonth(2000, 5, calendar); - -[ - [yearmonth1, "2000-05"], - [yearmonth2, "2000-05-01[u-ca=custom]"], -].forEach(([yearmonth, expected]) => { - const explicit = yearmonth.toString(undefined); - assert.sameValue(explicit, expected, "default calendarName option is auto"); - - const implicit = yearmonth.toString(); - assert.sameValue(implicit, expected, "default calendarName option is auto"); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js index 95bcf3ff942..46d68db9106 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toString/order-of-operations.js @@ -12,14 +12,10 @@ const expected = [ "get options.calendarName", "get options.calendarName.toString", "call options.calendarName.toString", - "get this.calendar.id", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainYearMonth(2000, 5); const options = TemporalHelpers.propertyBagObserver(actual, { calendarName: "auto", diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index d28f97d9399..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainYearMonth(2000, 5); -const arg = { year: 2000, month: 5, calendar: "iso8601" }; -instance.until(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-wrong-type.js index e26fb728206..d60b9a93caf 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.plainyearmonth.prototype.until description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.PlainYearMonth(2000, 5); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 2ae40e13b7d..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainYearMonth(2023, 5, "iso8601"); -instance.until({ year: 2070, month: 7 }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 8fd95fd4562..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.until(new Temporal.PlainYearMonth(2001, 6)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateadd-called-with-plaindate-instance.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateadd-called-with-plaindate-instance.js deleted file mode 100644 index c5d0d531a0b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateadd-called-with-plaindate-instance.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - relativeTo parameters that are not ZonedDateTime or undefined, are always - converted to PlainDate for observable calendar calls -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddPlainDateInstance(); -const instance = new Temporal.PlainYearMonth(1970, 1, calendar); -instance.until(new Temporal.PlainYearMonth(2000, 5, calendar), { smallestUnit: "year" }); -assert(calendar.dateAddCallCount > 0, "assertions in calendar.dateAdd() should have been tested"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 83f4bd923b9..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - Calendar.yearMonthFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5); -const arg = { year: 2000, month: 5, calendar }; -instance.until(arg); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-datefromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index 6e35238feb6..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.until({ year: 2000, month: 6, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 2); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js deleted file mode 100644 index ad7f59ee327..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - Calendar.dateUntil method is called with a null-prototype object as the - options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -const argument = new Temporal.PlainYearMonth(2022, 6, calendar); -instance.until(argument); -assert.sameValue(calendar.dateUntilCallCount, 1, "dateUntil should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index 33e4f9bdf4a..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: The options object passed to calendar.dateUntil has a largestUnit property with its value in the singular form -info: | - sec-temporal.plainyearmonth.prototype.until steps 20–21: - 20. Let _untilOptions_ be ? MergeLargestUnitOption(_options_, _largestUnit_). - 21. Let _result_ be ? CalendarDateUntil(_calendar_, _thisDate_, _otherDate_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.PlainYearMonth(2000, 5, calendar); - const later = new Temporal.PlainYearMonth(2001, 6, calendar); - earlier.until(later, { largestUnit }); - }, - { - years: ["year"], - months: ["month"] - } -); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-fields-iterable.js deleted file mode 100644 index e40c6d78bca..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-fields-iterable.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainyearmonth.prototype.until step 3: - 3. Set _other_ to ? ToTemporalYearMonth(_other_). - sec-temporal.plainyearmonth.prototype.until step 13: - 13. Let fieldNames be ? CalendarFields(_calendar_, « *"monthCode"*, *"year"* »). - sec-temporal-totemporalyearmonth step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected1 = [ - "monthCode", - "year", -]; -const expected2 = [ - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -yearmonth.until({ year: 2005, month: 6, calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 1, "fields() method not called"); -assert.compareArray(calendar1.fieldsCalledWith[0], expected1, "fields() method called with correct args"); -assert(calendar1.iteratorExhausted[0], "iterated through the whole iterable"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected2, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 7e71f6f8b0b..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.until(new Temporal.PlainYearMonth(2019, 2)); -assert.sameValue(calendar.dateFromFieldsCallCount, 2, "dateFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-temporal-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-temporal-object.js index be28ad212b4..59e2a8652e4 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-temporal-object.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const yearmonth = new Temporal.PlainYearMonth(2000, 5, temporalObject); + const yearmonth = new Temporal.PlainYearMonth(2000, 5); yearmonth.until({ year: 2005, month: 6, calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-yearmonthfromfields-called-with-options-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-yearmonthfromfields-called-with-options-undefined.js deleted file mode 100644 index 5b2ac6578ad..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-yearmonthfromfields-called-with-options-undefined.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - Calendar.yearMonthFromFields method is called with undefined as the options - value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -let instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.until({ year: 2000, month: 6, calendar }); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/constructor-in-calendar-fields.js deleted file mode 100644 index 7129de812d2..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - -assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/duplicate-calendar-fields.js deleted file mode 100644 index b1e6e75d141..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - - assert.throws(RangeError, () => instance.until(arg)); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js deleted file mode 100644 index 653542e7815..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: Mixed calendars throw as invalid -features: [Temporal] ----*/ - -class customCal extends Temporal.Calendar { - constructor () { - super('iso8601'); - } - - get id() { - return "I am a secret cal."; - } -} - -const ym1 = new Temporal.PlainYearMonth(2000, 1); -const ym2 = new Temporal.PlainYearMonth(2000, 1, new customCal()); - -assert.throws(RangeError, () => ym1.until(ym2), 'until throws with different calendars'); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js index a3d80845847..fc2859e16a5 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/order-of-operations.js @@ -8,33 +8,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const expectedMinimal = [ +const expected = [ // ToTemporalYearMonth "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.fields", - "get other.calendar.yearMonthFromFields", - "call other.calendar.fields", "get other.month", "get other.month.valueOf", "call other.month.valueOf", @@ -44,72 +20,33 @@ const expectedMinimal = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", - "call other.calendar.yearMonthFromFields", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; - -const expected = expectedMinimal.concat([ - // lookup - "get this.calendar.dateAdd", - "get this.calendar.dateFromFields", - "get this.calendar.dateUntil", - "get this.calendar.fields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields / CalendarDateFromFields (receiver) - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", - "call this.calendar.dateFromFields", - // PrepareTemporalFields / CalendarDateFromFields (argument) - "get other.calendar.monthCode", - "call other.calendar.monthCode", - "get other.calendar.year", - "call other.calendar.year", - "call this.calendar.dateFromFields", - // CalendarDateUntil - "call this.calendar.dateUntil", -]); const actual = []; -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, ownCalendar, 1); +const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); const otherYearMonthPropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2001, month: 6, monthCode: "M06", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); + calendar: "iso8601" +}, "other", ["calendar"]); function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { - // order is significant, due to iterating through properties in order to - // copy them to an internal null-prototype object: roundingIncrement, roundingMode, largestUnit, @@ -118,56 +55,5 @@ function createOptionsObserver({ smallestUnit = "months", largestUnit = "auto", }, "options"); } -// clear any observable things that happened while constructing the objects -actual.splice(0); - -// code path that skips RoundDuration: -instance.since(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 })); -assert.compareArray(actual, expected, "order of operations with no rounding"); -actual.splice(0); // clear - -// short-circuit for identical objects: -const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 5, - monthCode: "M05", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); - -instance.until(identicalPropertyBag, createOptionsObserver()); -assert.compareArray(actual, expectedMinimal, "order of operations with identical year-months"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest year: -const expectedOpsForYearRounding = expected.concat([ - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRounding, "order of operations with smallestUnit = years"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest year and skips a DateUntil call -const otherYearMonthPropertyBagSameMonth = TemporalHelpers.propertyBagObserver(actual, { - year: 2001, - month: 5, - monthCode: "M05", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), -}, "other"); -const expectedOpsForYearRoundingSameMonth = expected.concat([ - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", -]); -instance.until(otherYearMonthPropertyBagSameMonth, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForYearRoundingSameMonth, "order of operations with smallestUnit = years and no excess months"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest month: -const expectedOpsForMonthRounding = expected.concat([ - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", // BubbleRelativeDuration -]); -instance.until(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 2 })); -assert.compareArray(actual, expectedOpsForMonthRounding, "order of operations with smallestUnit = months"); -actual.splice(0); // clear +instance.until(otherYearMonthPropertyBag, createOptionsObserver({ smallestUnit: "months", roundingIncrement: 1 })); +assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/proto-in-calendar-fields.js deleted file mode 100644 index 6714dcc2cb5..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - -assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/rounding-zero-year-month-length.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/rounding-zero-year-month-length.js deleted file mode 100644 index 7d35c8a8965..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/until/rounding-zero-year-month-length.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.until -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const ym1 = new Temporal.PlainYearMonth(1970, 1, cal); -const ym2 = new Temporal.PlainYearMonth(1971, 1, cal); - -assert.throws(RangeError, () => ym1.until(ym2, { smallestUnit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => ym1.until(ym2, { smallestUnit: "months", roundingIncrement: 2 }), "zero month length handled correctly"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/basic.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/basic.js index 7d49806ea6a..ff59ced1529 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/basic.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/basic.js @@ -19,5 +19,5 @@ TemporalHelpers.assertPlainYearMonth(ym.with({ month: 1, years: 2020 }), 2019, 1 const withDay = ym.with({ year: 2019, get day() { throw new Test262Error("should not read the day property") } }); TemporalHelpers.assertPlainYearMonth(withDay, 2019, 10, "M10", "day property"); -assert.sameValue(withDay.getISOFields().isoDay, 1); - +const isoDay = Number(withDay.toString({ calendarName: "always" }).split("-")[2].slice(0, 2)); +assert.sameValue(isoDay, 1); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 443c9b62ae0..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.PlainYearMonth(2023, 5, "iso8601"); -instance.with({ month: 4 }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 98da4da7c95..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); - }, -}); -const yearMonthFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearMonthFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("yearMonthFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.with({ year: 2001 }); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "yearMonthFromFields", yearMonthFromFieldsOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-arguments.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-arguments.js deleted file mode 100644 index 9ec110eeaeb..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-arguments.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: Correct options value is passed to calendar method -info: | - YearMonthFromFields ( calendar, fields [ , options ] ) - - 5. Let yearMonth be ? Invoke(calendar, "yearMonthFromFields", « fields, options »). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const options = { - extra: "property", -}; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearMonthFromFields(...args) { - assert.sameValue(args.length, 2, "args.length"); - assert.sameValue(typeof args[0], "object", "args[0]"); - assert.notSameValue(args[1], options, "args[1] is a copy of options"); - assert.sameValue(args[1].extra, "property", "All properties are copied"); - assert.sameValue(Object.getPrototypeOf(args[1]), null, "Copy has null prototype"); - return super.yearMonthFromFields(...args); - } -} -const plainYearMonth = new Temporal.PlainYearMonth(2000, 7, new CustomCalendar()); -const result = plainYearMonth.with({ month: 5 }, options); -TemporalHelpers.assertPlainYearMonth(result, 2000, 5, "M05"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-fields-iterable.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-fields-iterable.js deleted file mode 100644 index 1c5fcb20c48..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-fields-iterable.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.plainyearmonth.prototype.with step 9: - 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar); -yearmonth.with({ year: 2005 }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 3e842c54fda..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: > - Calendar.yearMonthFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.with({ year: 2019 }); -assert.sameValue(calendar.yearMonthFromFieldsCallCount, 1, "yearMonthFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-merge-fields-returns-primitive.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-merge-fields-returns-primitive.js deleted file mode 100644 index 1139d27ee0c..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-merge-fields-returns-primitive.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: > - with() should throw a TypeError if mergeFields() returns a primitive, - without passing the value on to any other calendar methods -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Symbol, Temporal] ----*/ - -[undefined, null, true, 3.14159, "bad value", Symbol("no"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarMergeFieldsReturnsPrimitive(primitive); - const instance = new Temporal.PlainYearMonth(2000, 5, calendar); - assert.throws(TypeError, () => instance.with({ year: 2005 }), "bad return from mergeFields() throws"); - assert.sameValue(calendar.yearMonthFromFieldsCallCount, 0, "yearMonthFromFields() never called"); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js deleted file mode 100644 index 96b5e994669..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: > - Calendar.mergeFields method is called with null-prototype fields objects -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckMergeFieldsPrototypePollution(); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -instance.with({ year: 2019 }); -assert.sameValue(calendar.mergeFieldsCallCount, 1, "mergeFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/constructor-in-calendar-fields.js deleted file mode 100644 index 18f1e5591a1..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - -assert.throws(RangeError, () => ym.with({month: 1})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/copies-merge-fields-object.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/copies-merge-fields-object.js deleted file mode 100644 index 7cad0926d88..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/copies-merge-fields-object.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: The object returned from mergeFields() is copied before being passed to monthDayFromFields(). -info: | - sec-temporal.plainyearmonth.prototype.with steps 13–15: - 13. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialYearMonth_). - 14. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, «»). - 15. Return ? YearMonthFromFields(_calendar_, _fields_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get month", - "get month.valueOf", - "call month.valueOf", - "get monthCode", - "get monthCode.toString", - "call monthCode.toString", - "get year", - "get year.valueOf", - "call year.valueOf", -]; - -const calendar = TemporalHelpers.calendarMergeFieldsGetters(); -const yearmonth = new Temporal.PlainYearMonth(2000, 5, calendar); -yearmonth.with({ year: 2004 }); - -assert.compareArray(calendar.mergeFieldsReturnOperations, expected, "getters called on mergeFields return"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/duplicate-calendar-fields.js deleted file mode 100644 index 7acea421728..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['month'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - - assert.throws(RangeError, () => ym.with({month: 1})); -} diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/order-of-operations.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/order-of-operations.js index d3fb7ece3db..cc8c6b6e611 100644 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/order-of-operations.js @@ -13,24 +13,9 @@ const expected = [ "get fields.calendar", "get fields.timeZone", // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", "get options.overflow", - "getOwnPropertyDescriptor options.extra", - "get options.extra", - // lookup - "get this.calendar.fields", - "get this.calendar.mergeFields", - "get this.calendar.yearMonthFromFields", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields on receiver - "get this.calendar.month", - "call this.calendar.month", - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", + "get options.overflow.toString", + "call options.overflow.toString", // PrepareTemporalFields on argument "get fields.month", "get fields.month.valueOf", @@ -41,20 +26,10 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", - // CalendarMergeFields - "call this.calendar.mergeFields", - // CalendarYearMonthFromFields - "call this.calendar.yearMonthFromFields", - // inside Calendar.p.yearMonthFromFields - "get options.overflow.toString", - "call options.overflow.toString", ]; const actual = []; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.PlainYearMonth(2000, 5, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.PlainYearMonth(2000, 5); const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7, diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/proto-in-calendar-fields.js deleted file mode 100644 index cace4f11fa4..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/with/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.plainyearmonth.prototype.with -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const ym = new Temporal.PlainYearMonth(2023, 5, calendar); - -assert.throws(RangeError, () => ym.with({month: 1})); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/year/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/PlainYearMonth/prototype/year/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 78ac7725c4c..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/year/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plainyearmonth.prototype.year -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const yearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "year"); -Object.defineProperty(Temporal.Calendar.prototype, "year", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("year should not be looked up"); - }, -}); - -const instance = new Temporal.PlainYearMonth(2000, 5, "iso8601", 1); -instance.year; - -Object.defineProperty(Temporal.Calendar.prototype, "year", yearOriginal); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/year/custom.js b/test/built-ins/Temporal/PlainYearMonth/prototype/year/custom.js deleted file mode 100644 index 96714f61496..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/year/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.year -description: Custom calendar tests for year(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - year(...args) { - ++calls; - assert.compareArray(args, [instance], "year arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.PlainYearMonth(1830, 8, calendar); -const result = instance.year; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/year/validate-calendar-value.js b/test/built-ins/Temporal/PlainYearMonth/prototype/year/validate-calendar-value.js deleted file mode 100644 index 573ba7d8e5c..00000000000 --- a/test/built-ins/Temporal/PlainYearMonth/prototype/year/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.year -description: Validate result returned from calendar year() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [NaN, RangeError], - ["string", TypeError], - [{}, TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, RangeError], - [-0.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - year() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.throws(error, () => instance.year, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - year() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.sameValue(instance.year, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/PlainYearMonth/refisoday-undefined.js b/test/built-ins/Temporal/PlainYearMonth/refisoday-undefined.js index 95496c77645..16c27bb6989 100644 --- a/test/built-ins/Temporal/PlainYearMonth/refisoday-undefined.js +++ b/test/built-ins/Temporal/PlainYearMonth/refisoday-undefined.js @@ -7,11 +7,12 @@ description: referenceISODay argument defaults to 1 if not given features: [Temporal] ---*/ -const calendar = new Temporal.Calendar("iso8601"); -const args = [2000, 5, calendar]; +const args = [2000, 5]; const dateExplicit = new Temporal.PlainYearMonth(...args, undefined); -assert.sameValue(dateExplicit.getISOFields().isoDay, 1, "default referenceISODay is 1"); +const isoDayExplicit = Number(dateExplicit.toString({ calendarName: "always" }).split("-")[2].slice(0, 2)); +assert.sameValue(isoDayExplicit, 1, "default referenceISODay is 1"); const dateImplicit = new Temporal.PlainYearMonth(...args); -assert.sameValue(dateImplicit.getISOFields().isoDay, 1, "default referenceISODay is 1"); +const isoDayImplicit = Number(dateImplicit.toString({ calendarName: "always" }).split("-")[2].slice(0, 2)); +assert.sameValue(isoDayImplicit, 1, "default referenceISODay is 1"); diff --git a/test/built-ins/Temporal/TimeZone/argument-wrong-type.js b/test/built-ins/Temporal/TimeZone/argument-wrong-type.js deleted file mode 100644 index 2baebf5e821..00000000000 --- a/test/built-ins/Temporal/TimeZone/argument-wrong-type.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: RangeError thrown when constructor invoked with the wrong type -features: [Temporal] ----*/ - -const tests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], - [Symbol(), "symbol"], - [{}, "object not implementing any protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.ZonedDateTime.from("2020-01-01T00:00Z[UTC]"), "ZonedDateTime instance"], -]; - -for (const [arg, description] of tests) { - assert.throws( - typeof (arg) === "string" ? RangeError : TypeError, - () => new Temporal.TimeZone(arg), - `${description} is not accepted by this constructor` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/basic.js b/test/built-ins/Temporal/TimeZone/basic.js deleted file mode 100644 index 6cf1ebefc26..00000000000 --- a/test/built-ins/Temporal/TimeZone/basic.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Basic tests for the Temporal.TimeZone constructor. -features: [Temporal] ----*/ - -const valid = [ - ["+01:00"], - ["-01:00"], - ["+0330", "+03:30"], - ["-0650", "-06:50"], - ["-08", "-08:00"], - ["UTC"], -]; -for (const [zone, id = zone] of valid) { - const result = new Temporal.TimeZone(zone); - assert.sameValue(typeof result, "object", `object should be created for ${zone}`); - assert.sameValue(result.id, id, `id for ${zone} should be ${id}`); -} - -const invalid = ["+00:01.1", "-01.1", "+01:00:00", "-010000", "+03:30:00.000000001", "-033000.1"]; -for (const zone of invalid) { - assert.throws(RangeError, () => new Temporal.TimeZone(zone), `should throw for ${zone}`); -} diff --git a/test/built-ins/Temporal/TimeZone/builtin.js b/test/built-ins/Temporal/TimeZone/builtin.js deleted file mode 100644 index c7f419b1fa5..00000000000 --- a/test/built-ins/Temporal/TimeZone/builtin.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Tests that Temporal.TimeZone meets the requirements for built-in objects -info: | - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone), - Function.prototype, "prototype"); - -assert.sameValue(typeof Temporal.TimeZone.prototype, - "object", "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/constructor.js b/test/built-ins/Temporal/TimeZone/constructor.js deleted file mode 100644 index 5494561bd78..00000000000 --- a/test/built-ins/Temporal/TimeZone/constructor.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Temporal.TimeZone constructor cannot be called as a function -info: | - 1. If NewTarget is undefined, throw a TypeError exception. -features: [Temporal] ----*/ - -assert.throws(TypeError, () => Temporal.TimeZone("UTC")); diff --git a/test/built-ins/Temporal/TimeZone/from/argument-object.js b/test/built-ins/Temporal/TimeZone/from/argument-object.js deleted file mode 100644 index 31d443ba3a9..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/argument-object.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: An object is returned unchanged -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone {} - -const objects = [ - new Temporal.TimeZone("UTC"), - new CustomTimeZone("UTC"), - { id: "Etc/Custom", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, -]; - -const thisValues = [ - Temporal.TimeZone, - CustomTimeZone, - {}, - null, - undefined, - 7, -]; - -for (const thisValue of thisValues) { - for (const object of objects) { - const result = Temporal.TimeZone.from.call(thisValue, object); - assert.sameValue(result, object); - } - - const zdt = new Temporal.ZonedDateTime(0n, "UTC"); - const fromZdt = Temporal.TimeZone.from.call(thisValue, zdt); - assert.notSameValue(fromZdt, zdt.getTimeZone(), "from() creates a new object from a string slot value"); - assert.sameValue(fromZdt.id, "UTC"); -} diff --git a/test/built-ins/Temporal/TimeZone/from/argument-primitive.js b/test/built-ins/Temporal/TimeZone/from/argument-primitive.js deleted file mode 100644 index f10ffb80a3a..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/argument-primitive.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: RangeError thrown if a value is passed that converts to an invalid string -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone {} - -const primitives = [ - undefined, - null, - true, - "string", - "local", - "Z", - "-00:00[UTC]", - "+00:01.1", - "-01.1", - "1994-11-05T08:15:30+25:00", - "1994-11-05T13:15:30-25:00", - "+01:00:00", - "-010000", - "+03:30:00.000000001", - "-033000.1", - 7, - 4.2, - 12n, -]; - -const thisValues = [ - Temporal.TimeZone, - CustomTimeZone, - {}, - null, - undefined, - 7, -]; - -for (const thisValue of thisValues) { - for (const primitive of primitives) { - assert.throws(typeof primitive === 'string' ? RangeError : TypeError, () => Temporal.TimeZone.from.call(thisValue, primitive)); - } - - const symbol = Symbol(); - assert.throws(TypeError, () => Temporal.TimeZone.from.call(thisValue, symbol)); -} diff --git a/test/built-ins/Temporal/TimeZone/from/argument-valid.js b/test/built-ins/Temporal/TimeZone/from/argument-valid.js deleted file mode 100644 index 51290b4a748..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/argument-valid.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Built-in time zones are parsed correctly out of valid strings -features: [Temporal] ----*/ - -const valids = [ - ["+01:00"], - ["-01:00"], - ["+0330", "+03:30"], - ["-0650", "-06:50"], - ["-08", "-08:00"], - ["UTC"], - ["1994-11-05T08:15:30-05:00", "-05:00"], - ["1994-11-05T13:15:30Z", "UTC"], -]; - -for (const [valid, canonical = valid] of valids) { - const result = Temporal.TimeZone.from(valid); - assert.sameValue(Object.getPrototypeOf(result), Temporal.TimeZone.prototype); - assert.sameValue(result.id, canonical); - assert.sameValue(result.toString(), canonical); -} diff --git a/test/built-ins/Temporal/TimeZone/from/builtin.js b/test/built-ins/Temporal/TimeZone/from/builtin.js deleted file mode 100644 index d4953fe1f75..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/builtin.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Tests that Temporal.TimeZone.from meets the requirements for built-in objects -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.from), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.from), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.from), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.from.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/from/length.js b/test/built-ins/Temporal/TimeZone/from/length.js deleted file mode 100644 index 526772f93ec..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Temporal.TimeZone.from.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.from, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/from/name.js b/test/built-ins/Temporal/TimeZone/from/name.js deleted file mode 100644 index 9b8ef82cfe3..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Temporal.TimeZone.from.name is "from" -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.from, "name", { - value: "from", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/from/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/from/not-a-constructor.js deleted file mode 100644 index c4ea8fdd1ea..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/not-a-constructor.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Temporal.TimeZone.from does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.from(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.from), false, - "isConstructor(Temporal.TimeZone.from)"); diff --git a/test/built-ins/Temporal/TimeZone/from/prop-desc.js b/test/built-ins/Temporal/TimeZone/from/prop-desc.js deleted file mode 100644 index 42c0e5c3ff7..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: The "from" property of Temporal.TimeZone -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.from, - "function", - "`typeof TimeZone.from` is `function`" -); - -verifyProperty(Temporal.TimeZone, "from", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/from/subclassing-ignored.js b/test/built-ins/Temporal/TimeZone/from/subclassing-ignored.js deleted file mode 100644 index beb9251068d..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/subclassing-ignored.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: The receiver is never called when calling from() -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkSubclassingIgnoredStatic( - Temporal.TimeZone, - "from", - ["UTC"], - (result) => { - assert.sameValue(result.id, "UTC", "id property of result"); - assert.sameValue(result.toString(), "UTC", "toString() of result"); - }, -); diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-case-insensitive.js b/test/built-ins/Temporal/TimeZone/from/timezone-case-insensitive.js deleted file mode 100644 index 5f33d836661..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/timezone-case-insensitive.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Time zone names are case insensitive -features: [Temporal] ----*/ - -const timeZone = 'UtC'; -const result = Temporal.TimeZone.from(timeZone); -assert.sameValue(result.id, 'UTC', `Time zone created from string "${timeZone}"`); diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-string-datetime.js b/test/built-ins/Temporal/TimeZone/from/timezone-string-datetime.js deleted file mode 100644 index 30018a0d226..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/timezone-string-datetime.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Conversion of ISO date-time strings to Temporal.TimeZone instances -features: [Temporal] ----*/ - -let timeZone = "2021-08-19T17:30"; -assert.throws(RangeError, () => Temporal.TimeZone.from(timeZone), "bare date-time string is not a time zone"); - -[ - "2021-08-19T17:30-07:00:01", - "2021-08-19T17:30-07:00:00", - "2021-08-19T17:30-07:00:00.1", - "2021-08-19T17:30-07:00:00.0", - "2021-08-19T17:30-07:00:00.01", - "2021-08-19T17:30-07:00:00.00", - "2021-08-19T17:30-07:00:00.001", - "2021-08-19T17:30-07:00:00.000", - "2021-08-19T17:30-07:00:00.0001", - "2021-08-19T17:30-07:00:00.0000", - "2021-08-19T17:30-07:00:00.00001", - "2021-08-19T17:30-07:00:00.00000", - "2021-08-19T17:30-07:00:00.000001", - "2021-08-19T17:30-07:00:00.000000", - "2021-08-19T17:30-07:00:00.0000001", - "2021-08-19T17:30-07:00:00.0000000", - "2021-08-19T17:30-07:00:00.00000001", - "2021-08-19T17:30-07:00:00.00000000", - "2021-08-19T17:30-07:00:00.000000001", - "2021-08-19T17:30-07:00:00.000000000", -].forEach((timeZone) => { - assert.throws( - RangeError, - () => Temporal.TimeZone.from(timeZone), - `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` - ); -}); - -timeZone = "2021-08-19T17:30Z"; -const result1 = Temporal.TimeZone.from(timeZone); -assert.sameValue(result1.id, "UTC", "date-time + Z is UTC time zone"); - -timeZone = "2021-08-19T17:30-07:00"; -const result2 = Temporal.TimeZone.from(timeZone); -assert.sameValue(result2.id, "-07:00", "date-time + offset is the offset time zone"); - -timeZone = "2021-08-19T17:30[UTC]"; -const result3 = Temporal.TimeZone.from(timeZone); -assert.sameValue(result3.id, "UTC", "date-time + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30Z[UTC]"; -const result4 = Temporal.TimeZone.from(timeZone); -assert.sameValue(result4.id, "UTC", "date-time + Z + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30-07:00[UTC]"; -const result5 = Temporal.TimeZone.from(timeZone); -assert.sameValue(result5.id, "UTC", "date-time + offset + IANA annotation is the IANA time zone"); diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-string-leap-second.js b/test/built-ins/Temporal/TimeZone/from/timezone-string-leap-second.js deleted file mode 100644 index 6433f9f1000..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/timezone-string-leap-second.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Leap second is a valid ISO string for TimeZone -features: [Temporal] ----*/ - -let timeZone = "2016-12-31T23:59:60+00:00[UTC]"; - -const result = Temporal.TimeZone.from(timeZone); -assert.sameValue(result.id, "UTC", "leap second is a valid ISO string for TimeZone"); - -timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]"; -assert.throws(RangeError, () => Temporal.TimeZone.from(timeZone), "leap second in time zone name not valid"); diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets.js deleted file mode 100644 index e37fbab887b..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/timezone-string-multiple-offsets.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset -features: [Temporal] ----*/ - -const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; - -const result = Temporal.TimeZone.from(timeZone); -assert.sameValue(result.id, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-string-year-zero.js b/test/built-ins/Temporal/TimeZone/from/timezone-string-year-zero.js deleted file mode 100644 index 9e3720be18d..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/timezone-string-year-zero.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+00:00[UTC]", -]; -invalidStrings.forEach((timeZone) => { - assert.throws( - RangeError, - () => Temporal.TimeZone.from(timeZone), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-string.js b/test/built-ins/Temporal/TimeZone/from/timezone-string.js deleted file mode 100644 index 38189494e54..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/timezone-string.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -["UTC", "+01:30"].forEach((timeZone) => { - const result = Temporal.TimeZone.from(timeZone); - assert.sameValue(result.id, timeZone, `Time zone created from string "${timeZone}"`); -}); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/TimeZone/from/timezone-wrong-type.js b/test/built-ins/Temporal/TimeZone/from/timezone-wrong-type.js deleted file mode 100644 index c2b735593cd..00000000000 --- a/test/built-ins/Temporal/TimeZone/from/timezone-wrong-type.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone -features: [BigInt, Symbol, Temporal] ----*/ - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], -]; - -for (const [timeZone, description] of primitiveTests) { - assert.throws( - typeof timeZone === 'string' ? RangeError : TypeError, - () => Temporal.TimeZone.from(timeZone), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], -]; - -for (const [timeZone, description] of typeErrorTests) { - assert.throws(TypeError, () => Temporal.TimeZone.from(timeZone), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/length.js b/test/built-ins/Temporal/TimeZone/length.js deleted file mode 100644 index 4f2cc665142..00000000000 --- a/test/built-ins/Temporal/TimeZone/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Temporal.TimeZone.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/missing-arguments.js b/test/built-ins/Temporal/TimeZone/missing-arguments.js deleted file mode 100644 index 65ecacdbf59..00000000000 --- a/test/built-ins/Temporal/TimeZone/missing-arguments.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: TypeError thrown when constructor invoked with no argument -features: [Temporal] ----*/ - -assert.throws(TypeError, () => new Temporal.TimeZone()); -assert.throws(TypeError, () => new Temporal.TimeZone(undefined)); diff --git a/test/built-ins/Temporal/TimeZone/name.js b/test/built-ins/Temporal/TimeZone/name.js deleted file mode 100644 index 632a9505b9d..00000000000 --- a/test/built-ins/Temporal/TimeZone/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Temporal.TimeZone.name is "TimeZone" -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone, "name", { - value: "TimeZone", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prop-desc.js b/test/built-ins/Temporal/TimeZone/prop-desc.js deleted file mode 100644 index ace7b1503cd..00000000000 --- a/test/built-ins/Temporal/TimeZone/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: The "TimeZone" property of Temporal -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone, - "function", - "`typeof TimeZone` is `function`" -); - -verifyProperty(Temporal, "TimeZone", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/constructor.js b/test/built-ins/Temporal/TimeZone/prototype/constructor.js deleted file mode 100644 index 1a8925c2ce7..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/constructor.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.constructor -description: Test for Temporal.TimeZone.prototype.constructor. -info: The initial value of Temporal.TimeZone.prototype.constructor is %Temporal.TimeZone%. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype, "constructor", { - value: Temporal.TimeZone, - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/argument-object.js b/test/built-ins/Temporal/TimeZone/prototype/equals/argument-object.js deleted file mode 100644 index 13f1bd80d67..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/argument-object.js +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.equals -description: Tests that objects can be compared for equality -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -const objectsEqualUTC = [ - new Temporal.TimeZone("UTC"), - new CustomTimeZone("UTC"), - { id: "UTC", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, - new Temporal.ZonedDateTime(0n, "UTC") -]; - -const tzUTC = new Temporal.TimeZone("UTC"); - -for (const object of objectsEqualUTC) { - const result = tzUTC.equals(object); - assert.sameValue(result, true, `Receiver ${tzUTC.id} should equal argument ${object.id}`); -} - -const objectsEqual0000 = [ - new Temporal.TimeZone("+00:00"), - new Temporal.TimeZone("+0000"), - new Temporal.TimeZone("+00"), - new CustomTimeZone("+00:00"), - new CustomTimeZone("+0000"), - new CustomTimeZone("+00"), - { id: "+00:00", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, - { id: "+0000", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, - { id: "+00", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, - new Temporal.ZonedDateTime(0n, "+00:00"), - new Temporal.ZonedDateTime(0n, "+0000"), - new Temporal.ZonedDateTime(0n, "+00"), - "+00:00", - "+0000", - "+00" -]; - -const tz0000ToTest = [ - new Temporal.TimeZone("+00:00"), - new Temporal.TimeZone("+0000"), - new Temporal.TimeZone("+00"), - new CustomTimeZone("+00:00"), - new CustomTimeZone("+0000"), - new CustomTimeZone("+00") -]; - -for (const arg of objectsEqual0000) { - for (const receiver of tz0000ToTest) { - const result = receiver.equals(arg); - assert.sameValue(result, true, `Receiver ${receiver.id} should equal argument ${arg.id ?? arg}`); - } -} - -const objectsNotEqual = [ - new Temporal.TimeZone("+00:00"), - new CustomTimeZone("+00:00"), - new CustomTimeZone("Etc/Custom"), - { id: "+00:00", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, - { id: "Etc/Custom", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, - new Temporal.ZonedDateTime(0n, "+00:00"), - "UTC" -]; - -const customObjectsToTest = [tzUTC, new CustomTimeZone("YouTeeSee"), new CustomTimeZone("+01:00")]; - -for (const arg of objectsNotEqual) { - for (const receiver of customObjectsToTest) { - if (arg === "UTC" && receiver === tzUTC) continue; - const result = receiver.equals(arg); - assert.sameValue(result, false, `Receiver ${receiver.id} should not equal argument ${arg.id ?? arg}`); - } -} - -// Custom object IDs are compared case-sensitively -const classInstanceCustomId = new CustomTimeZone("Moon/Cheese"); -const classInstanceSameCaseCustomId = new CustomTimeZone("Moon/Cheese"); -const classInstanceDifferentCaseCustomId = new CustomTimeZone("MoOn/CHEESe"); - -const plainObjectSameCaseCustomId = { id: "Moon/Cheese", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }; -const plainObjectDifferentCaseCustomId = { - id: "MoOn/CHEESe", - getPossibleInstantsFor: null, - getOffsetNanosecondsFor: null -}; - -assert.sameValue(classInstanceCustomId.equals(classInstanceSameCaseCustomId), true); -assert.sameValue(classInstanceCustomId.equals(classInstanceDifferentCaseCustomId), false); -assert.sameValue(classInstanceCustomId.equals(plainObjectSameCaseCustomId), true); -assert.sameValue(classInstanceCustomId.equals(plainObjectDifferentCaseCustomId), false); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/argument-primitive.js b/test/built-ins/Temporal/TimeZone/prototype/equals/argument-primitive.js deleted file mode 100644 index 9e79b41bc1e..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/argument-primitive.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Exceptions thrown if a value is passed that converts to an invalid string -features: [Temporal] ----*/ - -const primitives = [ - undefined, - null, - true, - "string", - "local", - "Z", - "-00:00[UTC]", - "+00:01.1", - "-01.1", - "1994-11-05T08:15:30+25:00", - "1994-11-05T13:15:30-25:00", - 7, - 4.2, - 12n -]; - -const tzUTC = new Temporal.TimeZone("UTC"); -for (const primitive of primitives) { - assert.throws(typeof primitive === "string" ? RangeError : TypeError, () => tzUTC.equals(primitive)); -} - -const symbol = Symbol(); -assert.throws(TypeError, () => tzUTC.equals(symbol)); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/argument-valid.js b/test/built-ins/Temporal/TimeZone/prototype/equals/argument-valid.js deleted file mode 100644 index 5b9c79a00b2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/argument-valid.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Built-in time zones are compared correctly out of valid strings -features: [Temporal] ----*/ - -const validsEqual = [ - ["+0330", "+03:30"], - ["-0650", "-06:50"], - ["-08", "-08:00"], - ["1994-11-05T08:15:30-05:00", "-05:00"], - ["1994-11-05T13:15:30Z", "UTC"] -]; - -for (const [valid, canonical] of validsEqual) { - const tzValid = Temporal.TimeZone.from(valid); - const tzCanonical = Temporal.TimeZone.from(canonical); - assert.sameValue(tzValid.equals(canonical), true); - assert.sameValue(tzCanonical.equals(valid), true); -} - -const validsNotEqual = [ - ["+0330", "+03:31"], - ["-0650", "-06:51"], - ["-08", "-08:01"], - ["1994-11-05T08:15:30-05:00", "-05:01"], -]; - -for (const [valid, canonical] of validsNotEqual) { - const tzValid = Temporal.TimeZone.from(valid); - const tzCanonical = Temporal.TimeZone.from(canonical); - assert.sameValue(tzValid.equals(canonical), false); - assert.sameValue(tzCanonical.equals(valid), false); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/branding.js b/test/built-ins/Temporal/TimeZone/prototype/equals/branding.js deleted file mode 100644 index 7b5ad93e178..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.equals -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const equals = Temporal.TimeZone.prototype.equals; - -assert.sameValue(typeof equals, "function"); - -const args = ["UTC"]; - -assert.throws(TypeError, () => equals.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => equals.apply(null, args), "null"); -assert.throws(TypeError, () => equals.apply(true, args), "true"); -assert.throws(TypeError, () => equals.apply("", args), "empty string"); -assert.throws(TypeError, () => equals.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => equals.apply(1, args), "1"); -assert.throws(TypeError, () => equals.apply({}, args), "plain object"); -assert.throws(TypeError, () => equals.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => equals.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/equals/builtin.js deleted file mode 100644 index 8eac773cd20..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.equals -description: > - Tests that Temporal.TimeZone.prototype.equals - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.equals), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.equals), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.equals), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.equals.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/id-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/equals/id-wrong-type.js deleted file mode 100644 index ec955693aea..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/id-wrong-type.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.equals -description: TypeError thrown if time zone reports an id that is not a String -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -[ - undefined, - null, - true, - -1000, - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongId) => { - const timeZoneWrong = new CustomTimeZone(wrongId); - const timeZoneOK = new Temporal.TimeZone('UTC'); - assert.throws(TypeError, () => timeZoneWrong.equals(timeZoneOK)); - assert.throws(TypeError, () => timeZoneOK.equals(timeZoneWrong)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/length.js b/test/built-ins/Temporal/TimeZone/prototype/equals/length.js deleted file mode 100644 index 7d4d11fa6fa..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.equals -description: Temporal.TimeZone.prototype.equals.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.equals, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/name.js b/test/built-ins/Temporal/TimeZone/prototype/equals/name.js deleted file mode 100644 index 21f452ad877..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.equals -description: Temporal.TimeZone.prototype.equals.name is "equals". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.equals, "name", { - value: "equals", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/equals/not-a-constructor.js deleted file mode 100644 index b5d9cae6508..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.equals -description: > - Temporal.TimeZone.prototype.equals does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.equals(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.equals), false, - "isConstructor(Temporal.TimeZone.prototype.equals)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/equals/prop-desc.js deleted file mode 100644 index 8d0dfe1e0a0..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.equals -description: The "equals" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.equals, - "function", - "`typeof TimeZone.prototype.equals` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "equals", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-case-insensitive.js b/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-case-insensitive.js deleted file mode 100644 index 75b5d613c7a..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-case-insensitive.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.equals -description: Time zone names are case insensitive -features: [Temporal] ----*/ - -const timeZone = 'UtC'; -const result = Temporal.TimeZone.from(timeZone); -assert.sameValue(result.equals(timeZone), true); -assert.sameValue(result.equals("+00:00"), false); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-datetime.js b/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-datetime.js deleted file mode 100644 index ebbe31b3b78..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-datetime.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.equals -description: Conversion of ISO date-time strings to the argument of Temporal.TimeZone.prototype.equals -features: [Temporal] ----*/ - -let tzUTC = Temporal.TimeZone.from("UTC"); -let arg = "2021-08-19T17:30"; -assert.throws(RangeError, () => tzUTC.equals(arg), "bare date-time string is not a time zone"); - -[ - "2021-08-19T17:30-07:00:01", - "2021-08-19T17:30-07:00:00", - "2021-08-19T17:30-07:00:00.1", - "2021-08-19T17:30-07:00:00.0", - "2021-08-19T17:30-07:00:00.01", - "2021-08-19T17:30-07:00:00.00", - "2021-08-19T17:30-07:00:00.001", - "2021-08-19T17:30-07:00:00.000", - "2021-08-19T17:30-07:00:00.0001", - "2021-08-19T17:30-07:00:00.0000", - "2021-08-19T17:30-07:00:00.00001", - "2021-08-19T17:30-07:00:00.00000", - "2021-08-19T17:30-07:00:00.000001", - "2021-08-19T17:30-07:00:00.000000", - "2021-08-19T17:30-07:00:00.0000001", - "2021-08-19T17:30-07:00:00.0000000", - "2021-08-19T17:30-07:00:00.00000001", - "2021-08-19T17:30-07:00:00.00000000", - "2021-08-19T17:30-07:00:00.000000001", - "2021-08-19T17:30-07:00:00.000000000", -].forEach((timeZone) => { - assert.throws( - RangeError, - () => tzUTC.equals(timeZone), - `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` - ); -}); - -arg = "2021-08-19T17:30Z"; -tzUTC = Temporal.TimeZone.from(arg); -assert.sameValue(tzUTC.equals(arg), true, "date-time + Z is UTC time zone"); - -arg = "2021-08-19T17:30-07:00"; -tzUTC = Temporal.TimeZone.from(arg); -assert.sameValue(tzUTC.equals(arg), true, "date-time + offset is the offset time zone"); - -arg = "2021-08-19T17:30[UTC]"; -tzUTC = Temporal.TimeZone.from(arg); -assert.sameValue(tzUTC.equals(arg), true, "date-time + IANA annotation is the IANA time zone"); - -arg = "2021-08-19T17:30Z[UTC]"; -tzUTC = Temporal.TimeZone.from(arg); -assert.sameValue(tzUTC.equals(arg), true, "date-time + Z + IANA annotation is the IANA time zone"); - -arg = "2021-08-19T17:30-07:00[UTC]"; -tzUTC = Temporal.TimeZone.from(arg); -assert.sameValue(tzUTC.equals(arg), true, "date-time + offset + IANA annotation is the IANA time zone"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-multiple-offsets.js deleted file mode 100644 index 01dec3fd1f8..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-string-multiple-offsets.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Time zone strings with UTC offset fractional part are not confused with time fractional part -features: [Temporal] ----*/ - -const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; - -const result = Temporal.TimeZone.from(timeZone); -assert.sameValue(result.equals("+01:46"), true, "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-wrong-type.js deleted file mode 100644 index 745e0a1d119..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/equals/timezone-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone -features: [BigInt, Symbol, Temporal] ----*/ - -const rangeErrorTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"] -]; - -const tzUTC = new Temporal.TimeZone("UTC"); - -for (const [timeZone, description] of rangeErrorTests) { - assert.throws( - typeof timeZone === "string" ? RangeError : TypeError, - () => tzUTC.equals(timeZone), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"] -]; - -for (const [timeZone, description] of typeErrorTests) { - assert.throws( - TypeError, - () => tzUTC.equals(timeZone), - `${description} is not a valid object and does not convert to a string` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 5170ae48fd2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.TimeZone("UTC"); -// Patch getPossibleInstantsFor to allow the spec-mandated observable array -// iteration in the GetPossibleInstantsFor AO. -instance.getPossibleInstantsFor = function (...args) { - const instants = Temporal.TimeZone.prototype.getPossibleInstantsFor.apply(this, args); - instants[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; - return instants; -} - -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, calendar: "iso8601" }; -instance.getInstantFor(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-not-datetime.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-not-datetime.js deleted file mode 100644 index 92c057a34ca..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-not-datetime.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Appropriate error thrown when argument cannot be converted to Temporal.PlainDateTime -features: [Temporal] ----*/ - -const timeZone = Temporal.TimeZone.from("UTC"); -assert.throws(TypeError, () => timeZone.getInstantFor(undefined), "undefined"); -assert.throws(TypeError, () => timeZone.getInstantFor(null), "null"); -assert.throws(TypeError, () => timeZone.getInstantFor(true), "boolean"); -assert.throws(RangeError, () => timeZone.getInstantFor(""), "empty string"); -assert.throws(TypeError, () => timeZone.getInstantFor(Symbol()), "Symbol"); -assert.throws(TypeError, () => timeZone.getInstantFor(5), "number"); -assert.throws(TypeError, () => timeZone.getInstantFor(5n), "bigint"); -assert.throws(TypeError, () => timeZone.getInstantFor({ year: 2020 }), "plain object"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-number.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-number.js deleted file mode 100644 index 8b27f0df8f1..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: A number cannot be used in place of a Temporal.PlainDateTime -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.getInstantFor(arg), - `A number (${arg}) is not a valid ISO string for PlainDateTime` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-plaindate.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-plaindate.js deleted file mode 100644 index eb15eb6ca4b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-plaindate.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Fast path for converting Temporal.PlainDate to Temporal.PlainDateTime by reading internal slots -info: | - sec-temporal.timezone.prototype.getinstantfor step 3: - 3. Set _dateTime_ to ? ToTemporalDateTime(_dateTime_). - sec-temporal-totemporaldatetime step 2.b: - b. If _item_ has an [[InitializedTemporalDate]] internal slot, then - i. Return ? CreateTemporalDateTime(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], 0, 0, 0, 0, 0, 0, _item_.[[Calendar]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => { - const timezone = new Temporal.TimeZone("UTC"); - const result = timezone.getInstantFor(date); - assert.sameValue(result.epochNanoseconds, 957_225_600_000_000_000n, "epochNanoseconds result"); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index ec10e723198..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.getInstantFor(arg); -assert.sameValue(result.epochNanoseconds, 217_123_200_000_000_000n, "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 17f6f3f7f14..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.getInstantFor(arg); - assert.sameValue(result.epochNanoseconds, 217_123_200_000_000_000n, `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 5701e251955..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.getInstantFor(arg); -assert.sameValue( - result.epochNanoseconds, - 217_123_200_000_000_000n, - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-number.js deleted file mode 100644 index 15ad1bdcadc..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.getInstantFor(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-string.js deleted file mode 100644 index c578c197c53..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.getInstantFor(arg); -assert.sameValue(result.epochNanoseconds, 217_123_200_000_000_000n, `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index e2f93998ad2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.getInstantFor(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.getInstantFor(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 8efeeb208e3..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.getInstantFor(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 0ab9cb35bc2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.getInstantFor(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation.js deleted file mode 100644 index 118f11679e7..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-calendar-annotation.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1976-11-18T15:23[u-ca=iso8601]", "without time zone"], - ["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getInstantFor(arg); - - assert.sameValue( - result.epochNanoseconds, - 217_178_580_000_000_000n, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 561a17da8ff..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getInstantFor(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-date-with-utc-offset.js deleted file mode 100644 index 873c89fc1b3..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const validStrings = [ - "1976-11-18T15:23+00:00", - "1976-11-18T15:23+00:00[UTC]", - "1976-11-18T15:23+00:00[!UTC]", - "1976-11-18T15:23-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.getInstantFor(arg); - - assert.sameValue( - result.epochNanoseconds, - 217_178_580_000_000_000n, - `"${arg}" is a valid UTC offset with time for PlainDateTime` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getInstantFor(arg), - `"${arg}" UTC offset without time is not valid for PlainDateTime` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-calendar.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-calendar.js deleted file mode 100644 index 1d1e6ef70f4..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getInstantFor(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-time-zone.js deleted file mode 100644 index 5e6509414ba..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getInstantFor(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-separators.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-separators.js deleted file mode 100644 index a2c1b1c3eca..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["1976-11-18T15:23", "uppercase T"], - ["1976-11-18t15:23", "lowercase T"], - ["1976-11-18 15:23", "space between date and time"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getInstantFor(arg); - - assert.sameValue( - result.epochNanoseconds, - 217_178_580_000_000_000n, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-zone-annotation.js deleted file mode 100644 index a6746a03cc2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"], - ["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"], - ["1976-11-18T15:23[+00:00]", "numeric, with no offset"], - ["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"], - ["1976-11-18T15:23+00:00[UTC]", "named, with offset"], - ["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], - ["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"], - ["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getInstantFor(arg); - - assert.sameValue( - result.epochNanoseconds, - 217_178_580_000_000_000n, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-unknown-annotation.js deleted file mode 100644 index 91bb85df9f5..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-unknown-annotation.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["1976-11-18T15:23[foo=bar]", "alone"], - ["1976-11-18T15:23[UTC][foo=bar]", "with time zone"], - ["1976-11-18T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["1976-11-18T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["1976-11-18T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getInstantFor(arg); - - assert.sameValue( - result.epochNanoseconds, - 217_178_580_000_000_000n, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-with-utc-designator.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-with-utc-designator.js deleted file mode 100644 index d607c549b08..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: RangeError thrown if a string with UTC designator is used as a PlainDateTime -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getInstantFor(arg), - "String with UTC designator should not be valid as a PlainDateTime" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-wrong-type.js deleted file mode 100644 index 4e2b85431c4..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDateTime -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.getInstantFor(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDateTime, "Temporal.PlainDateTime, object"], - [Temporal.PlainDateTime.prototype, "Temporal.PlainDateTime.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.getInstantFor(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-balance-negative-time-units.js deleted file mode 100644 index 451e8cb7b55..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-balance-negative-time-units.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Negative time fields are balanced upwards if the argument is given as ZonedDateTime -info: | - sec-temporal-balancetime steps 3–14: - 3. Set _microsecond_ to _microsecond_ + floor(_nanosecond_ / 1000). - 4. Set _nanosecond_ to _nanosecond_ modulo 1000. - 5. Set _millisecond_ to _millisecond_ + floor(_microsecond_ / 1000). - 6. Set _microsecond_ to _microsecond_ modulo 1000. - 7. Set _second_ to _second_ + floor(_millisecond_ / 1000). - 8. Set _millisecond_ to _millisecond_ modulo 1000. - 9. Set _minute_ to _minute_ + floor(_second_ / 60). - 10. Set _second_ to _second_ modulo 60. - 11. Set _hour_ to _hour_ + floor(_minute_ / 60). - 12. Set _minute_ to _minute_ modulo 60. - 13. Let _days_ be floor(_hour_ / 24). - 14. Set _hour_ to _hour_ modulo 24. - sec-temporal-balanceisodatetime step 1: - 1. Let _balancedTime_ be ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). - sec-temporal-builtintimezonegetplaindatetimefor step 3: - 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). - sec-temporal-totemporaldatetime step 3.b: - b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then - ... - ii. 1. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). - sec-temporal.timezone.prototype.getinstantfor step 3: - 3. Set _dateTime_ ? ToTemporalDateTime(_dateTime_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// This code path is encountered if the time zone offset is negative and its -// absolute value in nanoseconds is greater than the nanosecond field of the -// exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); - -const conversionTimeZone = new Temporal.TimeZone("UTC"); // should not be used to interpret the argument -const instant = conversionTimeZone.getInstantFor(datetime); - -assert.sameValue(instant.epochNanoseconds, 3661_001_000_999n); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-negative-epochnanoseconds.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-negative-epochnanoseconds.js deleted file mode 100644 index 891716b420b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-negative-epochnanoseconds.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: A pre-epoch value is handled correctly by the modulo operation in GetISOPartsFromEpoch -info: | - sec-temporal-getisopartsfromepoch step 1: - 1. Let _remainderNs_ be the mathematical value whose sign is the sign of _epochNanoseconds_ and whose magnitude is abs(_epochNanoseconds_) modulo 106. - sec-temporal-builtintimezonegetplaindatetimefor step 2: - 2. Let _result_ be ! GetISOPartsFromEpoch(_instant_.[[Nanoseconds]]). -features: [Temporal] ----*/ - -const datetime = new Temporal.ZonedDateTime(-13849764_999_999_999n, "UTC"); - -// This code path shows up anywhere we convert an exact time, before the Unix -// epoch, with nonzero microseconds or nanoseconds, into a wall time. - -const instance = new Temporal.TimeZone("UTC"); -const result = instance.getInstantFor(datetime); -assert.sameValue(result.epochNanoseconds, -13849764_999_999_999n); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index fcb0d378624..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const builtinTimeZone = new Temporal.TimeZone("UTC"); - assert.throws(RangeError, () => builtinTimeZone.getInstantFor(datetime)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index f693c3975a2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const builtinTimeZone = new Temporal.TimeZone("UTC"); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => builtinTimeZone.getInstantFor(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index b0191610e4b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const builtinTimeZone = new Temporal.TimeZone("UTC"); - assert.throws(RangeError, () => builtinTimeZone.getInstantFor(datetime)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 9aa6e7fc1fc..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const builtinTimeZone = new Temporal.TimeZone("UTC"); - assert.throws(TypeError, () => builtinTimeZone.getInstantFor(datetime)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/balance-negative-time-units.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/balance-negative-time-units.js deleted file mode 100644 index 9c3056d7946..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/balance-negative-time-units.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Negative time fields are balanced upwards -info: | - sec-temporal-balancetime steps 3–14: - 3. Set _microsecond_ to _microsecond_ + floor(_nanosecond_ / 1000). - 4. Set _nanosecond_ to _nanosecond_ modulo 1000. - 5. Set _millisecond_ to _millisecond_ + floor(_microsecond_ / 1000). - 6. Set _microsecond_ to _microsecond_ modulo 1000. - 7. Set _second_ to _second_ + floor(_millisecond_ / 1000). - 8. Set _millisecond_ to _millisecond_ modulo 1000. - 9. Set _minute_ to _minute_ + floor(_second_ / 60). - 10. Set _second_ to _second_ modulo 60. - 11. Set _hour_ to _hour_ + floor(_minute_ / 60). - 12. Set _minute_ to _minute_ modulo 60. - 13. Let _days_ be floor(_hour_ / 24). - 14. Set _hour_ to _hour_ modulo 24. - sec-temporal-addtime step 8: - 8. Return ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). - sec-temporal-adddatetime step 1: - 1. Let _timeResult_ be ? AddTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_). - sec-temporal-builtintimezonegetinstantfor step 13.a: - a. Let _earlier_ be ? AddDateTime(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], 0, 0, 0, 0, 0, 0, 0, 0, 0, −_nanoseconds_, *"constrain"*). - sec-temporal.timezone.prototype.getinstantfor step 6: - 6. Return ? BuiltinTimeZoneGetInstantFor(_timeZone_, _dateTime_, _disambiguation_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const shiftInstant = new Temporal.Instant(3661_001_001_001n); -const tz = TemporalHelpers.oneShiftTimeZone(shiftInstant, 2); -const datetime = new Temporal.PlainDateTime(1970, 1, 1, 1, 1, 1, 1, 1, 1); - -// This code path is encountered if disambiguation is `earlier` and the shift is -// a spring-forward change -tz.getInstantFor(datetime, { disambiguation: "earlier" }); - -const expected = [ - "1970-01-01T01:01:01.001001001", - "1970-01-01T01:01:01.001000999", -]; -assert.compareArray(tz.getPossibleInstantsForCalledWith, expected); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/branding.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/branding.js deleted file mode 100644 index 0a95f4c43bb..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getInstantFor = Temporal.TimeZone.prototype.getInstantFor; - -assert.sameValue(typeof getInstantFor, "function"); - -const args = [new Temporal.PlainDateTime(2022, 6, 22)]; - -assert.throws(TypeError, () => getInstantFor.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => getInstantFor.apply(null, args), "null"); -assert.throws(TypeError, () => getInstantFor.apply(true, args), "true"); -assert.throws(TypeError, () => getInstantFor.apply("", args), "empty string"); -assert.throws(TypeError, () => getInstantFor.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => getInstantFor.apply(1, args), "1"); -assert.throws(TypeError, () => getInstantFor.apply({}, args), "plain object"); -assert.throws(TypeError, () => getInstantFor.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => getInstantFor.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/builtin.js deleted file mode 100644 index fac2790e990..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - Tests that Temporal.TimeZone.prototype.getInstantFor - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.getInstantFor), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getInstantFor), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getInstantFor), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.getInstantFor.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index cfe33e430a7..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.TimeZone("UTC"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.getInstantFor(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-fields-iterable.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-fields-iterable.js deleted file mode 100644 index 7686aaad94e..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-fields-iterable.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.timezone.prototype.getinstantfor step 3: - 3. Set _dateTime_ to ? ToTemporalDateTime(_dateTime_). - sec-temporal-totemporaldatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const timeZone = new Temporal.TimeZone("UTC"); -timeZone.getInstantFor({ year: 2000, month: 5, day: 2, calendar }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-temporal-object.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-temporal-object.js deleted file mode 100644 index 7f44cd88d1c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.timezone.prototype.getinstantfor step 3: - 3. Set _dateTime_ to ? ToTemporalDateTime(_dateTime_). - sec-temporal-totemporaldatetime step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const timeZone = new Temporal.TimeZone("UTC"); - timeZone.getInstantFor({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/constructor-in-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/constructor-in-calendar-fields.js deleted file mode 100644 index cecf13fbc57..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.TimeZone("UTC"); - -assert.throws(RangeError, () => instance.getInstantFor(arg)); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-invalid-string.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-invalid-string.js deleted file mode 100644 index b2de9799a9c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-invalid-string.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: RangeError thrown when disambiguation option not one of the allowed string values -info: | - sec-getoption step 10: - 10. If _values_ is not *undefined* and _values_ does not contain an element equal to _value_, throw a *RangeError* exception. - sec-temporal-totemporaldisambiguation step 1: - 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). - sec-temporal.timezone.prototype.getinstantfor step 5: - 5. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). -features: [Temporal] ----*/ - -const datetime = new Temporal.PlainDateTime(2001, 9, 9, 1, 46, 40, 987, 654, 321); -const timeZone = new Temporal.TimeZone("UTC"); -assert.throws(RangeError, () => timeZone.getInstantFor(datetime, { disambiguation: "other string" })); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-undefined.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-undefined.js deleted file mode 100644 index 1cfacf1981a..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-undefined.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Fallback value for disambiguation option -info: | - sec-getoption step 3: - 3. If _value_ is *undefined*, return _fallback_. - sec-temporal-totemporaldisambiguation step 1: - 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). - sec-temporal.timezone.prototype.getinstantfor step 5: - 5. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const springForwardDateTime = new Temporal.PlainDateTime(2000, 4, 2, 2, 30); -const fallBackDateTime = new Temporal.PlainDateTime(2000, 10, 29, 1, 30); - -[ - [springForwardDateTime, 954671400_000_000_000n], - [fallBackDateTime, 972808200_000_000_000n], -].forEach(([datetime, expected]) => { - const explicit = timeZone.getInstantFor(datetime, { disambiguation: undefined }); - assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); - const implicit = timeZone.getInstantFor(datetime, {}); - assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); - const lambda = timeZone.getInstantFor(datetime, () => {}); - assert.sameValue(lambda.epochNanoseconds, expected, "default disambiguation is compatible"); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-wrong-type.js deleted file mode 100644 index 4a8988e55d5..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/disambiguation-wrong-type.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Type conversions for disambiguation option -info: | - sec-getoption step 9.a: - a. Set _value_ to ? ToString(_value_). - sec-temporal-totemporaldisambiguation step 1: - 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). - sec-temporal.timezone.prototype.getinstantfor step 5: - 5. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const datetime = new Temporal.PlainDateTime(2001, 9, 9, 1, 46, 40, 987, 654, 321); -const timeZone = new Temporal.TimeZone("UTC"); -TemporalHelpers.checkStringOptionWrongType("disambiguation", "compatible", - (disambiguation) => timeZone.getInstantFor(datetime, { disambiguation }), - (result, descr) => assert.sameValue(result.epochNanoseconds, 1_000_000_000_987_654_321n, descr), -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/duplicate-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/duplicate-calendar-fields.js deleted file mode 100644 index 9b686411ffe..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.TimeZone("UTC"); - - assert.throws(RangeError, () => instance.getInstantFor(arg)); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index 2aa879b2b50..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-maximum-forward-offset-shift.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants can be at most 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - calls++; - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12 })]; - } -} - -const timeZone = new Shift24Hour(); - -for (const disambiguation of ["earlier", "later", "compatible"]) { - timeZone.getInstantFor(new Temporal.PlainDateTime(1970, 1, 1, 12), { disambiguation }); - - assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); - calls = 0; -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js deleted file mode 100644 index 2b8308c2c0d..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -for (const disambiguation of ["earlier", "later", "compatible"]) { - assert.throws(RangeError, () => timeZone.getInstantFor(new Temporal.PlainDateTime(1970, 1, 1, 12), { disambiguation }), "RangeError should be thrown"); -} - diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 1bc1086f994..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); - -for (const disambiguation of ["earlier", "later", "compatible"]) { - const timeZone = new SkippedDateTime(); - timeZone.getInstantFor(new Temporal.PlainDateTime(2000, 3, 4, 12, 34, 56, 0, 0, 0, nonBuiltinISOCalendar), { disambiguation }); - - assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index dd3b08227dc..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-maximum-backward-offset-shift.js +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - calls++; - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12 }), - utcInstant.add({ hours: 12 }) - ]; - } -} - -const timeZone = new Shift24Hour(); - -for (const disambiguation of ["earlier", "later", "compatible"]) { - timeZone.getInstantFor(new Temporal.PlainDateTime(1970, 1, 1, 12), { disambiguation }); - - assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); - calls = 0; -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index ba6fb520be1..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/getpossibleinstantsfor-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -for (const disambiguation of ["earlier", "later", "compatible"]) { - assert.throws(RangeError, () => timeZone.getInstantFor(new Temporal.PlainDateTime(1970, 1, 1, 12), { disambiguation }), "RangeError should be thrown"); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/infinity-throws-rangeerror.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/infinity-throws-rangeerror.js deleted file mode 100644 index 52c877b2d16..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.timezone.prototype.getinstantfor -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); -const base = { year: 2000, month: 5, day: 2, hour: 15, minute: 30, second: 45, millisecond: 987, microsecond: 654, nanosecond: 321 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((prop) => { - assert.throws(RangeError, () => instance.getInstantFor({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.getInstantFor({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/leap-second.js deleted file mode 100644 index 22945fe481c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Leap second is a valid ISO string for PlainDateTime -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.getInstantFor(arg); -assert.sameValue( - result1.epochNanoseconds, - 1_483_228_799_000_000_000n, - "leap second is a valid ISO string for PlainDateTime" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.getInstantFor(arg); -assert.sameValue( - result2.epochNanoseconds, - 1_483_228_799_000_000_000n, - "second: 60 is ignored in property bag for PlainDateTime" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/length.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/length.js deleted file mode 100644 index 4188f547e66..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Temporal.TimeZone.prototype.getInstantFor.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getInstantFor, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/name.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/name.js deleted file mode 100644 index 9f369768c47..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Temporal.TimeZone.prototype.getInstantFor.name is "getInstantFor". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getInstantFor, "name", { - value: "getInstantFor", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/not-a-constructor.js deleted file mode 100644 index 1c1429ce136..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: > - Temporal.TimeZone.prototype.getInstantFor does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.getInstantFor(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getInstantFor), false, - "isConstructor(Temporal.TimeZone.prototype.getInstantFor)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-object.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-object.js deleted file mode 100644 index f6beb88df03..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-object.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Empty or a function object may be used as options -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const result1 = instance.getInstantFor(new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38), {}); -assert.sameValue( - result1.epochNanoseconds, 1572345998000000000n, - "options may be an empty plain object" -); - -const result2 = instance.getInstantFor(new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38), () => {}); -assert.sameValue( - result2.epochNanoseconds, 1572345998000000000n, - "options may be a function object" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-undefined.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-undefined.js deleted file mode 100644 index 350e6863678..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-undefined.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -includes: [temporalHelpers.js] -description: Verify that undefined options are handled correctly. -features: [BigInt, Temporal] ----*/ - -const datetimeEarlier = new Temporal.PlainDateTime(2000, 10, 29, 1, 34, 56, 987, 654, 321); -const datetimeLater = new Temporal.PlainDateTime(2000, 4, 2, 2, 34, 56, 987, 654, 321); -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -[ - [datetimeEarlier, 972808496987654321n], - [datetimeLater, 954671696987654321n], -].forEach(([datetime, expected]) => { - const explicit = timeZone.getInstantFor(datetime, undefined); - assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); - - const implicit = timeZone.getInstantFor(datetime); - assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-wrong-type.js deleted file mode 100644 index eaa0b1239d0..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/options-wrong-type.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: TypeError thrown when options argument is a primitive -features: [BigInt, Symbol, Temporal] ----*/ - -const badOptions = [ - null, - true, - "some string", - Symbol(), - 1, - 2n, -]; - -const instance = new Temporal.TimeZone("UTC"); -for (const value of badOptions) { - assert.throws(TypeError, () => instance.getInstantFor(new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38), value), - `TypeError on wrong options type ${typeof value}`); -}; diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/order-of-operations.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/order-of-operations.js deleted file mode 100644 index 021a35dc3ea..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/order-of-operations.js +++ /dev/null @@ -1,106 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Properties on an object passed to getInstantFor() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - // GetTemporalCalendarSlotValueWithISODefault - "get fields.calendar", - "has fields.calendar.dateAdd", - "has fields.calendar.dateFromFields", - "has fields.calendar.dateUntil", - "has fields.calendar.day", - "has fields.calendar.dayOfWeek", - "has fields.calendar.dayOfYear", - "has fields.calendar.daysInMonth", - "has fields.calendar.daysInWeek", - "has fields.calendar.daysInYear", - "has fields.calendar.fields", - "has fields.calendar.id", - "has fields.calendar.inLeapYear", - "has fields.calendar.mergeFields", - "has fields.calendar.month", - "has fields.calendar.monthCode", - "has fields.calendar.monthDayFromFields", - "has fields.calendar.monthsInYear", - "has fields.calendar.weekOfYear", - "has fields.calendar.year", - "has fields.calendar.yearMonthFromFields", - "has fields.calendar.yearOfWeek", - // lookup - "get fields.calendar.dateFromFields", - "get fields.calendar.fields", - // CalendarFields - "call fields.calendar.fields", - // PrepareTemporalFields - "get fields.day", - "get fields.day.valueOf", - "call fields.day.valueOf", - "get fields.hour", - "get fields.hour.valueOf", - "call fields.hour.valueOf", - "get fields.microsecond", - "get fields.microsecond.valueOf", - "call fields.microsecond.valueOf", - "get fields.millisecond", - "get fields.millisecond.valueOf", - "call fields.millisecond.valueOf", - "get fields.minute", - "get fields.minute.valueOf", - "call fields.minute.valueOf", - "get fields.month", - "get fields.month.valueOf", - "call fields.month.valueOf", - "get fields.monthCode", - "get fields.monthCode.toString", - "call fields.monthCode.toString", - "get fields.nanosecond", - "get fields.nanosecond.valueOf", - "call fields.nanosecond.valueOf", - "get fields.second", - "get fields.second.valueOf", - "call fields.second.valueOf", - "get fields.year", - "get fields.year.valueOf", - "call fields.year.valueOf", - // InterpretTemporalDateTimeFields - "call fields.calendar.dateFromFields", - // ToTemporalDisambiguation - "get options.disambiguation", - "get options.disambiguation.toString", - "call options.disambiguation.toString", - // BuiltinTimeZoneGetInstantFor - "get this.getPossibleInstantsFor", - "call this.getPossibleInstantsFor", -]; -const actual = []; - -const instance = new Temporal.TimeZone("UTC"); -TemporalHelpers.observeProperty(actual, instance, "getPossibleInstantsFor", function getPossibleInstantsFor(...args) { - actual.push("call this.getPossibleInstantsFor"); - return Temporal.TimeZone.prototype.getPossibleInstantsFor.apply(instance, args); -}, "this"); - -const fields = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 5, - monthCode: "M05", - day: 2, - hour: 12, - minute: 34, - second: 56, - millisecond: 987, - microsecond: 654, - nanosecond: 321, - calendar: TemporalHelpers.calendarObserver(actual, "fields.calendar"), -}, "fields"); - -const options = TemporalHelpers.propertyBagObserver(actual, { disambiguation: "compatible" }, "options"); - -instance.getInstantFor(fields, options); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/prop-desc.js deleted file mode 100644 index 2eb0f587650..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: The "getInstantFor" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.getInstantFor, - "function", - "`typeof TimeZone.prototype.getInstantFor` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "getInstantFor", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/proto-in-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/proto-in-calendar-fields.js deleted file mode 100644 index 4579bff80e1..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.TimeZone("UTC"); - -assert.throws(RangeError, () => instance.getInstantFor(arg)); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/read-time-fields-before-datefromfields.js deleted file mode 100644 index 6a6fca8c6d2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.timezone.prototype.getinstantfor step 3: - 3. Set _dateTime_ to ? ToTemporalDateTime(_dateTime_). - sec-temporal-totemporaldatetime step 2.e: - e. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timezone = new Temporal.TimeZone("UTC"); -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const result = timezone.getInstantFor({ year: 1970, month: 1, day: 1, calendar }); - -assert.sameValue(result.epochNanoseconds, 0n, "epochNanoseconds result"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero.js deleted file mode 100644 index d7ed91a2bf4..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getinstantfor -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-12-07", - "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00", - "-000000-12-07T03:24:30+00:00[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getInstantFor(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index c70b2259b5f..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.getNextTransition(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation.js deleted file mode 100644 index db98cdb83d8..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], - ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], - ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], - ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], - ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], - ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], - ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getNextTransition(arg); - - assert.sameValue( - result, - null, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-critical-unknown-annotation.js deleted file mode 100644 index d805a9438d6..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar]", - "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getNextTransition(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-date-with-utc-offset.js deleted file mode 100644 index bc4474c4f27..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const validStrings = [ - "1970-01-01T00Z", - "1970-01-01T00Z[UTC]", - "1970-01-01T00Z[!UTC]", - "1970-01-01T00Z[Europe/Vienna]", - "1970-01-01T00+00:00", - "1970-01-01T00+00:00[UTC]", - "1970-01-01T00+00:00[!UTC]", - "1969-12-31T16-08:00[America/Vancouver]", -]; - -for (const arg of validStrings) { - const result = instance.getNextTransition(arg); - - assert.sameValue( - result, - null, - `"${arg}" is a valid UTC offset with time for Instant` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getNextTransition(arg), - `"${arg}" UTC offset without time is not valid for Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-invalid.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-invalid.js deleted file mode 100644 index 934edbfdf6b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-invalid.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as an Instant -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00T00:00Z", - "2020-01-32T00:00Z", - "2020-02-30T00:00Z", - "2021-02-29T00:00Z", - "2020-00-01T00:00Z", - "2020-13-01T00:00Z", - "2020-01-01TZ", - "2020-01-01T25:00:00Z", - "2020-01-01T01:60:00Z", - "2020-01-01T01:60:61Z", - "2020-01-01T00:00Zjunk", - "2020-01-01T00:00:00Zjunk", - "2020-01-01T00:00:00.000000000Zjunk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01T00:00Z", - "2020-001-01T00:00Z", - "2020-01-001T00:00Z", - "2020-01-01T001Z", - "2020-01-01T01:001Z", - "2020-01-01T01:01:001Z", - // valid, but forms not supported in Temporal: - "2020-W01-1T00:00Z", - "2020-001T00:00Z", - "+0002020-01-01T00:00Z", - // may be valid in other contexts, but insufficient information for Instant: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - "2020-01-01", - "2020-01-01T00", - "2020-01-01T00:00", - "2020-01-01T00:00:00", - "2020-01-01T00:00:00.000000000", - // valid, but outside the supported range: - "-999999-01-01T00:00Z", - "+999999-01-01T00:00Z", -]; - -const instance = new Temporal.TimeZone("UTC"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getNextTransition(arg), - `"${arg}" should not be a valid ISO string for an Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-calendar.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-calendar.js deleted file mode 100644 index 5adbdb1fa98..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-calendar.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getNextTransition(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-time-zone.js deleted file mode 100644 index ec245c5a685..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[UTC][UTC]", - "1970-01-01T00:00Z[!UTC][UTC]", - "1970-01-01T00:00Z[UTC][!UTC]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00Z[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getNextTransition(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-separators.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-separators.js deleted file mode 100644 index 7bef091c27f..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z", "uppercase T"], - ["1970-01-01t00:00Z", "lowercase T"], - ["1970-01-01 00:00Z", "space between date and time"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getNextTransition(arg); - - assert.sameValue( - result, - null, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-zone-annotation.js deleted file mode 100644 index c31d25dee38..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], - ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], - ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], - ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], - ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], - ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], - ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], - ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getNextTransition(arg); - - assert.sameValue( - result, - null, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-unknown-annotation.js deleted file mode 100644 index 53f49b74b99..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-string-unknown-annotation.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[foo=bar]", "alone"], - ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], - ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], - ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getNextTransition(arg); - - assert.sameValue( - result, - null, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-wrong-type.js deleted file mode 100644 index 65294ea9063..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: > - Appropriate error thrown when argument cannot be converted to a valid string - for Instant -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], - [{}, "plain object"], - [Temporal.Instant, "Temporal.Instant, object"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === "string" || (typeof arg === "object" && arg !== null) || typeof arg === "function" - ? RangeError - : TypeError, - () => instance.getNextTransition(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString() -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.getNextTransition(arg), `${description} does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-zoneddatetime.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-zoneddatetime.js deleted file mode 100644 index bf351bbd352..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/argument-zoneddatetime.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Fast path for converting Temporal.ZonedDateTime to Temporal.Instant -info: | - sec-temporal.timezone.prototype.getnexttransition step 3: - 3. Set _startingPoint_ to ? ToTemporalInstant(_startingPoint_). - sec-temporal-totemporalinstant step 1.b: - b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return ! CreateTemporalInstant(_item_.[[Nanoseconds]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalInstantFastPath((datetime) => { - const timeZone = Temporal.TimeZone.from("UTC"); - const result = timeZone.getNextTransition(datetime); - assert.sameValue(result, null, "transition result"); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/branding.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/branding.js deleted file mode 100644 index 9b629ee6e5e..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getNextTransition = Temporal.TimeZone.prototype.getNextTransition; - -assert.sameValue(typeof getNextTransition, "function"); - -const args = [new Temporal.Instant(0n)]; - -assert.throws(TypeError, () => getNextTransition.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => getNextTransition.apply(null, args), "null"); -assert.throws(TypeError, () => getNextTransition.apply(true, args), "true"); -assert.throws(TypeError, () => getNextTransition.apply("", args), "empty string"); -assert.throws(TypeError, () => getNextTransition.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => getNextTransition.apply(1, args), "1"); -assert.throws(TypeError, () => getNextTransition.apply({}, args), "plain object"); -assert.throws(TypeError, () => getNextTransition.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => getNextTransition.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/builtin.js deleted file mode 100644 index 4964f48b53b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: > - Tests that Temporal.TimeZone.prototype.getNextTransition - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.getNextTransition), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getNextTransition), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getNextTransition), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.getNextTransition.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/instant-string-limits.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/instant-string-limits.js deleted file mode 100644 index 81f142ef7b6..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/instant-string-limits.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: String arguments at the limit of the representable range -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const minInstantStrings = [ - "-271821-04-20T00:00Z", - "-271821-04-19T23:00-01:00", - "-271821-04-19T00:00:00.000000001-23:59:59.999999999", -]; -for (const str of minInstantStrings) { - assert.sameValue(instance.getNextTransition(str), null, `instant string ${str} should be valid`); -} - -const maxInstantStrings = [ - "+275760-09-13T00:00Z", - "+275760-09-13T01:00+01:00", - "+275760-09-13T23:59:59.999999999+23:59:59.999999999", -]; - -for (const str of maxInstantStrings) { - assert.sameValue(instance.getNextTransition(str), null, `instant string ${str} should be valid`); -} - -const outOfRangeInstantStrings = [ - "-271821-04-19T23:59:59.999999999Z", - "-271821-04-19T23:00-00:59:59.999999999", - "-271821-04-19T00:00:00-23:59:59.999999999", - "-271821-04-19T00:00:00-24:00", - "+275760-09-13T00:00:00.000000001Z", - "+275760-09-13T01:00+00:59:59.999999999", - "+275760-09-14T00:00+23:59:59.999999999", - "+275760-09-14T00:00+24:00", -]; - -for (const str of outOfRangeInstantStrings) { - assert.throws(RangeError, () => instance.getNextTransition(str), `instant string ${str} should not be valid`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/instant-string.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/instant-string.js deleted file mode 100644 index 673432f46e5..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/instant-string.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Conversion of ISO date-time strings to Temporal.Instant instances -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -let str = "1970-01-01T00:00"; -assert.throws(RangeError, () => instance.getNextTransition(str), "bare date-time string is not an instant"); -str = "1970-01-01T00:00[UTC]"; -assert.throws(RangeError, () => instance.getNextTransition(str), "date-time + IANA annotation is not an instant"); - -// The following are all valid strings so should not throw: - -const valids = [ - "1970-01-01T00:00Z", - "1970-01-01T00:00+01:00", - "1970-01-01T00:00Z[UTC]", - "1970-01-01T00:00+01:00[UTC]", - "1970-01-01T00:00Z[u-ca=hebrew]", - "1970-01-01T00:00+01:00[u-ca=hebrew]", - "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]", -]; -for (const str of valids) { - const result = instance.getNextTransition(str); - assert.sameValue(result, null); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/leap-second.js deleted file mode 100644 index 44cafb81c3b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/leap-second.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Leap second is a valid ISO string for Instant -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const arg = "2016-12-31T23:59:60Z"; -const result = instance.getNextTransition(arg); -assert.sameValue( - result, - null, - "leap second is a valid ISO string for Instant" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/length.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/length.js deleted file mode 100644 index 248f2416f19..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Temporal.TimeZone.prototype.getNextTransition.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getNextTransition, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/name.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/name.js deleted file mode 100644 index 0fdb93d632c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Temporal.TimeZone.prototype.getNextTransition.name is "getNextTransition". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getNextTransition, "name", { - value: "getNextTransition", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/not-a-constructor.js deleted file mode 100644 index 5c57f04f86a..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: > - Temporal.TimeZone.prototype.getNextTransition does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.getNextTransition(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getNextTransition), false, - "isConstructor(Temporal.TimeZone.prototype.getNextTransition)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/prop-desc.js deleted file mode 100644 index 975d1bfd716..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: The "getNextTransition" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.getNextTransition, - "function", - "`typeof TimeZone.prototype.getNextTransition` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "getNextTransition", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero.js deleted file mode 100644 index 3874a284fb6..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getNextTransition/year-zero.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-03-30T00:45Z", - "-000000-03-30T01:45+01:00", - "-000000-03-30T01:45:00+00:00[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getNextTransition(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 72093a11d88..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.getOffsetNanosecondsFor(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation.js deleted file mode 100644 index 684f02a4788..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], - ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], - ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], - ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], - ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], - ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], - ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getOffsetNanosecondsFor(arg); - - assert.sameValue( - result, - 0, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 612c9cba7db..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar]", - "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getOffsetNanosecondsFor(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-date-with-utc-offset.js deleted file mode 100644 index 82bde800c9b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const validStrings = [ - "1970-01-01T00Z", - "1970-01-01T00Z[UTC]", - "1970-01-01T00Z[!UTC]", - "1970-01-01T00Z[Europe/Vienna]", - "1970-01-01T00+00:00", - "1970-01-01T00+00:00[UTC]", - "1970-01-01T00+00:00[!UTC]", - "1969-12-31T16-08:00[America/Vancouver]", -]; - -for (const arg of validStrings) { - const result = instance.getOffsetNanosecondsFor(arg); - - assert.sameValue( - result, - 0, - `"${arg}" is a valid UTC offset with time for Instant` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getOffsetNanosecondsFor(arg), - `"${arg}" UTC offset without time is not valid for Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-invalid.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-invalid.js deleted file mode 100644 index 7780706e02e..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-invalid.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as an Instant -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00T00:00Z", - "2020-01-32T00:00Z", - "2020-02-30T00:00Z", - "2021-02-29T00:00Z", - "2020-00-01T00:00Z", - "2020-13-01T00:00Z", - "2020-01-01TZ", - "2020-01-01T25:00:00Z", - "2020-01-01T01:60:00Z", - "2020-01-01T01:60:61Z", - "2020-01-01T00:00Zjunk", - "2020-01-01T00:00:00Zjunk", - "2020-01-01T00:00:00.000000000Zjunk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01T00:00Z", - "2020-001-01T00:00Z", - "2020-01-001T00:00Z", - "2020-01-01T001Z", - "2020-01-01T01:001Z", - "2020-01-01T01:01:001Z", - // valid, but forms not supported in Temporal: - "2020-W01-1T00:00Z", - "2020-001T00:00Z", - "+0002020-01-01T00:00Z", - // may be valid in other contexts, but insufficient information for Instant: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - "2020-01-01", - "2020-01-01T00", - "2020-01-01T00:00", - "2020-01-01T00:00:00", - "2020-01-01T00:00:00.000000000", - // valid, but outside the supported range: - "-999999-01-01T00:00Z", - "+999999-01-01T00:00Z", -]; - -const instance = new Temporal.TimeZone("UTC"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getOffsetNanosecondsFor(arg), - `"${arg}" should not be a valid ISO string for an Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-calendar.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-calendar.js deleted file mode 100644 index 4301e8e77b9..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-calendar.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getOffsetNanosecondsFor(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-time-zone.js deleted file mode 100644 index 2739414d204..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[UTC][UTC]", - "1970-01-01T00:00Z[!UTC][UTC]", - "1970-01-01T00:00Z[UTC][!UTC]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00Z[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getOffsetNanosecondsFor(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-separators.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-separators.js deleted file mode 100644 index c653a0fe2f8..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z", "uppercase T"], - ["1970-01-01t00:00Z", "lowercase T"], - ["1970-01-01 00:00Z", "space between date and time"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getOffsetNanosecondsFor(arg); - - assert.sameValue( - result, - 0, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-zone-annotation.js deleted file mode 100644 index 8f8d4a7d040..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], - ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], - ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], - ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], - ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], - ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], - ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], - ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getOffsetNanosecondsFor(arg); - - assert.sameValue( - result, - 0, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-unknown-annotation.js deleted file mode 100644 index 1534172c6ac..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-string-unknown-annotation.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[foo=bar]", "alone"], - ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], - ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], - ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getOffsetNanosecondsFor(arg); - - assert.sameValue( - result, - 0, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-wrong-type.js deleted file mode 100644 index 536d637accb..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: > - Appropriate error thrown when argument cannot be converted to a valid string - for Instant -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], - [{}, "plain object"], - [Temporal.Instant, "Temporal.Instant, object"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === "string" || (typeof arg === "object" && arg !== null) || typeof arg === "function" - ? RangeError - : TypeError, - () => instance.getOffsetNanosecondsFor(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString() -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.getOffsetNanosecondsFor(arg), `${description} does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-zoneddatetime.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-zoneddatetime.js deleted file mode 100644 index a69dd033415..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/argument-zoneddatetime.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Fast path for converting Temporal.ZonedDateTime to Temporal.Instant -info: | - sec-temporal.timezone.prototype.getoffsetnanosecondsfor step 3: - 3. Set _instant_ to ? ToTemporalInstant(_instant_). - sec-temporal-totemporalinstant step 1.b: - b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return ! CreateTemporalInstant(_item_.[[Nanoseconds]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalInstantFastPath((datetime) => { - const timeZone = Temporal.TimeZone.from("UTC"); - const result = timeZone.getOffsetNanosecondsFor(datetime); - assert.sameValue(result, 0, "offset result"); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/branding.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/branding.js deleted file mode 100644 index 6071b04848e..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getOffsetNanosecondsFor = Temporal.TimeZone.prototype.getOffsetNanosecondsFor; - -assert.sameValue(typeof getOffsetNanosecondsFor, "function"); - -const args = [new Temporal.Instant(0n)]; - -assert.throws(TypeError, () => getOffsetNanosecondsFor.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => getOffsetNanosecondsFor.apply(null, args), "null"); -assert.throws(TypeError, () => getOffsetNanosecondsFor.apply(true, args), "true"); -assert.throws(TypeError, () => getOffsetNanosecondsFor.apply("", args), "empty string"); -assert.throws(TypeError, () => getOffsetNanosecondsFor.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => getOffsetNanosecondsFor.apply(1, args), "1"); -assert.throws(TypeError, () => getOffsetNanosecondsFor.apply({}, args), "plain object"); -assert.throws(TypeError, () => getOffsetNanosecondsFor.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => getOffsetNanosecondsFor.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/builtin.js deleted file mode 100644 index de5637a15a7..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: > - Tests that Temporal.TimeZone.prototype.getOffsetNanosecondsFor - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.getOffsetNanosecondsFor), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getOffsetNanosecondsFor), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getOffsetNanosecondsFor), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.getOffsetNanosecondsFor.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string-limits.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string-limits.js deleted file mode 100644 index a0fbbb92e23..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string-limits.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: String arguments at the limit of the representable range -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const minInstantStrings = [ - "-271821-04-20T00:00Z", - "-271821-04-19T23:00-01:00", - "-271821-04-19T00:00:00.000000001-23:59:59.999999999", -]; -for (const str of minInstantStrings) { - assert.sameValue(instance.getOffsetNanosecondsFor(str), 0, `instant string ${str} should be valid`); -} - -const maxInstantStrings = [ - "+275760-09-13T00:00Z", - "+275760-09-13T01:00+01:00", - "+275760-09-13T23:59:59.999999999+23:59:59.999999999", -]; - -for (const str of maxInstantStrings) { - assert.sameValue(instance.getOffsetNanosecondsFor(str), 0, `instant string ${str} should be valid`); -} - -const outOfRangeInstantStrings = [ - "-271821-04-19T23:59:59.999999999Z", - "-271821-04-19T23:00-00:59:59.999999999", - "-271821-04-19T00:00:00-23:59:59.999999999", - "-271821-04-19T00:00:00-24:00", - "+275760-09-13T00:00:00.000000001Z", - "+275760-09-13T01:00+00:59:59.999999999", - "+275760-09-14T00:00+23:59:59.999999999", - "+275760-09-14T00:00+24:00", -]; - -for (const str of outOfRangeInstantStrings) { - assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), `instant string ${str} should not be valid`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string.js deleted file mode 100644 index 11530550265..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Conversion of ISO date-time strings to Temporal.Instant instances -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -let str = "1970-01-01T00:00"; -assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), "bare date-time string is not an instant"); -str = "1970-01-01T00:00[UTC]"; -assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), "date-time + IANA annotation is not an instant"); - -// The following are all valid strings so should not throw: - -const valids = [ - "1970-01-01T00:00Z", - "1970-01-01T00:00+01:00", - "1970-01-01T00:00Z[UTC]", - "1970-01-01T00:00+01:00[UTC]", - "1970-01-01T00:00Z[u-ca=hebrew]", - "1970-01-01T00:00+01:00[u-ca=hebrew]", - "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]", -]; -for (const str of valids) { - const result = instance.getOffsetNanosecondsFor(str); - assert.sameValue(result, 0); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/leap-second.js deleted file mode 100644 index 417d2d4fd4d..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/leap-second.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Leap second is a valid ISO string for Instant -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const arg = "2016-12-31T23:59:60Z"; -const result = instance.getOffsetNanosecondsFor(arg); -assert.sameValue( - result, - 0, - "leap second is a valid ISO string for Instant" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/length.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/length.js deleted file mode 100644 index 7cb07fecf70..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Temporal.TimeZone.prototype.getOffsetNanosecondsFor.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getOffsetNanosecondsFor, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/name.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/name.js deleted file mode 100644 index 79ef66486f6..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Temporal.TimeZone.prototype.getOffsetNanosecondsFor.name is "getOffsetNanosecondsFor". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getOffsetNanosecondsFor, "name", { - value: "getOffsetNanosecondsFor", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/not-a-constructor.js deleted file mode 100644 index 5d9093eee6b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: > - Temporal.TimeZone.prototype.getOffsetNanosecondsFor does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.getOffsetNanosecondsFor(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getOffsetNanosecondsFor), false, - "isConstructor(Temporal.TimeZone.prototype.getOffsetNanosecondsFor)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/prop-desc.js deleted file mode 100644 index fceac4116d3..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: The "getOffsetNanosecondsFor" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.getOffsetNanosecondsFor, - "function", - "`typeof TimeZone.prototype.getOffsetNanosecondsFor` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/year-zero.js deleted file mode 100644 index 2af428da658..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/year-zero.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-03-30T00:45Z", - "-000000-03-30T01:45+01:00", - "-000000-03-30T01:45:00+00:00[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getOffsetNanosecondsFor(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-not-absolute-getOffsetNanosecondsFor-override.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-not-absolute-getOffsetNanosecondsFor-override.js deleted file mode 100644 index 1cbebe0e6e3..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-not-absolute-getOffsetNanosecondsFor-override.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: timeZone.getOffsetNanosecondsFor not called when argument cannot be converted to Temporal.Instant -features: [Temporal] ----*/ - -const timeZone = Temporal.TimeZone.from("UTC"); -let called = false; -timeZone.getOffsetNanosecondsFor = () => called = true; -assert.throws(TypeError, () => timeZone.getOffsetStringFor(undefined), "undefined"); -assert.throws(TypeError, () => timeZone.getOffsetStringFor(null), "null"); -assert.throws(TypeError, () => timeZone.getOffsetStringFor(true), "boolean"); -assert.throws(RangeError, () => timeZone.getOffsetStringFor(""), "empty string"); -assert.throws(TypeError, () => timeZone.getOffsetStringFor(Symbol()), "Symbol"); -assert.throws(TypeError, () => timeZone.getOffsetStringFor(5), "number"); -assert.throws(TypeError, () => timeZone.getOffsetStringFor(5n), "bigint"); -assert.throws(RangeError, () => timeZone.getOffsetStringFor({}), "plain object"); -assert.sameValue(called, false); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 85567f5e5d5..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.getOffsetStringFor(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation.js deleted file mode 100644 index dfd5bc0d039..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], - ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], - ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], - ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], - ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], - ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], - ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getOffsetStringFor(arg); - - assert.sameValue( - result, - "+00:00", - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-critical-unknown-annotation.js deleted file mode 100644 index bd0210330c7..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar]", - "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getOffsetStringFor(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-date-with-utc-offset.js deleted file mode 100644 index 92263384b10..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const validStrings = [ - "1970-01-01T00Z", - "1970-01-01T00Z[UTC]", - "1970-01-01T00Z[!UTC]", - "1970-01-01T00Z[Europe/Vienna]", - "1970-01-01T00+00:00", - "1970-01-01T00+00:00[UTC]", - "1970-01-01T00+00:00[!UTC]", - "1969-12-31T16-08:00[America/Vancouver]", -]; - -for (const arg of validStrings) { - const result = instance.getOffsetStringFor(arg); - - assert.sameValue( - result, - "+00:00", - `"${arg}" is a valid UTC offset with time for Instant` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getOffsetStringFor(arg), - `"${arg}" UTC offset without time is not valid for Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-invalid.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-invalid.js deleted file mode 100644 index f3c2d266935..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-invalid.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as an Instant -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00T00:00Z", - "2020-01-32T00:00Z", - "2020-02-30T00:00Z", - "2021-02-29T00:00Z", - "2020-00-01T00:00Z", - "2020-13-01T00:00Z", - "2020-01-01TZ", - "2020-01-01T25:00:00Z", - "2020-01-01T01:60:00Z", - "2020-01-01T01:60:61Z", - "2020-01-01T00:00Zjunk", - "2020-01-01T00:00:00Zjunk", - "2020-01-01T00:00:00.000000000Zjunk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01T00:00Z", - "2020-001-01T00:00Z", - "2020-01-001T00:00Z", - "2020-01-01T001Z", - "2020-01-01T01:001Z", - "2020-01-01T01:01:001Z", - // valid, but forms not supported in Temporal: - "2020-W01-1T00:00Z", - "2020-001T00:00Z", - "+0002020-01-01T00:00Z", - // may be valid in other contexts, but insufficient information for Instant: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - "2020-01-01", - "2020-01-01T00", - "2020-01-01T00:00", - "2020-01-01T00:00:00", - "2020-01-01T00:00:00.000000000", - // valid, but outside the supported range: - "-999999-01-01T00:00Z", - "+999999-01-01T00:00Z", -]; - -const instance = new Temporal.TimeZone("UTC"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getOffsetStringFor(arg), - `"${arg}" should not be a valid ISO string for an Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-calendar.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-calendar.js deleted file mode 100644 index d190bbdcdb9..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-calendar.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getOffsetStringFor(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-time-zone.js deleted file mode 100644 index 080c8119adc..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[UTC][UTC]", - "1970-01-01T00:00Z[!UTC][UTC]", - "1970-01-01T00:00Z[UTC][!UTC]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00Z[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getOffsetStringFor(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-separators.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-separators.js deleted file mode 100644 index 255947ddfde..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z", "uppercase T"], - ["1970-01-01t00:00Z", "lowercase T"], - ["1970-01-01 00:00Z", "space between date and time"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getOffsetStringFor(arg); - - assert.sameValue( - result, - "+00:00", - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-zone-annotation.js deleted file mode 100644 index ce875963970..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], - ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], - ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], - ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], - ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], - ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], - ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], - ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getOffsetStringFor(arg); - - assert.sameValue( - result, - "+00:00", - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-unknown-annotation.js deleted file mode 100644 index 46666bda446..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-string-unknown-annotation.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[foo=bar]", "alone"], - ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], - ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], - ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getOffsetStringFor(arg); - - assert.sameValue( - result, - "+00:00", - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-wrong-type.js deleted file mode 100644 index 9a070edc31c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: > - Appropriate error thrown when argument cannot be converted to a valid string - for Instant -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], - [{}, "plain object"], - [Temporal.Instant, "Temporal.Instant, object"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === "string" || (typeof arg === "object" && arg !== null) || typeof arg === "function" - ? RangeError - : TypeError, - () => instance.getOffsetStringFor(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString() -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.getOffsetStringFor(arg), `${description} does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-zoneddatetime.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-zoneddatetime.js deleted file mode 100644 index 1169032902c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/argument-zoneddatetime.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Fast path for converting Temporal.ZonedDateTime to Temporal.Instant -info: | - sec-temporal.timezone.prototype.getoffsetstringfor step 3: - 3. Set _instant_ to ? ToTemporalInstant(_instant_). - sec-temporal-totemporalinstant step 1.b: - b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return ! CreateTemporalInstant(_item_.[[Nanoseconds]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalInstantFastPath((datetime) => { - const timeZone = Temporal.TimeZone.from("UTC"); - const result = timeZone.getOffsetStringFor(datetime); - assert.sameValue(result, "+00:00", "offset result"); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/basic.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/basic.js deleted file mode 100644 index 184bb12a20b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/basic.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Basic tests for Temporal.TimeZone.prototype.getOffsetStringFor -features: [BigInt, Temporal] ----*/ - -const instant = new Temporal.Instant(0n); - -function test(timeZoneIdentifier, expectedOffsetString, description) { - const timeZone = new Temporal.TimeZone(timeZoneIdentifier); - assert.sameValue(timeZone.getOffsetStringFor(instant), expectedOffsetString, description); -} - -test("UTC", "+00:00", "offset of UTC is +00:00"); -test("+01:00", "+01:00", "positive offset"); -test("-05:00", "-05:00", "negative offset"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/branding.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/branding.js deleted file mode 100644 index 1017cda02c0..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getOffsetStringFor = Temporal.TimeZone.prototype.getOffsetStringFor; - -assert.sameValue(typeof getOffsetStringFor, "function"); - -const args = [new Temporal.Instant(0n)]; - -assert.throws(TypeError, () => getOffsetStringFor.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => getOffsetStringFor.apply(null, args), "null"); -assert.throws(TypeError, () => getOffsetStringFor.apply(true, args), "true"); -assert.throws(TypeError, () => getOffsetStringFor.apply("", args), "empty string"); -assert.throws(TypeError, () => getOffsetStringFor.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => getOffsetStringFor.apply(1, args), "1"); -assert.throws(TypeError, () => getOffsetStringFor.apply({}, args), "plain object"); -assert.throws(TypeError, () => getOffsetStringFor.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => getOffsetStringFor.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/builtin.js deleted file mode 100644 index 9d090b07f39..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: > - Tests that Temporal.TimeZone.prototype.getOffsetStringFor - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.getOffsetStringFor), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getOffsetStringFor), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getOffsetStringFor), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.getOffsetStringFor.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string-limits.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string-limits.js deleted file mode 100644 index 02a4200b393..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string-limits.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: String arguments at the limit of the representable range -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const minInstantStrings = [ - "-271821-04-20T00:00Z", - "-271821-04-19T23:00-01:00", - "-271821-04-19T00:00:00.000000001-23:59:59.999999999", -]; -for (const str of minInstantStrings) { - assert.sameValue(instance.getOffsetStringFor(str), "+00:00", `instant string ${str} should be valid`); -} - -const maxInstantStrings = [ - "+275760-09-13T00:00Z", - "+275760-09-13T01:00+01:00", - "+275760-09-13T23:59:59.999999999+23:59:59.999999999", -]; - -for (const str of maxInstantStrings) { - assert.sameValue(instance.getOffsetStringFor(str), "+00:00", `instant string ${str} should be valid`); -} - -const outOfRangeInstantStrings = [ - "-271821-04-19T23:59:59.999999999Z", - "-271821-04-19T23:00-00:59:59.999999999", - "-271821-04-19T00:00:00-23:59:59.999999999", - "-271821-04-19T00:00:00-24:00", - "+275760-09-13T00:00:00.000000001Z", - "+275760-09-13T01:00+00:59:59.999999999", - "+275760-09-14T00:00+23:59:59.999999999", - "+275760-09-14T00:00+24:00", -]; - -for (const str of outOfRangeInstantStrings) { - assert.throws(RangeError, () => instance.getOffsetStringFor(str), `instant string ${str} should not be valid`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string.js deleted file mode 100644 index b79e1c1e6f1..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Conversion of ISO date-time strings to Temporal.Instant instances -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -let str = "1970-01-01T00:00"; -assert.throws(RangeError, () => instance.getOffsetStringFor(str), "bare date-time string is not an instant"); -str = "1970-01-01T00:00[UTC]"; -assert.throws(RangeError, () => instance.getOffsetStringFor(str), "date-time + IANA annotation is not an instant"); - -// The following are all valid strings so should not throw: - -const valids = [ - "1970-01-01T00:00Z", - "1970-01-01T00:00+01:00", - "1970-01-01T00:00Z[UTC]", - "1970-01-01T00:00+01:00[UTC]", - "1970-01-01T00:00Z[u-ca=hebrew]", - "1970-01-01T00:00+01:00[u-ca=hebrew]", - "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]", -]; -for (const str of valids) { - const result = instance.getOffsetStringFor(str); - assert.sameValue(result, "+00:00"); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/leap-second.js deleted file mode 100644 index eac9e7c63c3..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/leap-second.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Leap second is a valid ISO string for Instant -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const arg = "2016-12-31T23:59:60Z"; -const result = instance.getOffsetStringFor(arg); -assert.sameValue( - result, - "+00:00", - "leap second is a valid ISO string for Instant" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/length.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/length.js deleted file mode 100644 index f8bb1d7b0b3..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Temporal.TimeZone.prototype.getOffsetStringFor.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getOffsetStringFor, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/name.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/name.js deleted file mode 100644 index 0be05ed49d2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Temporal.TimeZone.prototype.getOffsetStringFor.name is "getOffsetStringFor". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getOffsetStringFor, "name", { - value: "getOffsetStringFor", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/not-a-constructor.js deleted file mode 100644 index a2b65b5f4a1..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: > - Temporal.TimeZone.prototype.getOffsetStringFor does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.getOffsetStringFor(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getOffsetStringFor), false, - "isConstructor(Temporal.TimeZone.prototype.getOffsetStringFor)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/prop-desc.js deleted file mode 100644 index 7840a891755..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: The "getOffsetStringFor" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.getOffsetStringFor, - "function", - "`typeof TimeZone.prototype.getOffsetStringFor` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "getOffsetStringFor", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index e9c1270dfd6..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - assert.throws(RangeError, () => timeZone.getOffsetStringFor(instant)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 50f0aecbdc5..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => timeZone.getOffsetStringFor(instant), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index c839cc5ddbc..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - assert.throws(RangeError, () => timeZone.getOffsetStringFor(instant)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 4fd73d5c513..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - assert.throws(TypeError, () => timeZone.getOffsetStringFor(instant)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/year-zero.js deleted file mode 100644 index a0933319900..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getOffsetStringFor/year-zero.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-03-30T00:45Z", - "-000000-03-30T01:45+01:00", - "-000000-03-30T01:45:00+00:00[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getOffsetStringFor(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-negative-epochnanoseconds.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-negative-epochnanoseconds.js deleted file mode 100644 index a87df234357..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-negative-epochnanoseconds.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: A pre-epoch value is handled correctly by the modulo operation in GetISOPartsFromEpoch -info: | - sec-temporal-getisopartsfromepoch step 1: - 1. Let _remainderNs_ be the mathematical value whose sign is the sign of _epochNanoseconds_ and whose magnitude is abs(_epochNanoseconds_) modulo 106. - sec-temporal-builtintimezonegetplaindatetimefor step 2: - 2. Let _result_ be ! GetISOPartsFromEpoch(_instant_.[[Nanoseconds]]). -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const instant = new Temporal.Instant(-13849764_999_999_999n); - -// This code path shows up anywhere we convert an exact time, before the Unix -// epoch, with nonzero microseconds or nanoseconds, into a wall time. - -const instance = new Temporal.TimeZone("UTC"); -const result = instance.getPlainDateTimeFor(instant); -TemporalHelpers.assertPlainDateTime(result, 1969, 7, "M07", 24, 16, 50, 35, 0, 0, 1); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-not-absolute-getOffsetNanosecondsFor-override.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-not-absolute-getOffsetNanosecondsFor-override.js deleted file mode 100644 index c3b94ef1f41..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-not-absolute-getOffsetNanosecondsFor-override.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: timeZone.getOffsetNanosecondsFor not called when argument cannot be converted to Temporal.Instant -features: [Temporal] ----*/ - -const timeZone = Temporal.TimeZone.from("UTC"); -let called = false; -timeZone.getOffsetNanosecondsFor = () => called = true; -assert.throws(TypeError, () => timeZone.getPlainDateTimeFor(undefined), "undefined"); -assert.throws(TypeError, () => timeZone.getPlainDateTimeFor(null), "null"); -assert.throws(TypeError, () => timeZone.getPlainDateTimeFor(true), "boolean"); -assert.throws(RangeError, () => timeZone.getPlainDateTimeFor(""), "empty string"); -assert.throws(TypeError, () => timeZone.getPlainDateTimeFor(Symbol()), "Symbol"); -assert.throws(TypeError, () => timeZone.getPlainDateTimeFor(5), "number"); -assert.throws(TypeError, () => timeZone.getPlainDateTimeFor(5n), "bigint"); -assert.throws(RangeError, () => timeZone.getPlainDateTimeFor({}), "plain object"); -assert.sameValue(called, false); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-object-tostring.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-object-tostring.js deleted file mode 100644 index f2cdde15964..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-object-tostring.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Object is converted to a string, then to Temporal.Instant -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const arg = {}; -assert.throws(RangeError, () => instance.getPlainDateTimeFor(arg), "[object Object] is not a valid ISO string"); - -arg.toString = function() { - return "1970-01-01T00:00Z"; -}; -const result = instance.getPlainDateTimeFor(arg); -TemporalHelpers.assertPlainDateTime(result, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "result of toString is interpreted as ISO string"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 2708de707a9..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.getPlainDateTimeFor(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation.js deleted file mode 100644 index c5a032b4048..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-calendar-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], - ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], - ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], - ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], - ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], - ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], - ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPlainDateTimeFor(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-critical-unknown-annotation.js deleted file mode 100644 index b527f247ad0..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar]", - "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPlainDateTimeFor(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-date-with-utc-offset.js deleted file mode 100644 index 23c2f1a5b3f..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: UTC offset not valid with format that does not include a time -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const validStrings = [ - "1970-01-01T00Z", - "1970-01-01T00Z[UTC]", - "1970-01-01T00Z[!UTC]", - "1970-01-01T00Z[Europe/Vienna]", - "1970-01-01T00+00:00", - "1970-01-01T00+00:00[UTC]", - "1970-01-01T00+00:00[!UTC]", - "1969-12-31T16-08:00[America/Vancouver]", -]; - -for (const arg of validStrings) { - const result = instance.getPlainDateTimeFor(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, - `"${arg}" is a valid UTC offset with time for Instant` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getPlainDateTimeFor(arg), - `"${arg}" UTC offset without time is not valid for Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-invalid.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-invalid.js deleted file mode 100644 index 8d114f824ea..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-invalid.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as an Instant -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00T00:00Z", - "2020-01-32T00:00Z", - "2020-02-30T00:00Z", - "2021-02-29T00:00Z", - "2020-00-01T00:00Z", - "2020-13-01T00:00Z", - "2020-01-01TZ", - "2020-01-01T25:00:00Z", - "2020-01-01T01:60:00Z", - "2020-01-01T01:60:61Z", - "2020-01-01T00:00Zjunk", - "2020-01-01T00:00:00Zjunk", - "2020-01-01T00:00:00.000000000Zjunk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01T00:00Z", - "2020-001-01T00:00Z", - "2020-01-001T00:00Z", - "2020-01-01T001Z", - "2020-01-01T01:001Z", - "2020-01-01T01:01:001Z", - // valid, but forms not supported in Temporal: - "2020-W01-1T00:00Z", - "2020-001T00:00Z", - "+0002020-01-01T00:00Z", - // may be valid in other contexts, but insufficient information for Instant: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - "2020-01-01", - "2020-01-01T00", - "2020-01-01T00:00", - "2020-01-01T00:00:00", - "2020-01-01T00:00:00.000000000", - // valid, but outside the supported range: - "-999999-01-01T00:00Z", - "+999999-01-01T00:00Z", -]; - -const instance = new Temporal.TimeZone("UTC"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getPlainDateTimeFor(arg), - `"${arg}" should not be a valid ISO string for an Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-calendar.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-calendar.js deleted file mode 100644 index eeb2ce24b42..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-calendar.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPlainDateTimeFor(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-time-zone.js deleted file mode 100644 index 875971d3304..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[UTC][UTC]", - "1970-01-01T00:00Z[!UTC][UTC]", - "1970-01-01T00:00Z[UTC][!UTC]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00Z[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPlainDateTimeFor(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-separators.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-separators.js deleted file mode 100644 index 8e80217cf47..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-separators.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Time separator in string argument can vary -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["1970-01-01T00:00Z", "uppercase T"], - ["1970-01-01t00:00Z", "lowercase T"], - ["1970-01-01 00:00Z", "space between date and time"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPlainDateTimeFor(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-zone-annotation.js deleted file mode 100644 index ec4feff5a31..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], - ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], - ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], - ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], - ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], - ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], - ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], - ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPlainDateTimeFor(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-unknown-annotation.js deleted file mode 100644 index 89983064f38..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Various forms of unknown annotation -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[foo=bar]", "alone"], - ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], - ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], - ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPlainDateTimeFor(arg); - - TemporalHelpers.assertPlainDateTime( - result, - 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-wrong-type.js deleted file mode 100644 index 94a5fab8ae7..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: > - Appropriate error thrown when argument cannot be converted to a valid string - for Instant -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], - [{}, "plain object"], - [Temporal.Instant, "Temporal.Instant, object"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === "string" || (typeof arg === "object" && arg !== null) || typeof arg === "function" - ? RangeError - : TypeError, - () => instance.getPlainDateTimeFor(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString() -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.getPlainDateTimeFor(arg), `${description} does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-zoneddatetime.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-zoneddatetime.js deleted file mode 100644 index a9e8551b417..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/argument-zoneddatetime.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Fast path for converting Temporal.ZonedDateTime to Temporal.Instant -info: | - sec-temporal.timezone.prototype.getplaindatetimefor step 2: - 2. Set _instant_ to ? ToTemporalInstant(_instant_). - sec-temporal-totemporalinstant step 1.b: - b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return ! CreateTemporalInstant(_item_.[[Nanoseconds]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalInstantFastPath((datetime) => { - const timeZone = Temporal.TimeZone.from("UTC"); - const result = timeZone.getPlainDateTimeFor(datetime); - TemporalHelpers.assertPlainDateTime(result, 2001, 9, "M09", 9, 1, 46, 40, 987, 654, 321); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/balance-negative-time-units.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/balance-negative-time-units.js deleted file mode 100644 index 80eb51d64ff..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/balance-negative-time-units.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Negative time fields are balanced upwards -info: | - sec-temporal-balancetime steps 3–14: - 3. Set _microsecond_ to _microsecond_ + floor(_nanosecond_ / 1000). - 4. Set _nanosecond_ to _nanosecond_ modulo 1000. - 5. Set _millisecond_ to _millisecond_ + floor(_microsecond_ / 1000). - 6. Set _microsecond_ to _microsecond_ modulo 1000. - 7. Set _second_ to _second_ + floor(_millisecond_ / 1000). - 8. Set _millisecond_ to _millisecond_ modulo 1000. - 9. Set _minute_ to _minute_ + floor(_second_ / 60). - 10. Set _second_ to _second_ modulo 60. - 11. Set _hour_ to _hour_ + floor(_minute_ / 60). - 12. Set _minute_ to _minute_ modulo 60. - 13. Let _days_ be floor(_hour_ / 24). - 14. Set _hour_ to _hour_ modulo 24. - sec-temporal-balanceisodatetime step 1: - 1. Let _balancedTime_ be ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). - sec-temporal-builtintimezonegetplaindatetimefor step 3: - 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). - sec-get-temporal.timezone.prototype.getplaindatetimefor step 4: - 4. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// This code path is encountered if the time zone offset is negative and its -// absolute value in nanoseconds is greater than the nanosecond field of the -// exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const instant = new Temporal.Instant(1001n); - -const pdt = tz.getPlainDateTimeFor(instant); - -TemporalHelpers.assertPlainDateTime(pdt, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 999); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/branding.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/branding.js deleted file mode 100644 index 55dce1041c9..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getPlainDateTimeFor = Temporal.TimeZone.prototype.getPlainDateTimeFor; - -assert.sameValue(typeof getPlainDateTimeFor, "function"); - -const args = [new Temporal.Instant(0n)]; - -assert.throws(TypeError, () => getPlainDateTimeFor.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => getPlainDateTimeFor.apply(null, args), "null"); -assert.throws(TypeError, () => getPlainDateTimeFor.apply(true, args), "true"); -assert.throws(TypeError, () => getPlainDateTimeFor.apply("", args), "empty string"); -assert.throws(TypeError, () => getPlainDateTimeFor.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => getPlainDateTimeFor.apply(1, args), "1"); -assert.throws(TypeError, () => getPlainDateTimeFor.apply({}, args), "plain object"); -assert.throws(TypeError, () => getPlainDateTimeFor.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => getPlainDateTimeFor.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/builtin.js deleted file mode 100644 index 26ce3f02fbd..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: > - Tests that Temporal.TimeZone.prototype.getPlainDateTimeFor - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.getPlainDateTimeFor), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getPlainDateTimeFor), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getPlainDateTimeFor), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.getPlainDateTimeFor.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-case-insensitive.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-case-insensitive.js deleted file mode 100644 index 0cc75d0e91a..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-case-insensitive.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Calendar names are case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const arg = "iSo8601"; -const result = instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg); -assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-iso-string.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-iso-string.js deleted file mode 100644 index 0eff62ba92b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-iso-string.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -for (const arg of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const result = instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg); - assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-number.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-number.js deleted file mode 100644 index 9deb3a0f323..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: A number is not allowed to be a calendar -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const numbers = [ - 1, - -19761118, - 19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg), - "A number is not a valid ISO string for Calendar" - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-string-leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-string-leap-second.js deleted file mode 100644 index efd79853de2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-string-leap-second.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Leap second is a valid ISO string for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const arg = "2016-12-31T23:59:60"; -const result = instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg); -assert.sameValue( - result.calendarId, - "iso8601", - "leap second is a valid ISO string for Calendar" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-string.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-string.js deleted file mode 100644 index fe3d4932a2c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-string.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const arg = "iso8601"; - -const result = instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-temporal-object.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-temporal-object.js deleted file mode 100644 index 345d50f60b3..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-temporal-object.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const instance = new Temporal.TimeZone("UTC"); - const result = instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-undefined.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-undefined.js deleted file mode 100644 index 6c0d705436f..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-undefined.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Calendar argument defaults to the built-in ISO 8601 calendar -features: [Temporal] ----*/ - -const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456789Z"); -const timeZone = Temporal.TimeZone.from("UTC"); - -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not call Calendar.from"); - }, -}); - -const result1 = timeZone.getPlainDateTimeFor(instant); -assert.sameValue(result1.calendarId, "iso8601"); - -const result2 = timeZone.getPlainDateTimeFor(instant, undefined); -assert.sameValue(result2.calendarId, "iso8601"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-wrong-type.js deleted file mode 100644 index f4084d60ad4..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/calendar-wrong-type.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.getPlainDateTimeFor(new Temporal.Instant(0n), arg), `${description} is not a valid object and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/custom-timezone.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/custom-timezone.js deleted file mode 100644 index 906d3dfef89..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/custom-timezone.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: getOffsetNanosecondsFor is called by getPlainDateTimeFor -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "get getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", -]; - -const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456789Z"); -const timeZone = new Temporal.TimeZone("UTC"); -TemporalHelpers.observeProperty(actual, timeZone, "getOffsetNanosecondsFor", function (instantArg) { - actual.push("call timeZone.getOffsetNanosecondsFor"); - assert.sameValue(instantArg, instant); - return 9876543210123; -}); - -const result = timeZone.getPlainDateTimeFor(instant); -TemporalHelpers.assertPlainDateTime(result, 1975, 2, "M02", 2, 17, 10, 12, 666, 666, 912); -assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-limits.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-limits.js deleted file mode 100644 index 65b5de1c9ef..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-limits.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: String arguments at the limit of the representable range -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const minInstantStrings = [ - "-271821-04-20T00:00Z", - "-271821-04-19T23:00-01:00", - "-271821-04-19T00:00:00.000000001-23:59:59.999999999", -]; -for (const str of minInstantStrings) { - TemporalHelpers.assertPlainDateTime(instance.getPlainDateTimeFor(str), -271821, 4, "M04", 20, 0, 0, 0, 0, 0, 0, `instant string ${str} should be valid`); -} - -const maxInstantStrings = [ - "+275760-09-13T00:00Z", - "+275760-09-13T01:00+01:00", - "+275760-09-13T23:59:59.999999999+23:59:59.999999999", -]; - -for (const str of maxInstantStrings) { - TemporalHelpers.assertPlainDateTime(instance.getPlainDateTimeFor(str), 275760, 9, "M09", 13, 0, 0, 0, 0, 0, 0, `instant string ${str} should be valid`); -} - -const outOfRangeInstantStrings = [ - "-271821-04-19T23:59:59.999999999Z", - "-271821-04-19T23:00-00:59:59.999999999", - "-271821-04-19T00:00:00-23:59:59.999999999", - "-271821-04-19T00:00:00-24:00", - "+275760-09-13T00:00:00.000000001Z", - "+275760-09-13T01:00+00:59:59.999999999", - "+275760-09-14T00:00+23:59:59.999999999", - "+275760-09-14T00:00+24:00", -]; - -for (const str of outOfRangeInstantStrings) { - assert.throws(RangeError, () => instance.getPlainDateTimeFor(str), `instant string ${str} should not be valid`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-multiple-offsets.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-multiple-offsets.js deleted file mode 100644 index e7abec396e1..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-multiple-offsets.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Instant strings with UTC offset fractional part are not confused with time fractional part -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); -const str = "1970-01-01T00:02:00.000000000+00:02[+01:30]"; - -const result = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "UTC offset determined from offset part of string"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-sub-minute-offset.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-sub-minute-offset.js deleted file mode 100644 index be7af0b1368..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string-sub-minute-offset.js +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Temporal.Instant string with sub-minute offset -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const str = "1970-01-01T00:19:32.37+00:19:32.37"; -const result = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "if present, sub-minute offset is accepted exactly"); - -[ - "2021-08-19T17:30-07:00:01[-07:00:01]", - "2021-08-19T17:30-07:00:00[-07:00:00]", - "2021-08-19T17:30-07:00:00.1[-07:00:00.1]", - "2021-08-19T17:30-07:00:00.0[-07:00:00.0]", - "2021-08-19T17:30-07:00:00.01[-07:00:00.01]", - "2021-08-19T17:30-07:00:00.00[-07:00:00.00]", - "2021-08-19T17:30-07:00:00.001[-07:00:00.001]", - "2021-08-19T17:30-07:00:00.000[-07:00:00.000]", - "2021-08-19T17:30-07:00:00.0001[-07:00:00.0001]", - "2021-08-19T17:30-07:00:00.0000[-07:00:00.0000]", - "2021-08-19T17:30-07:00:00.00001[-07:00:00.00001]", - "2021-08-19T17:30-07:00:00.00000[-07:00:00.00000]", - "2021-08-19T17:30-07:00:00.000001[-07:00:00.000001]", - "2021-08-19T17:30-07:00:00.000000[-07:00:00.000000]", - "2021-08-19T17:30-07:00:00.0000001[-07:00:00.0000001]", - "2021-08-19T17:30-07:00:00.0000000[-07:00:00.0000000]", - "2021-08-19T17:30-07:00:00.00000001[-07:00:00.00000001]", - "2021-08-19T17:30-07:00:00.00000000[-07:00:00.00000000]", - "2021-08-19T17:30-07:00:00.000000001[-07:00:00.000000001]", - "2021-08-19T17:30-07:00:00.000000000[-07:00:00.000000000]", - - "2021-08-19T17:30-07:00:01[-070001]", - "2021-08-19T17:30-07:00:00[-070000]", - "2021-08-19T17:30-07:00:00.1[-070000.1]", - "2021-08-19T17:30-07:00:00.0[-070000.0]", - "2021-08-19T17:30-07:00:00.01[-070000.01]", - "2021-08-19T17:30-07:00:00.00[-070000.00]", - "2021-08-19T17:30-07:00:00.001[-070000.001]", - "2021-08-19T17:30-07:00:00.000[-070000.000]", - "2021-08-19T17:30-07:00:00.0001[-070000.0001]", - "2021-08-19T17:30-07:00:00.0000[-070000.0000]", - "2021-08-19T17:30-07:00:00.00001[-070000.00001]", - "2021-08-19T17:30-07:00:00.00000[-070000.00000]", - "2021-08-19T17:30-07:00:00.000001[-070000.000001]", - "2021-08-19T17:30-07:00:00.000000[-070000.000000]", - "2021-08-19T17:30-07:00:00.0000001[-070000.0000001]", - "2021-08-19T17:30-07:00:00.0000000[-070000.0000000]", - "2021-08-19T17:30-07:00:00.00000001[-070000.00000001]", - "2021-08-19T17:30-07:00:00.00000000[-070000.00000000]", - "2021-08-19T17:30-07:00:00.000000001[-070000.000000001]", - "2021-08-19T17:30-07:00:00.000000000[-070000.000000000]" -].forEach((str) => { - assert.throws( - RangeError, - () => instance.getPlainDateTimeFor(str), - `ISO strings cannot have sub-minute offsets in time zone annotations: ${str}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string.js deleted file mode 100644 index 4299e729a50..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Conversion of ISO date-time strings to Temporal.Instant instances -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -let str = "1970-01-01T00:00"; -assert.throws(RangeError, () => instance.getPlainDateTimeFor(str), "bare date-time string is not an instant"); -str = "1970-01-01T00:00[UTC]"; -assert.throws(RangeError, () => instance.getPlainDateTimeFor(str), "date-time + IANA annotation is not an instant"); - -str = "1970-01-01T00:00Z"; -const result1 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result1, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "date-time + Z preserves exact time"); - -str = "1970-01-01T00:00+01:00"; -const result2 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result2, 1969, 12, "M12", 31, 23, 0, 0, 0, 0, 0, "date-time + offset preserves exact time with offset"); - -str = "1970-01-01T00:00Z[Etc/Ignored]"; -const result3 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result3, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation ignores the IANA annotation"); - -str = "1970-01-01T00:00+01:00[Etc/Ignored]"; -const result4 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result4, 1969, 12, "M12", 31, 23, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation ignores the IANA annotation"); - -str = "1970-01-01T00:00Z[u-ca=hebrew]"; -const result6 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result6, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 0, "date-time + Z + Calendar ignores the Calendar"); - -str = "1970-01-01T00:00+01:00[u-ca=hebrew]"; -const result5 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result5, 1969, 12, "M12", 31, 23, 0, 0, 0, 0, 0, "date-time + offset + Calendar ignores the Calendar"); - -str = "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]"; -const result7 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result7, 1969, 12, "M12", 31, 23, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation + Calendar ignores the Calendar and IANA annotation"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/leap-second.js deleted file mode 100644 index f17224284ae..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/leap-second.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Leap second is a valid ISO string for Instant -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const arg = "2016-12-31T23:59:60Z"; -const result = instance.getPlainDateTimeFor(arg); -TemporalHelpers.assertPlainDateTime( - result, - 2016, 12, "M12", 31, 23, 59, 59, 0, 0, 0, - "leap second is a valid ISO string for Instant" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/length.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/length.js deleted file mode 100644 index e30cab7528a..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Temporal.TimeZone.prototype.getPlainDateTimeFor.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getPlainDateTimeFor, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/limits.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/limits.js deleted file mode 100644 index 24a970573df..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/limits.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.getplaindatetimefor -description: Checking limits of representable PlainDateTime -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -const min = new Temporal.Instant(-8_640_000_000_000_000_000_000n); -const offsetMin = new Temporal.TimeZone("-23:59"); -const max = new Temporal.Instant(8_640_000_000_000_000_000_000n); -const offsetMax = new Temporal.TimeZone("+23:59"); - -TemporalHelpers.assertPlainDateTime( - offsetMin.getPlainDateTimeFor(min, "iso8601"), - -271821, 4, "M04", 19, 0, 1, 0, 0, 0, 0, - "converting from Instant (negative case)" -); - -TemporalHelpers.assertPlainDateTime( - offsetMax.getPlainDateTimeFor(max, "iso8601"), - 275760, 9, "M09", 13, 23, 59, 0, 0, 0, 0, - "converting from Instant (positive case)" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/name.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/name.js deleted file mode 100644 index 5e0b9b08af9..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Temporal.TimeZone.prototype.getPlainDateTimeFor.name is "getPlainDateTimeFor". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getPlainDateTimeFor, "name", { - value: "getPlainDateTimeFor", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/not-a-constructor.js deleted file mode 100644 index 4c5226e1708..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: > - Temporal.TimeZone.prototype.getPlainDateTimeFor does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.getPlainDateTimeFor(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getPlainDateTimeFor), false, - "isConstructor(Temporal.TimeZone.prototype.getPlainDateTimeFor)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/pre-epoch.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/pre-epoch.js deleted file mode 100644 index 4dddb892bb6..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/pre-epoch.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Test of basic functionality for an exact time earlier than the Unix epoch -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instant = Temporal.Instant.from("1969-07-16T13:32:01.234567891Z"); -assert.sameValue(instant.toString(), "1969-07-16T13:32:01.234567891Z"); -const timeZone = Temporal.TimeZone.from("-04:00"); -const dateTime = timeZone.getPlainDateTimeFor(instant); -TemporalHelpers.assertPlainDateTime(dateTime, 1969, 7, "M07", 16, 9, 32, 1, 234, 567, 891); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/prop-desc.js deleted file mode 100644 index fb9003568ca..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: The "getPlainDateTimeFor" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.getPlainDateTimeFor, - "function", - "`typeof TimeZone.prototype.getPlainDateTimeFor` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "getPlainDateTimeFor", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index e6c3ef76238..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - assert.throws(RangeError, () => timeZone.getPlainDateTimeFor(instant)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 0b4b6ce4b2c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => timeZone.getPlainDateTimeFor(instant), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 7e641caf05b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - assert.throws(RangeError, () => timeZone.getPlainDateTimeFor(instant)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index eb2bb198bdf..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const instant = new Temporal.Instant(1_000_000_000_987_654_321n); - assert.throws(TypeError, () => timeZone.getPlainDateTimeFor(instant)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero.js deleted file mode 100644 index aa2b02626e8..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPlainDateTimeFor/year-zero.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-03-30T00:45Z", - "-000000-03-30T01:45+01:00", - "-000000-03-30T01:45:00+00:00[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPlainDateTimeFor(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 628f2b6b5a5..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.TimeZone("UTC"); -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, calendar: "iso8601" }; -instance.getPossibleInstantsFor(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-not-datetime.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-not-datetime.js deleted file mode 100644 index 9d243db4a1c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-not-datetime.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Appropriate error thrown when argument cannot be converted to Temporal.PlainDateTime -features: [Temporal] ----*/ - -const timeZone = Temporal.TimeZone.from("UTC"); -assert.throws(TypeError, () => timeZone.getPossibleInstantsFor(undefined), "undefined"); -assert.throws(TypeError, () => timeZone.getPossibleInstantsFor(null), "null"); -assert.throws(TypeError, () => timeZone.getPossibleInstantsFor(true), "boolean"); -assert.throws(RangeError, () => timeZone.getPossibleInstantsFor(""), "empty string"); -assert.throws(TypeError, () => timeZone.getPossibleInstantsFor(Symbol()), "Symbol"); -assert.throws(TypeError, () => timeZone.getPossibleInstantsFor(5), "number"); -assert.throws(TypeError, () => timeZone.getPossibleInstantsFor(5n), "bigint"); -assert.throws(TypeError, () => timeZone.getPossibleInstantsFor({}), "plain object"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-number.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-number.js deleted file mode 100644 index 306b3f24fe4..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: A number cannot be used in place of a Temporal.PlainDateTime -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.getPossibleInstantsFor(arg), - `A number (${arg}) is not a valid ISO string for PlainDateTime` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-plaindate.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-plaindate.js deleted file mode 100644 index d916b5c4997..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-plaindate.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.until -description: Fast path for converting Temporal.PlainDate to Temporal.PlainDateTime by reading internal slots -info: | - sec-temporal.timezone.prototype.getpossibleinstantsfor step 3: - 3. Set _dateTime_ to ? ToTemporalDateTime(_dateTime_). - sec-temporal-totemporaldatetime step 2.b: - b. If _item_ has an [[InitializedTemporalDate]] internal slot, then - i. Return ? CreateTemporalDateTime(_item_.[[ISOYear]], _item_.[[ISOMonth]], _item_.[[ISODay]], 0, 0, 0, 0, 0, 0, _item_.[[Calendar]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalPlainDateTimeFastPath((date) => { - const timezone = new Temporal.TimeZone("UTC"); - const result = timezone.getPossibleInstantsFor(date); - assert.sameValue(result.length, 1, "one possible instant"); - assert.sameValue(result[0].epochNanoseconds, 957_225_600_000_000_000n, "epochNanoseconds result"); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 9c2c3cf78e9..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: The calendar name is case-insensitive -includes: [compareArray.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.getPossibleInstantsFor(arg); -assert.compareArray(result.map(i => i.epochNanoseconds), [217_123_200_000_000_000n], "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index fa837475959..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: An ISO 8601 string can be converted to a calendar ID in Calendar -includes: [compareArray.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.getPossibleInstantsFor(arg); - assert.compareArray(result.map(i => i.epochNanoseconds), [217_123_200_000_000_000n], `Calendar created from string "${calendar}"`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 84de55acbc6..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Leap second is a valid ISO string for a calendar in a property bag -includes: [compareArray.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.getPossibleInstantsFor(arg); -assert.compareArray( - result.map(i => i.epochNanoseconds), - [217_123_200_000_000_000n], - "leap second is a valid ISO string for calendar" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-number.js deleted file mode 100644 index 3f404de7409..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.getPossibleInstantsFor(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-string.js deleted file mode 100644 index 1bdd88042d9..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: A calendar ID is valid input for Calendar -includes: [compareArray.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.getPossibleInstantsFor(arg); -assert.compareArray(result.map(i => i.epochNanoseconds), [217_123_200_000_000_000n], `Calendar created from string "${calendar}"`); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 31643beedaf..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.getPossibleInstantsFor(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.getPossibleInstantsFor(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 4a9389ca8b0..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.getPossibleInstantsFor(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index ebbf696eacd..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01T00:00[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01T00:00[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.getPossibleInstantsFor(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation.js deleted file mode 100644 index 4b18b0f3e45..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-calendar-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] -includes: [compareArray.js] ----*/ - -const tests = [ - ["1976-11-18T15:23[u-ca=iso8601]", "without time zone"], - ["1976-11-18T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["1976-11-18T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["1976-11-18T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["1976-11-18T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPossibleInstantsFor(arg); - - assert.compareArray( - result.map(i => i.epochNanoseconds), - [217_178_580_000_000_000n], - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 972e3b4e30b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPossibleInstantsFor(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-date-with-utc-offset.js deleted file mode 100644 index 11239a95502..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: UTC offset not valid with format that does not include a time -features: [Temporal] -includes: [compareArray.js] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const validStrings = [ - "1976-11-18T15:23+00:00", - "1976-11-18T15:23+00:00[UTC]", - "1976-11-18T15:23+00:00[!UTC]", - "1976-11-18T15:23-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.getPossibleInstantsFor(arg); - - assert.compareArray( - result.map(i => i.epochNanoseconds), - [217_178_580_000_000_000n], - `"${arg}" is a valid UTC offset with time for PlainDateTime` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getPossibleInstantsFor(arg), - `"${arg}" UTC offset without time is not valid for PlainDateTime` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-calendar.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-calendar.js deleted file mode 100644 index 6115c8e6d33..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPossibleInstantsFor(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-time-zone.js deleted file mode 100644 index 4b0ddfa2ca6..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPossibleInstantsFor(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-separators.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-separators.js deleted file mode 100644 index 91a62b1c763..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-separators.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Time separator in string argument can vary -features: [Temporal] -includes: [compareArray.js] ----*/ - -const tests = [ - ["1976-11-18T15:23", "uppercase T"], - ["1976-11-18t15:23", "lowercase T"], - ["1976-11-18 15:23", "space between date and time"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPossibleInstantsFor(arg); - - assert.compareArray( - result.map(i => i.epochNanoseconds), - [217_178_580_000_000_000n], - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-zone-annotation.js deleted file mode 100644 index 9cdd241e77a..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] -includes: [compareArray.js] ----*/ - -const tests = [ - ["1976-11-18T15:23[Asia/Kolkata]", "named, with no offset"], - ["1976-11-18T15:23[!Europe/Vienna]", "named, with ! and no offset"], - ["1976-11-18T15:23[+00:00]", "numeric, with no offset"], - ["1976-11-18T15:23[!-02:30]", "numeric, with ! and no offset"], - ["1976-11-18T15:23+00:00[UTC]", "named, with offset"], - ["1976-11-18T15:23+00:00[!Africa/Abidjan]", "named, with offset and !"], - ["1976-11-18T15:23+00:00[+01:00]", "numeric, with offset"], - ["1976-11-18T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPossibleInstantsFor(arg); - - assert.compareArray( - result.map(i => i.epochNanoseconds), - [217_178_580_000_000_000n], - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-unknown-annotation.js deleted file mode 100644 index dd94565cc5c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Various forms of unknown annotation -features: [Temporal] -includes: [compareArray.js] ----*/ - -const tests = [ - ["1976-11-18T15:23[foo=bar]", "alone"], - ["1976-11-18T15:23[UTC][foo=bar]", "with time zone"], - ["1976-11-18T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["1976-11-18T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["1976-11-18T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPossibleInstantsFor(arg); - - assert.compareArray( - result.map(i => i.epochNanoseconds), - [217_178_580_000_000_000n], - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-with-utc-designator.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-with-utc-designator.js deleted file mode 100644 index c6032d465ba..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: RangeError thrown if a string with UTC designator is used as a PlainDateTime -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPossibleInstantsFor(arg), - "String with UTC designator should not be valid as a PlainDateTime" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-wrong-type.js deleted file mode 100644 index 9b12a1a80b4..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDateTime -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.getPossibleInstantsFor(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDateTime, "Temporal.PlainDateTime, object"], - [Temporal.PlainDateTime.prototype, "Temporal.PlainDateTime.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.getPossibleInstantsFor(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-balance-negative-time-units.js deleted file mode 100644 index 45147806825..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-balance-negative-time-units.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Negative time fields are balanced upwards if the argument is given as ZonedDateTime -info: | - sec-temporal-balancetime steps 3–14: - 3. Set _microsecond_ to _microsecond_ + floor(_nanosecond_ / 1000). - 4. Set _nanosecond_ to _nanosecond_ modulo 1000. - 5. Set _millisecond_ to _millisecond_ + floor(_microsecond_ / 1000). - 6. Set _microsecond_ to _microsecond_ modulo 1000. - 7. Set _second_ to _second_ + floor(_millisecond_ / 1000). - 8. Set _millisecond_ to _millisecond_ modulo 1000. - 9. Set _minute_ to _minute_ + floor(_second_ / 60). - 10. Set _second_ to _second_ modulo 60. - 11. Set _hour_ to _hour_ + floor(_minute_ / 60). - 12. Set _minute_ to _minute_ modulo 60. - 13. Let _days_ be floor(_hour_ / 24). - 14. Set _hour_ to _hour_ modulo 24. - sec-temporal-balanceisodatetime step 1: - 1. Let _balancedTime_ be ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). - sec-temporal-builtintimezonegetplaindatetimefor step 3: - 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). - sec-temporal-totemporaldatetime step 3.b: - b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then - ... - ii. 1. Return ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). - sec-temporal.timezone.prototype.getpossibleinstantsfor step 3: - 3. Set _dateTime_ ? ToTemporalDateTime(_dateTime_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// This code path is encountered if the time zone offset is negative and its -// absolute value in nanoseconds is greater than the nanosecond field of the -// exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); - -const conversionTimeZone = new Temporal.TimeZone("UTC"); // should not be used to interpret the argument -const instants = conversionTimeZone.getPossibleInstantsFor(datetime); - -assert.sameValue(instants.length, 1); -assert.sameValue(instants[0].epochNanoseconds, 3661_001_000_999n); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-negative-epochnanoseconds.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-negative-epochnanoseconds.js deleted file mode 100644 index 6b77502afde..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-negative-epochnanoseconds.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: A pre-epoch value is handled correctly by the modulo operation in GetISOPartsFromEpoch -info: | - sec-temporal-getisopartsfromepoch step 1: - 1. Let _remainderNs_ be the mathematical value whose sign is the sign of _epochNanoseconds_ and whose magnitude is abs(_epochNanoseconds_) modulo 106. - sec-temporal-builtintimezonegetplaindatetimefor step 2: - 2. Let _result_ be ! GetISOPartsFromEpoch(_instant_.[[Nanoseconds]]). -features: [Temporal] -includes: [compareArray.js] ----*/ - -const datetime = new Temporal.ZonedDateTime(-13849764_999_999_999n, "UTC"); - -// This code path shows up anywhere we convert an exact time, before the Unix -// epoch, with nonzero microseconds or nanoseconds, into a wall time. - -const instance = new Temporal.TimeZone("UTC"); -const result = instance.getPossibleInstantsFor(datetime); -assert.compareArray(result.map((i) => i.epochNanoseconds), [-13849764_999_999_999n]); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 962bf65e230..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const builtinTimeZone = new Temporal.TimeZone("UTC"); - assert.throws(RangeError, () => builtinTimeZone.getPossibleInstantsFor(datetime)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 5386893bf25..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const builtinTimeZone = new Temporal.TimeZone("UTC"); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => builtinTimeZone.getPossibleInstantsFor(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 7ff5b7f3b7b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const builtinTimeZone = new Temporal.TimeZone("UTC"); - assert.throws(RangeError, () => builtinTimeZone.getPossibleInstantsFor(datetime)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index f6a2a9cd7bd..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const builtinTimeZone = new Temporal.TimeZone("UTC"); - assert.throws(TypeError, () => builtinTimeZone.getPossibleInstantsFor(datetime)); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/branding.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/branding.js deleted file mode 100644 index 8506d52aee0..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getPossibleInstantsFor = Temporal.TimeZone.prototype.getPossibleInstantsFor; - -assert.sameValue(typeof getPossibleInstantsFor, "function"); - -const args = [new Temporal.PlainDateTime(2022, 6, 22)]; - -assert.throws(TypeError, () => getPossibleInstantsFor.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => getPossibleInstantsFor.apply(null, args), "null"); -assert.throws(TypeError, () => getPossibleInstantsFor.apply(true, args), "true"); -assert.throws(TypeError, () => getPossibleInstantsFor.apply("", args), "empty string"); -assert.throws(TypeError, () => getPossibleInstantsFor.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => getPossibleInstantsFor.apply(1, args), "1"); -assert.throws(TypeError, () => getPossibleInstantsFor.apply({}, args), "plain object"); -assert.throws(TypeError, () => getPossibleInstantsFor.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => getPossibleInstantsFor.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/builtin.js deleted file mode 100644 index 05623e37a20..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: > - Tests that Temporal.TimeZone.prototype.getPossibleInstantsFor - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.getPossibleInstantsFor), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getPossibleInstantsFor), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getPossibleInstantsFor), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.getPossibleInstantsFor.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index d74bdf4aa92..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.TimeZone("UTC"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.getPossibleInstantsFor(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-fields-iterable.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-fields-iterable.js deleted file mode 100644 index a4216496cf9..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-fields-iterable.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.timezone.prototype.getpossibleinstantsfor step 3: - 3. Set _dateTime_ to ? ToTemporalDateTime(_dateTime_). - sec-temporal-totemporaldatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const timeZone = new Temporal.TimeZone("UTC"); -timeZone.getPossibleInstantsFor({ year: 2000, month: 5, day: 2, calendar }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-temporal-object.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-temporal-object.js deleted file mode 100644 index 1e81176a1dd..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/calendar-temporal-object.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal.timezone.prototype.getpossibleinstantsfor step 3: - 3. Set _dateTime_ to ? ToTemporalDateTime(_dateTime_). - sec-temporal-totemporaldatetime step 2.c: - c. Let _calendar_ be ? GetTemporalCalendarWithISODefault(_item_). - sec-temporal-gettemporalcalendarwithisodefault step 2: - 2. Return ? ToTemporalCalendarWithISODefault(_calendar_). - sec-temporal-totemporalcalendarwithisodefault step 2: - 3. Return ? ToTemporalCalendar(_temporalCalendarLike_). - sec-temporal-totemporalcalendar step 1.a: - a. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const timeZone = new Temporal.TimeZone("UTC"); - timeZone.getPossibleInstantsFor({ year: 2000, month: 5, day: 2, calendar: temporalObject }); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/constructor-in-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/constructor-in-calendar-fields.js deleted file mode 100644 index 5bc24ee6d32..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.TimeZone("UTC"); - -assert.throws(RangeError, () => instance.getPossibleInstantsFor(arg)); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/duplicate-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/duplicate-calendar-fields.js deleted file mode 100644 index 3b6e5f57f80..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.TimeZone("UTC"); - - assert.throws(RangeError, () => instance.getPossibleInstantsFor(arg)); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/fixed-offset-near-date-time-limits.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/fixed-offset-near-date-time-limits.js deleted file mode 100644 index 8aa1af72920..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/fixed-offset-near-date-time-limits.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: > - Call getPossibleInstantsFor with values near the date/time limit and a fixed offset. -features: [Temporal, exponentiation] ----*/ - -const oneHour = 1n * 60n * 60n * 1000n**3n; - -const minDt = new Temporal.PlainDateTime(-271821, 4, 19, 1, 0, 0, 0, 0, 0); -const minValidDt = new Temporal.PlainDateTime(-271821, 4, 20, 0, 0, 0, 0, 0, 0); -const maxDt = new Temporal.PlainDateTime(275760, 9, 13, 0, 0, 0, 0, 0, 0); - -let zero = new Temporal.TimeZone("+00"); -let plusOne = new Temporal.TimeZone("+01"); -let minusOne = new Temporal.TimeZone("-01"); - -// Try the minimum date-time. -assert.throws(RangeError, () => zero.getPossibleInstantsFor(minDt)); -assert.throws(RangeError, () => plusOne.getPossibleInstantsFor(minDt)); -assert.throws(RangeError, () => minusOne.getPossibleInstantsFor(minDt)); - -// Try the minimum valid date-time. -{ - let r = zero.getPossibleInstantsFor(minValidDt); - assert.sameValue(r.length, 1); - assert.sameValue(r[0].epochNanoseconds, -86_40000_00000_00000_00000n); -} - -{ - let r = minusOne.getPossibleInstantsFor(minValidDt); - assert.sameValue(r.length, 1); - assert.sameValue(r[0].epochNanoseconds, -86_40000_00000_00000_00000n + oneHour); -} - -assert.throws(RangeError, () => plusOne.getPossibleInstantsFor(minValidDt)); - -// Try the maximum valid date-time. -{ - let r = zero.getPossibleInstantsFor(maxDt); - assert.sameValue(r.length, 1); - assert.sameValue(r[0].epochNanoseconds, 86_40000_00000_00000_00000n); -} - -{ - let r = plusOne.getPossibleInstantsFor(maxDt); - assert.sameValue(r.length, 1); - assert.sameValue(r[0].epochNanoseconds, 86_40000_00000_00000_00000n - oneHour); -} - -assert.throws(RangeError, () => minusOne.getPossibleInstantsFor(maxDt)); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/infinity-throws-rangeerror.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/infinity-throws-rangeerror.js deleted file mode 100644 index 371891da0cf..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); -const base = { year: 2000, month: 5, day: 2, hour: 15, minute: 30, second: 45, millisecond: 987, microsecond: 654, nanosecond: 321 }; - -[Infinity, -Infinity].forEach((inf) => { - ["year", "month", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond"].forEach((prop) => { - assert.throws(RangeError, () => instance.getPossibleInstantsFor({ ...base, [prop]: inf }), `${prop} property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, prop); - assert.throws(RangeError, () => instance.getPossibleInstantsFor({ ...base, [prop]: obj })); - assert.compareArray(calls, [`get ${prop}.valueOf`, `call ${prop}.valueOf`], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/leap-second.js deleted file mode 100644 index 79cb2a37326..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/leap-second.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Leap second is a valid ISO string for PlainDateTime -includes: [compareArray.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.getPossibleInstantsFor(arg); -assert.compareArray( - result1.map(i => i.epochNanoseconds), - [1_483_228_799_000_000_000n], - "leap second is a valid ISO string for PlainDateTime" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.getPossibleInstantsFor(arg); -assert.compareArray( - result2.map(i => i.epochNanoseconds), - [1_483_228_799_000_000_000n], - "second: 60 is ignored in property bag for PlainDateTime" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/length.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/length.js deleted file mode 100644 index 4be7b6d8519..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Temporal.TimeZone.prototype.getPossibleInstantsFor.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getPossibleInstantsFor, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/name.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/name.js deleted file mode 100644 index 59d0a384bdb..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Temporal.TimeZone.prototype.getPossibleInstantsFor.name is "getPossibleInstantsFor". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getPossibleInstantsFor, "name", { - value: "getPossibleInstantsFor", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/not-a-constructor.js deleted file mode 100644 index 2f3b6de5cda..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: > - Temporal.TimeZone.prototype.getPossibleInstantsFor does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.getPossibleInstantsFor(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getPossibleInstantsFor), false, - "isConstructor(Temporal.TimeZone.prototype.getPossibleInstantsFor)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/prop-desc.js deleted file mode 100644 index 4ab7bba6a90..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: The "getPossibleInstantsFor" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.getPossibleInstantsFor, - "function", - "`typeof TimeZone.prototype.getPossibleInstantsFor` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/proto-in-calendar-fields.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/proto-in-calendar-fields.js deleted file mode 100644 index 9c2c1c32413..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.TimeZone("UTC"); - -assert.throws(RangeError, () => instance.getPossibleInstantsFor(arg)); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/read-time-fields-before-datefromfields.js deleted file mode 100644 index fd9cfc93691..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.timezone.prototype.getpossibleinstantsfor step 3: - 3. Set _dateTime_ to ? ToTemporalDateTime(_dateTime_). - sec-temporal-totemporaldatetime step 2.e: - e. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timezone = new Temporal.TimeZone("UTC"); -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const result = timezone.getPossibleInstantsFor({ year: 1970, month: 1, day: 1, calendar }); - -assert.sameValue(result.length, 1, "result array length"); -assert.sameValue(result[0].epochNanoseconds, 0n, "epochNanoseconds result"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero.js deleted file mode 100644 index 0db44c18697..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-12-07", - "-000000-12-07T03:24:30", - "-000000-12-07T03:24:30+01:00", - "-000000-12-07T03:24:30+00:00[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPossibleInstantsFor(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 24c567b1df7..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01T00:00Z[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01T00:00Z[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01T00:00Z[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.getPreviousTransition(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation.js deleted file mode 100644 index 6ede7be636f..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[u-ca=iso8601]", "without time zone"], - ["1970-01-01T00:00Z[UTC][u-ca=gregory]", "with time zone"], - ["1970-01-01T00:00Z[!u-ca=hebrew]", "with ! and no time zone"], - ["1970-01-01T00:00Z[UTC][!u-ca=chinese]", "with ! and time zone"], - ["1970-01-01T00:00Z[u-ca=discord]", "annotation is ignored"], - ["1970-01-01T00:00Z[!u-ca=discord]", "annotation with ! is ignored"], - ["1970-01-01T00:00Z[u-ca=iso8601][u-ca=discord]", "two annotations are ignored"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPreviousTransition(arg); - - assert.sameValue( - result, - null, - `calendar annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 527c45e2dd1..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar]", - "1970-01-01T00:00Z[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00Z[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00Z[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPreviousTransition(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-date-with-utc-offset.js deleted file mode 100644 index 32aab26472e..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const validStrings = [ - "1970-01-01T00Z", - "1970-01-01T00Z[UTC]", - "1970-01-01T00Z[!UTC]", - "1970-01-01T00Z[Europe/Vienna]", - "1970-01-01T00+00:00", - "1970-01-01T00+00:00[UTC]", - "1970-01-01T00+00:00[!UTC]", - "1969-12-31T16-08:00[America/Vancouver]", -]; - -for (const arg of validStrings) { - const result = instance.getPreviousTransition(arg); - - assert.sameValue( - result, - null, - `"${arg}" is a valid UTC offset with time for Instant` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getPreviousTransition(arg), - `"${arg}" UTC offset without time is not valid for Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-invalid.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-invalid.js deleted file mode 100644 index 3b83ea8c354..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-invalid.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as an Instant -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00T00:00Z", - "2020-01-32T00:00Z", - "2020-02-30T00:00Z", - "2021-02-29T00:00Z", - "2020-00-01T00:00Z", - "2020-13-01T00:00Z", - "2020-01-01TZ", - "2020-01-01T25:00:00Z", - "2020-01-01T01:60:00Z", - "2020-01-01T01:60:61Z", - "2020-01-01T00:00Zjunk", - "2020-01-01T00:00:00Zjunk", - "2020-01-01T00:00:00.000000000Zjunk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01T00:00Z", - "2020-001-01T00:00Z", - "2020-01-001T00:00Z", - "2020-01-01T001Z", - "2020-01-01T01:001Z", - "2020-01-01T01:01:001Z", - // valid, but forms not supported in Temporal: - "2020-W01-1T00:00Z", - "2020-001T00:00Z", - "+0002020-01-01T00:00Z", - // may be valid in other contexts, but insufficient information for Instant: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - "2020-01-01", - "2020-01-01T00", - "2020-01-01T00:00", - "2020-01-01T00:00:00", - "2020-01-01T00:00:00.000000000", - // valid, but outside the supported range: - "-999999-01-01T00:00Z", - "+999999-01-01T00:00Z", -]; - -const instance = new Temporal.TimeZone("UTC"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.getPreviousTransition(arg), - `"${arg}" should not be a valid ISO string for an Instant` - ); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-calendar.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-calendar.js deleted file mode 100644 index 090cfc0e4d3..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-calendar.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00Z[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPreviousTransition(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-time-zone.js deleted file mode 100644 index 64aa91d2941..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01T00:00Z[UTC][UTC]", - "1970-01-01T00:00Z[!UTC][UTC]", - "1970-01-01T00:00Z[UTC][!UTC]", - "1970-01-01T00:00Z[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00Z[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPreviousTransition(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-separators.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-separators.js deleted file mode 100644 index d9023ea6b5b..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z", "uppercase T"], - ["1970-01-01t00:00Z", "lowercase T"], - ["1970-01-01 00:00Z", "space between date and time"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPreviousTransition(arg); - - assert.sameValue( - result, - null, - `variant time separators (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-zone-annotation.js deleted file mode 100644 index d85e05a2018..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[Asia/Kolkata]", "named, with Z"], - ["1970-01-01T00:00Z[!Europe/Vienna]", "named, with Z and !"], - ["1970-01-01T00:00Z[+00:00]", "numeric, with Z"], - ["1970-01-01T00:00Z[!-02:30]", "numeric, with Z and !"], - ["1970-01-01T00:00+00:00[UTC]", "named, with offset"], - ["1970-01-01T00:00+00:00[!Africa/Abidjan]", "named, with offset and !"], - ["1970-01-01T00:00+00:00[-08:00]", "numeric, with offset"], - ["1970-01-01T00:00+00:00[!+01:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPreviousTransition(arg); - - assert.sameValue( - result, - null, - `time zone annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-unknown-annotation.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-unknown-annotation.js deleted file mode 100644 index 7d964fba19a..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-string-unknown-annotation.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["1970-01-01T00:00Z[foo=bar]", "alone"], - ["1970-01-01T00:00Z[UTC][foo=bar]", "with time zone"], - ["1970-01-01T00:00Z[u-ca=iso8601][foo=bar]", "with calendar"], - ["1970-01-01T00:00Z[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["1970-01-01T00:00Z[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.TimeZone("UTC"); - -tests.forEach(([arg, description]) => { - const result = instance.getPreviousTransition(arg); - - assert.sameValue( - result, - null, - `unknown annotation (${description})` - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-wrong-type.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-wrong-type.js deleted file mode 100644 index 1bd6dd29933..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: > - Appropriate error thrown when argument cannot be converted to a valid string - for Instant -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [19761118, "number that would convert to a valid ISO string in other contexts"], - [1n, "bigint"], - [{}, "plain object"], - [Temporal.Instant, "Temporal.Instant, object"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === "string" || (typeof arg === "object" && arg !== null) || typeof arg === "function" - ? RangeError - : TypeError, - () => instance.getPreviousTransition(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [Temporal.Instant.prototype, "Temporal.Instant.prototype, object"], // fails brand check in toString() -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.getPreviousTransition(arg), `${description} does not convert to a string`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-zoneddatetime.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-zoneddatetime.js deleted file mode 100644 index 25b517f90a8..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/argument-zoneddatetime.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Fast path for converting Temporal.ZonedDateTime to Temporal.Instant -info: | - sec-temporal.timezone.prototype.getprevioustransition step 3: - 3. Set _startingPoint_ to ? ToTemporalInstant(_startingPoint_). - sec-temporal-totemporalinstant step 1.b: - b. If _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return ! CreateTemporalInstant(_item_.[[Nanoseconds]]). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkToTemporalInstantFastPath((datetime) => { - const timeZone = Temporal.TimeZone.from("UTC"); - const result = timeZone.getPreviousTransition(datetime); - assert.sameValue(result, null, "transition result"); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/branding.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/branding.js deleted file mode 100644 index 75e4164e4dd..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/branding.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getPreviousTransition = Temporal.TimeZone.prototype.getPreviousTransition; - -assert.sameValue(typeof getPreviousTransition, "function"); - -const args = [new Temporal.Instant(0n)]; - -assert.throws(TypeError, () => getPreviousTransition.apply(undefined, args), "undefined"); -assert.throws(TypeError, () => getPreviousTransition.apply(null, args), "null"); -assert.throws(TypeError, () => getPreviousTransition.apply(true, args), "true"); -assert.throws(TypeError, () => getPreviousTransition.apply("", args), "empty string"); -assert.throws(TypeError, () => getPreviousTransition.apply(Symbol(), args), "symbol"); -assert.throws(TypeError, () => getPreviousTransition.apply(1, args), "1"); -assert.throws(TypeError, () => getPreviousTransition.apply({}, args), "plain object"); -assert.throws(TypeError, () => getPreviousTransition.apply(Temporal.TimeZone, args), "Temporal.TimeZone"); -assert.throws(TypeError, () => getPreviousTransition.apply(Temporal.TimeZone.prototype, args), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/builtin.js deleted file mode 100644 index 4fc7ff1c311..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: > - Tests that Temporal.TimeZone.prototype.getPreviousTransition - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.getPreviousTransition), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.getPreviousTransition), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.getPreviousTransition), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.getPreviousTransition.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/instant-string-limits.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/instant-string-limits.js deleted file mode 100644 index 5f0afdbdec4..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/instant-string-limits.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: String arguments at the limit of the representable range -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const minInstantStrings = [ - "-271821-04-20T00:00Z", - "-271821-04-19T23:00-01:00", - "-271821-04-19T00:00:00.000000001-23:59:59.999999999", -]; -for (const str of minInstantStrings) { - assert.sameValue(instance.getPreviousTransition(str), null, `instant string ${str} should be valid`); -} - -const maxInstantStrings = [ - "+275760-09-13T00:00Z", - "+275760-09-13T01:00+01:00", - "+275760-09-13T23:59:59.999999999+23:59:59.999999999", -]; - -for (const str of maxInstantStrings) { - assert.sameValue(instance.getPreviousTransition(str), null, `instant string ${str} should be valid`); -} - -const outOfRangeInstantStrings = [ - "-271821-04-19T23:59:59.999999999Z", - "-271821-04-19T23:00-00:59:59.999999999", - "-271821-04-19T00:00:00-23:59:59.999999999", - "-271821-04-19T00:00:00-24:00", - "+275760-09-13T00:00:00.000000001Z", - "+275760-09-13T01:00+00:59:59.999999999", - "+275760-09-14T00:00+23:59:59.999999999", - "+275760-09-14T00:00+24:00", -]; - -for (const str of outOfRangeInstantStrings) { - assert.throws(RangeError, () => instance.getPreviousTransition(str), `instant string ${str} should not be valid`); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/instant-string.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/instant-string.js deleted file mode 100644 index a2a6c477e97..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/instant-string.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Conversion of ISO date-time strings to Temporal.Instant instances -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -let str = "1970-01-01T00:00"; -assert.throws(RangeError, () => instance.getPreviousTransition(str), "bare date-time string is not an instant"); -str = "1970-01-01T00:00[UTC]"; -assert.throws(RangeError, () => instance.getPreviousTransition(str), "date-time + IANA annotation is not an instant"); - -// The following are all valid strings so should not throw: - -const valids = [ - "1970-01-01T00:00Z", - "1970-01-01T00:00+01:00", - "1970-01-01T00:00Z[UTC]", - "1970-01-01T00:00+01:00[UTC]", - "1970-01-01T00:00Z[u-ca=hebrew]", - "1970-01-01T00:00+01:00[u-ca=hebrew]", - "1970-01-01T00:00+01:00[Etc/Ignored][u-ca=hebrew]", -]; -for (const str of valids) { - const result = instance.getPreviousTransition(str); - assert.sameValue(result, null); -} diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/leap-second.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/leap-second.js deleted file mode 100644 index 29d3b5d4100..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/leap-second.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Leap second is a valid ISO string for Instant -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); - -const arg = "2016-12-31T23:59:60Z"; -const result = instance.getPreviousTransition(arg); -assert.sameValue( - result, - null, - "leap second is a valid ISO string for Instant" -); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/length.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/length.js deleted file mode 100644 index 83cb3c8abe2..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Temporal.TimeZone.prototype.getPreviousTransition.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getPreviousTransition, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/name.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/name.js deleted file mode 100644 index 0dc22a2a50e..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Temporal.TimeZone.prototype.getPreviousTransition.name is "getPreviousTransition". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.getPreviousTransition, "name", { - value: "getPreviousTransition", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/not-a-constructor.js deleted file mode 100644 index 12f2d39e183..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: > - Temporal.TimeZone.prototype.getPreviousTransition does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.getPreviousTransition(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.getPreviousTransition), false, - "isConstructor(Temporal.TimeZone.prototype.getPreviousTransition)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/prop-desc.js deleted file mode 100644 index a2e3c75e5bb..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: The "getPreviousTransition" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.getPreviousTransition, - "function", - "`typeof TimeZone.prototype.getPreviousTransition` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "getPreviousTransition", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero.js b/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero.js deleted file mode 100644 index 07b1e7248f8..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/getPreviousTransition/year-zero.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-03-30T00:45Z", - "-000000-03-30T01:45+01:00", - "-000000-03-30T01:45:00+00:00[UTC]", -]; -const instance = new Temporal.TimeZone("UTC"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.getPreviousTransition(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/id/branding.js b/test/built-ins/Temporal/TimeZone/prototype/id/branding.js deleted file mode 100644 index f437ab2baae..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/id/branding.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.timezone.prototype.id -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const descriptor = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id"); -const id = descriptor.get; - -assert.sameValue(typeof id, "function"); - -assert.throws(TypeError, () => id.call(undefined), "undefined"); -assert.throws(TypeError, () => id.call(null), "null"); -assert.throws(TypeError, () => id.call(true), "true"); -assert.throws(TypeError, () => id.call(""), "empty string"); -assert.throws(TypeError, () => id.call(Symbol()), "symbol"); -assert.throws(TypeError, () => id.call(1), "1"); -assert.throws(TypeError, () => id.call({}), "plain object"); -assert.throws(TypeError, () => id.call(Temporal.TimeZone), "Temporal.TimeZone"); -assert.throws(TypeError, () => id.call(Temporal.TimeZone.prototype), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/id/custom-timezone.js b/test/built-ins/Temporal/TimeZone/prototype/id/custom-timezone.js deleted file mode 100644 index 863dc84face..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/id/custom-timezone.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.timezone.prototype.id -description: Getter does not call toString(), returns the ID from internal slot -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = []; - -const timeZone = new Temporal.TimeZone("UTC"); -TemporalHelpers.observeProperty(actual, timeZone, Symbol.toPrimitive, undefined); -TemporalHelpers.observeProperty(actual, timeZone, "toString", function () { - actual.push("call timeZone.toString"); - return "time zone"; -}); - -const result = timeZone.id; -assert.compareArray(actual, expected); -assert.sameValue(result, "UTC"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/id/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/id/prop-desc.js deleted file mode 100644 index 1887699b543..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/id/prop-desc.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.timezone.prototype.id -description: The "id" property of Temporal.TimeZone.prototype -features: [Temporal] ----*/ - -const descriptor = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id"); -assert.sameValue(typeof descriptor.get, "function"); -assert.sameValue(descriptor.set, undefined); -assert.sameValue(descriptor.enumerable, false); -assert.sameValue(descriptor.configurable, true); diff --git a/test/built-ins/Temporal/TimeZone/prototype/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/prop-desc.js deleted file mode 100644 index d76945b80d4..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/prop-desc.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-prototype -description: The "prototype" property of Temporal.TimeZone -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue(typeof Temporal.TimeZone.prototype, "object"); -assert.notSameValue(Temporal.TimeZone.prototype, null); - -verifyProperty(Temporal.TimeZone, "prototype", { - writable: false, - enumerable: false, - configurable: false, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toJSON/branding.js b/test/built-ins/Temporal/TimeZone/prototype/toJSON/branding.js deleted file mode 100644 index 207c7721779..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toJSON/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tojson -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toJSON = Temporal.TimeZone.prototype.toJSON; - -assert.sameValue(typeof toJSON, "function"); - -assert.throws(TypeError, () => toJSON.call(undefined), "undefined"); -assert.throws(TypeError, () => toJSON.call(null), "null"); -assert.throws(TypeError, () => toJSON.call(true), "true"); -assert.throws(TypeError, () => toJSON.call(""), "empty string"); -assert.throws(TypeError, () => toJSON.call(Symbol()), "symbol"); -assert.throws(TypeError, () => toJSON.call(1), "1"); -assert.throws(TypeError, () => toJSON.call({}), "plain object"); -assert.throws(TypeError, () => toJSON.call(Temporal.TimeZone), "Temporal.TimeZone"); -assert.throws(TypeError, () => toJSON.call(Temporal.TimeZone.prototype), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toJSON/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/toJSON/builtin.js deleted file mode 100644 index 37cecb9b122..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toJSON/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tojson -description: > - Tests that Temporal.TimeZone.prototype.toJSON - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.toJSON), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.toJSON), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.toJSON), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.toJSON.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toJSON/length.js b/test/built-ins/Temporal/TimeZone/prototype/toJSON/length.js deleted file mode 100644 index 295171903c7..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toJSON/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tojson -description: Temporal.TimeZone.prototype.toJSON.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.toJSON, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toJSON/name.js b/test/built-ins/Temporal/TimeZone/prototype/toJSON/name.js deleted file mode 100644 index cdf784682fa..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toJSON/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tojson -description: Temporal.TimeZone.prototype.toJSON.name is "toJSON". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.toJSON, "name", { - value: "toJSON", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toJSON/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/toJSON/not-a-constructor.js deleted file mode 100644 index 24c036a5444..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toJSON/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tojson -description: > - Temporal.TimeZone.prototype.toJSON does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.toJSON(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.toJSON), false, - "isConstructor(Temporal.TimeZone.prototype.toJSON)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toJSON/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/toJSON/prop-desc.js deleted file mode 100644 index e3d09cec62e..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toJSON/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tojson -description: The "toJSON" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.toJSON, - "function", - "`typeof TimeZone.prototype.toJSON` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "toJSON", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toJSON/returns-identifier-slot.js b/test/built-ins/Temporal/TimeZone/prototype/toJSON/returns-identifier-slot.js deleted file mode 100644 index a15100c9325..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toJSON/returns-identifier-slot.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tojson -description: toJSON() returns the internal slot value -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; - -const timeZone = new Temporal.TimeZone("UTC"); -TemporalHelpers.observeProperty(actual, timeZone, Symbol.toPrimitive, undefined); -TemporalHelpers.observeProperty(actual, timeZone, "id", "Etc/Bogus"); -TemporalHelpers.observeProperty(actual, timeZone, "toString", function () { - actual.push("call timeZone.toString"); - return "Etc/TAI"; -}); - -const result = timeZone.toJSON(); -assert.sameValue(result, "UTC", "toJSON gets the internal slot value"); -assert.compareArray(actual, [], "should not invoke any observable operations"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toString/branding.js b/test/built-ins/Temporal/TimeZone/prototype/toString/branding.js deleted file mode 100644 index ab7654cc73c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toString/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tostring -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const toString = Temporal.TimeZone.prototype.toString; - -assert.sameValue(typeof toString, "function"); - -assert.throws(TypeError, () => toString.call(undefined), "undefined"); -assert.throws(TypeError, () => toString.call(null), "null"); -assert.throws(TypeError, () => toString.call(true), "true"); -assert.throws(TypeError, () => toString.call(""), "empty string"); -assert.throws(TypeError, () => toString.call(Symbol()), "symbol"); -assert.throws(TypeError, () => toString.call(1), "1"); -assert.throws(TypeError, () => toString.call({}), "plain object"); -assert.throws(TypeError, () => toString.call(Temporal.TimeZone), "Temporal.TimeZone"); -assert.throws(TypeError, () => toString.call(Temporal.TimeZone.prototype), "Temporal.TimeZone.prototype"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toString/builtin.js b/test/built-ins/Temporal/TimeZone/prototype/toString/builtin.js deleted file mode 100644 index 8cd8e1f2fbd..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toString/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tostring -description: > - Tests that Temporal.TimeZone.prototype.toString - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.TimeZone.prototype.toString), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.TimeZone.prototype.toString), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.TimeZone.prototype.toString), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.TimeZone.prototype.toString.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toString/length.js b/test/built-ins/Temporal/TimeZone/prototype/toString/length.js deleted file mode 100644 index f32b3738c1c..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toString/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tostring -description: Temporal.TimeZone.prototype.toString.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.toString, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toString/name.js b/test/built-ins/Temporal/TimeZone/prototype/toString/name.js deleted file mode 100644 index 53bbdc2b208..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toString/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tostring -description: Temporal.TimeZone.prototype.toString.name is "toString". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype.toString, "name", { - value: "toString", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toString/not-a-constructor.js b/test/built-ins/Temporal/TimeZone/prototype/toString/not-a-constructor.js deleted file mode 100644 index a379a7dcb1f..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toString/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tostring -description: > - Temporal.TimeZone.prototype.toString does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.TimeZone.prototype.toString(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.TimeZone.prototype.toString), false, - "isConstructor(Temporal.TimeZone.prototype.toString)"); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toString/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/toString/prop-desc.js deleted file mode 100644 index 2b117165a68..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toString/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.tostring -description: The "toString" property of Temporal.TimeZone.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.TimeZone.prototype.toString, - "function", - "`typeof TimeZone.prototype.toString` is `function`" -); - -verifyProperty(Temporal.TimeZone.prototype, "toString", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/prototype/toStringTag/prop-desc.js b/test/built-ins/Temporal/TimeZone/prototype/toStringTag/prop-desc.js deleted file mode 100644 index 2aeae3722c8..00000000000 --- a/test/built-ins/Temporal/TimeZone/prototype/toStringTag/prop-desc.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype-@@tostringtag -description: The @@toStringTag property of Temporal.TimeZone -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.TimeZone.prototype, Symbol.toStringTag, { - value: "Temporal.TimeZone", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/TimeZone/subclass.js b/test/built-ins/Temporal/TimeZone/subclass.js deleted file mode 100644 index d0b5364b0bb..00000000000 --- a/test/built-ins/Temporal/TimeZone/subclass.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Test for Temporal.TimeZone subclassing. -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { -} - -const instance = new CustomTimeZone("UTC"); -assert.sameValue(instance.toString(), "UTC"); -assert.sameValue(Object.getPrototypeOf(instance), CustomTimeZone.prototype, "Instance of CustomTimeZone"); -assert(instance instanceof CustomTimeZone, "Instance of CustomTimeZone"); -assert(instance instanceof Temporal.TimeZone, "Instance of Temporal.TimeZone"); diff --git a/test/built-ins/Temporal/ZonedDateTime/calendar-iso-string.js b/test/built-ins/Temporal/ZonedDateTime/calendar-iso-string.js new file mode 100644 index 00000000000..d47b0ec013f --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/calendar-iso-string.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.constructor +description: An ISO string is not valid input for a constructor's calendar param +features: [Temporal] +---*/ + +assert.throws( + RangeError, + () => new Temporal.ZonedDateTime(0n, "UTC", "1997-12-04[u-ca=iso8601]"), + "An ISO string is not a valid calendar ID for constructor parameter" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/calendar-string.js index 35be85afebe..bcd40a23d71 100644 --- a/test/built-ins/Temporal/ZonedDateTime/calendar-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/calendar-string.js @@ -10,4 +10,4 @@ features: [Temporal] const arg = "iso8601"; const result = new Temporal.ZonedDateTime(0n, "UTC", arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/ZonedDateTime/calendar-temporal-object.js b/test/built-ins/Temporal/ZonedDateTime/calendar-temporal-object.js deleted file mode 100644 index 4f423ba86e2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/calendar-temporal-object.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots -info: | - sec-temporal-totemporalcalendar step 1.b: - b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then - i. Return _temporalCalendarLike_.[[Calendar]]. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const plainDate = new Temporal.PlainDate(2000, 5, 2); -const plainDateTime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); -const plainMonthDay = new Temporal.PlainMonthDay(5, 2); -const plainYearMonth = new Temporal.PlainYearMonth(2000, 5); -const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - -[plainDate, plainDateTime, plainMonthDay, plainYearMonth, zonedDateTime].forEach((arg) => { - const actual = []; - const expected = []; - - const calendar = arg.getISOFields().calendar; - - Object.defineProperty(arg, "calendar", { - get() { - actual.push("get calendar"); - return calendar; - }, - }); - - const result = new Temporal.ZonedDateTime(0n, "UTC", arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); - - assert.compareArray(actual, expected, "calendar getter not called"); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/calendar-undefined.js b/test/built-ins/Temporal/ZonedDateTime/calendar-undefined.js index 0de531db8a7..49c7b201fab 100644 --- a/test/built-ins/Temporal/ZonedDateTime/calendar-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/calendar-undefined.js @@ -7,16 +7,10 @@ description: Calendar argument defaults to the built-in ISO 8601 calendar features: [BigInt, Temporal] ---*/ -const args = [957270896987654321n, new Temporal.TimeZone("UTC")]; - -Object.defineProperty(Temporal.Calendar, "from", { - get() { - throw new Test262Error("Should not get Calendar.from"); - }, -}); +const args = [957270896987654321n, "UTC"]; const explicit = new Temporal.ZonedDateTime(...args, undefined); -assert.sameValue(explicit.getISOFields().calendar, "iso8601", "calendar slot should store a string"); +assert.sameValue(explicit.calendarId, "iso8601", "calendar string should be iso8601"); const implicit = new Temporal.ZonedDateTime(...args); -assert.sameValue(implicit.getISOFields().calendar, "iso8601", "calendar slot should store a string"); +assert.sameValue(implicit.calendarId, "iso8601", "calendar string should be iso8601"); diff --git a/test/built-ins/Temporal/ZonedDateTime/calendar-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/calendar-wrong-type.js index 6aa4667067c..7483befa107 100644 --- a/test/built-ins/Temporal/ZonedDateTime/calendar-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.zoneddatetime description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar + for Calendar features: [BigInt, Symbol, Temporal] ---*/ @@ -27,9 +27,8 @@ for (const [arg, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [arg, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index c2a4f0437aa..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const timeZone = "UTC"; -const datetime = new Temporal.ZonedDateTime(0n, timeZone); -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, timeZone, calendar: "iso8601" }; -Temporal.ZonedDateTime.compare(arg, datetime); -Temporal.ZonedDateTime.compare(datetime, arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-ambiguous-wall-clock-time.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-ambiguous-wall-clock-time.js deleted file mode 100644 index 8dd0221e543..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-ambiguous-wall-clock-time.js +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: > - Correct time zone calls are made when converting a ZonedDateTime-like property - bag denoting an ambiguous wall-clock time -includes: [temporalHelpers.js, compareArray.js] -features: [Temporal] ----*/ - -const actual = []; - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const timeZone1 = TemporalHelpers.timeZoneObserver(actual, "one.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone), - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone), -}); -const timeZone2 = TemporalHelpers.timeZoneObserver(actual, "two.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone), - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone), -}); -const calendar1 = TemporalHelpers.calendarObserver(actual, "one.calendar"); -const calendar2 = TemporalHelpers.calendarObserver(actual, "two.calendar"); - -const expectedOne = [ - // GetTemporalCalendarSlotValueWithISODefault - "has one.calendar.dateAdd", - "has one.calendar.dateFromFields", - "has one.calendar.dateUntil", - "has one.calendar.day", - "has one.calendar.dayOfWeek", - "has one.calendar.dayOfYear", - "has one.calendar.daysInMonth", - "has one.calendar.daysInWeek", - "has one.calendar.daysInYear", - "has one.calendar.fields", - "has one.calendar.id", - "has one.calendar.inLeapYear", - "has one.calendar.mergeFields", - "has one.calendar.month", - "has one.calendar.monthCode", - "has one.calendar.monthDayFromFields", - "has one.calendar.monthsInYear", - "has one.calendar.weekOfYear", - "has one.calendar.year", - "has one.calendar.yearMonthFromFields", - "has one.calendar.yearOfWeek", - // lookup - "get one.calendar.dateFromFields", - "get one.calendar.fields", - // CalendarFields - "call one.calendar.fields", - // ToTemporalTimeZoneSlotValue - "has one.timeZone.getOffsetNanosecondsFor", - "has one.timeZone.getPossibleInstantsFor", - "has one.timeZone.id", - // InterpretTemporalDateTimeFields - "call one.calendar.dateFromFields", - // lookup - "get one.timeZone.getOffsetNanosecondsFor", - "get one.timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call one.timeZone.getPossibleInstantsFor", -]; - -const expectedTwo = [ - // GetTemporalCalendarSlotValueWithISODefault - "has two.calendar.dateAdd", - "has two.calendar.dateFromFields", - "has two.calendar.dateUntil", - "has two.calendar.day", - "has two.calendar.dayOfWeek", - "has two.calendar.dayOfYear", - "has two.calendar.daysInMonth", - "has two.calendar.daysInWeek", - "has two.calendar.daysInYear", - "has two.calendar.fields", - "has two.calendar.id", - "has two.calendar.inLeapYear", - "has two.calendar.mergeFields", - "has two.calendar.month", - "has two.calendar.monthCode", - "has two.calendar.monthDayFromFields", - "has two.calendar.monthsInYear", - "has two.calendar.weekOfYear", - "has two.calendar.year", - "has two.calendar.yearMonthFromFields", - "has two.calendar.yearOfWeek", - // lookup - "get two.calendar.dateFromFields", - "get two.calendar.fields", - // CalendarFields - "call two.calendar.fields", - // ToTemporalTimeZoneSlotValue - "has two.timeZone.getOffsetNanosecondsFor", - "has two.timeZone.getPossibleInstantsFor", - "has two.timeZone.id", - // InterpretTemporalDateTimeFields - "call two.calendar.dateFromFields", - // lookup - "get two.timeZone.getOffsetNanosecondsFor", - "get two.timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call two.timeZone.getPossibleInstantsFor", -]; - -Temporal.ZonedDateTime.compare( - { year: 2000, month: 4, day: 2, hour: 2, minute: 30, timeZone: timeZone1, calendar: calendar1 }, - { year: 2000, month: 4, day: 2, hour: 2, minute: 30, timeZone: timeZone2, calendar: calendar2 }, -); - -const expectedSpringForward = expectedOne.concat([ - // DisambiguatePossibleInstants - "call one.timeZone.getOffsetNanosecondsFor", - "call one.timeZone.getOffsetNanosecondsFor", - "call one.timeZone.getPossibleInstantsFor", -], expectedTwo, [ - // DisambiguatePossibleInstants - "call two.timeZone.getOffsetNanosecondsFor", - "call two.timeZone.getOffsetNanosecondsFor", - "call two.timeZone.getPossibleInstantsFor", -]); -assert.compareArray(actual, expectedSpringForward, "order of operations converting property bags at skipped wall-clock time"); -actual.splice(0); // clear - -Temporal.ZonedDateTime.compare( - { year: 2000, month: 10, day: 29, hour: 1, minute: 30, timeZone: timeZone1, calendar: calendar1 }, - { year: 2000, month: 10, day: 29, hour: 1, minute: 30, timeZone: timeZone2, calendar: calendar2 }, -); - -const expectedFallBack = expectedOne.concat(expectedTwo); -assert.compareArray(actual, expectedFallBack, "order of operations converting property bags at repeated wall-clock time"); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-case-insensitive.js index ca199160052..5642ae718a7 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-case-insensitive.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-case-insensitive.js @@ -7,7 +7,7 @@ description: The calendar name is case-insensitive features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const datetime = new Temporal.ZonedDateTime(0n, timeZone); const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar: "IsO8601" }; diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-leap-second.js index 0bf607c3237..a9671e128a1 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-leap-second.js @@ -7,7 +7,7 @@ description: Leap second is a valid ISO string for a calendar in a property bag features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const datetime = new Temporal.ZonedDateTime(217_123_200_000_000_000n, timeZone); const calendar = "2016-12-31T23:59:60+00:00[UTC]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-number.js index e01d722949e..c681c39c309 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-number.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-number.js @@ -7,7 +7,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const datetime = new Temporal.ZonedDateTime(0n, timeZone); const numbers = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-string.js index d0208d54198..acd56452b82 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-string.js @@ -4,22 +4,12 @@ /*--- esid: sec-temporal.zoneddatetime.compare description: A calendar ID is valid input for Calendar -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - const calendar = "iso8601"; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const datetime = new Temporal.ZonedDateTime(0n, timeZone); const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar }; @@ -28,5 +18,3 @@ assert.sameValue(result1, 0, `Calendar created from string "${arg}" (first argum const result2 = Temporal.ZonedDateTime.compare(datetime, arg); assert.sameValue(result2, 0, `Calendar created from string "${arg}" (second argument)`); - -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-wrong-type.js index 3641ce8f63b..4dc45c42391 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.zoneddatetime.compare description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const datetime = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const datetime = new Temporal.ZonedDateTime(0n, "UTC"); const primitiveTests = [ [null, "null"], @@ -35,10 +35,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-year-zero.js index 26a1253b18f..cb98229a285 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-calendar-year-zero.js @@ -7,7 +7,7 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const datetime = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const datetime = new Temporal.ZonedDateTime(0n, "UTC"); const invalidStrings = [ "-000000-10-31", "-000000-10-31T17:45", diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 004b7b4668b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.compare -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone1 = new SkippedDateTime(); -const arg1 = { year: 2000, month: 5, day: 2, timeZone: timeZone1, calendar: nonBuiltinISOCalendar }; -const timeZone2 = new SkippedDateTime(); -const arg2 = { year: 2000, month: 5, day: 2, timeZone: timeZone2, calendar: nonBuiltinISOCalendar }; - -Temporal.ZonedDateTime.compare(arg1, arg2); - -assert.sameValue(timeZone1.calls, 2, "getPossibleInstantsFor should have been called 2 times on first time zone"); -assert.sameValue(timeZone2.calls, 2, "getPossibleInstantsFor should have been called 2 times on second time zone"); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-invalid-offset-string.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-invalid-offset-string.js index 63baaa1af72..3d168958068 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-invalid-offset-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-invalid-offset-string.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset is in the w features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); const badOffsets = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-offset-not-agreeing-with-timezone.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-offset-not-agreeing-with-timezone.js index 79f6346c1f3..7dd409de6c5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-offset-not-agreeing-with-timezone.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-offset-not-agreeing-with-timezone.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset does not ag features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+01:00"); +const timeZone = "+01:00"; const datetime = new Temporal.ZonedDateTime(0n, timeZone); const properties = { year: 2021, month: 10, day: 28, offset: "-07:00", timeZone }; diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-backward-offset-shift.js deleted file mode 100644 index 58148c6f7f2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.compare -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; -const datetime = new Temporal.ZonedDateTime(0n, timeZone); - -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime), "RangeError should be thrown (first argument)"); -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg), "RangeError should be thrown (second argument)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-forward-offset-shift.js deleted file mode 100644 index 69de9ee843a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.compare -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; -const datetime = new Temporal.ZonedDateTime(0n, timeZone); - -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime), "RangeError should be thrown (first argument)"); -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg), "RangeError should be thrown (second argument)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index e0fe6289b22..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, Infinity, -Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - - assert.throws(RangeError, () => Temporal.ZonedDateTime.compare({ year: 2000, month: 5, day: 2, hour: 12, timeZone }, datetime)); - assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, { year: 2000, month: 5, day: 2, hour: 12, timeZone })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 60ab2680773..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -Temporal.TimeZone.prototype.getPossibleInstantsFor = function () { - return []; -}; - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.ZonedDateTime.compare({ year: 2000, month: 5, day: 2, hour: 12, timeZone }, datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); - assert.throws( - TypeError, - () => Temporal.ZonedDateTime.compare(datetime, { year: 2000, month: 5, day: 2, hour: 12, timeZone }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 281afb2447b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - - assert.throws(RangeError, () => Temporal.ZonedDateTime.compare({ year: 2000, month: 5, day: 2, hour: 12, timeZone }, datetime)); - assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, { year: 2000, month: 5, day: 2, hour: 12, timeZone })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 1ee2b28fc61..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - - assert.throws( - TypeError, - () => Temporal.ZonedDateTime.compare({ year: 2000, month: 5, day: 2, hour: 12, timeZone }, datetime), - `invalid offset: ${String(wrongOffset)} (${typeof wrongOffset})` - ); - assert.throws( - TypeError, - () => Temporal.ZonedDateTime.compare(datetime, { year: 2000, month: 5, day: 2, hour: 12, timeZone }), - `invalid offset: ${String(wrongOffset)} (${typeof wrongOffset})` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-datetime.js index 49a0f0eaa37..a3ec68c9e51 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.zoneddatetime.compare -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-year-zero.js index b5a4de63df2..6c9e55b6cd0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string-year-zero.js @@ -7,7 +7,7 @@ description: Negative zero, as an extended year, is rejected features: [Temporal, arrow-function] ---*/ -const datetime = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const datetime = new Temporal.ZonedDateTime(0n, "UTC"); const invalidStrings = [ "-000000-10-31T17:45Z", "-000000-10-31T17:45+00:00[UTC]", diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string.js index e5f1be57ffb..3d56a08a53d 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-string.js @@ -4,34 +4,13 @@ /*--- esid: sec-temporal.zoneddatetime.compare description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - ["UTC", "+01:30"].forEach((timeZone) => { - const epoch = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone(timeZone)); + const epoch = new Temporal.ZonedDateTime(0n, timeZone); // These should be valid input and not throw Temporal.ZonedDateTime.compare({ year: 2020, month: 5, day: 2, timeZone }, epoch); Temporal.ZonedDateTime.compare(epoch, { year: 2020, month: 5, day: 2, timeZone }); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-wrong-type.js index 7c6ec7d0efc..de3c5501bf5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-timezone-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const datetime = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const datetime = new Temporal.ZonedDateTime(0n, "UTC"); const primitiveTests = [ [null, "null"], @@ -35,8 +35,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-wrong-type.js index 6e8600fdaf0..3cb808a6bb9 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/argument-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const other = new Temporal.ZonedDateTime(0n, timeZone); const primitiveTests = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/compare/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index d5c3ae63f0b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const timeZone = new Temporal.TimeZone("UTC"); -const arg1 = { year: 2000, month: 5, day: 2, timeZone, calendar }; -const arg2 = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - -Temporal.ZonedDateTime.compare(arg1, arg2); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar (first argument)"); - -calendar.dateFromFieldsCallCount = 0; - -Temporal.ZonedDateTime.compare(arg2, arg1); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar (second argument)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/compare/calendar-fields-iterable.js deleted file mode 100644 index 08940a85bd4..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/calendar-fields-iterable.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.zoneddatetime.compare steps 1–2: - 1. Set _one_ to ? ToTemporalZonedDateTime(_one_). - 2. Set _two_ to ? ToTemporalZonedDateTime(_two_). - sec-temporal-totemporalzoneddatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -Temporal.ZonedDateTime.compare( - { year: 2000, month: 5, day: 2, timeZone: "UTC", calendar: calendar1 }, - { year: 2001, month: 6, day: 3, timeZone: "UTC", calendar: calendar2 }, -); - -assert.sameValue(calendar1.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar1.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar1.iteratorExhausted[0], "iterated through the whole iterable"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/compare/constructor-in-calendar-fields.js deleted file mode 100644 index 3788d16b3ae..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/constructor-in-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.compare -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; -const datetime = Temporal.ZonedDateTime.from({ year: 2023, month: 5, monthCode: 'M05', day: 15, timeZone: 'Europe/Paris' }); - -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime)); -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/compare/duplicate-calendar-fields.js deleted file mode 100644 index 817ea785f0b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/duplicate-calendar-fields.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.compare -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const timeZone = 'Europe/Paris' - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; - const datetime = Temporal.ZonedDateTime.from({year: 2023, month: 5, monthCode: 'M05', day: 15, timeZone: 'Europe/Paris'}); - - assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime)); - assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg)); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/exhaustive.js b/test/built-ins/Temporal/ZonedDateTime/compare/exhaustive.js deleted file mode 100644 index 655868266c0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/exhaustive.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: Tests for compare() with each possible outcome -features: [Temporal] ----*/ - -const tz1 = "UTC"; -const tz2 = "-00:30"; -const cal1 = "iso8601"; -const cal2 = new (class extends Temporal.Calendar { id = "custom"; })("iso8601"); - -assert.sameValue( - Temporal.ZonedDateTime.compare(new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, tz1, cal1), new Temporal.ZonedDateTime(500_000_000_000_000_000n, tz2, cal2)), - 1, - ">" -); -assert.sameValue( - Temporal.ZonedDateTime.compare(new Temporal.ZonedDateTime(-1000n, tz1, cal1), new Temporal.ZonedDateTime(1000n, tz2, cal2)), - -1, - "<" -); -assert.sameValue( - Temporal.ZonedDateTime.compare(new Temporal.ZonedDateTime(123_456_789n, tz1, cal1), new Temporal.ZonedDateTime(123_456_789n, tz2, cal2)), - 0, - "=" -); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/leap-second.js b/test/built-ins/Temporal/ZonedDateTime/compare/leap-second.js index cdd1368336f..c2783a7396f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/leap-second.js @@ -7,7 +7,7 @@ description: Leap second is a valid ISO string for ZonedDateTime features: [Temporal] ---*/ -const datetime = new Temporal.ZonedDateTime(1_483_228_799_000_000_000n, new Temporal.TimeZone("UTC")); +const datetime = new Temporal.ZonedDateTime(1_483_228_799_000_000_000n, "UTC"); let arg = "2016-12-31T23:59:60+00:00[UTC]"; const result1 = Temporal.ZonedDateTime.compare(arg, datetime); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/compare/order-of-operations.js index 1659432e9a0..f7a0b7f3be8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/compare/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/compare/order-of-operations.js @@ -10,30 +10,6 @@ features: [Temporal] const expected = [ "get one.calendar", - "has one.calendar.dateAdd", - "has one.calendar.dateFromFields", - "has one.calendar.dateUntil", - "has one.calendar.day", - "has one.calendar.dayOfWeek", - "has one.calendar.dayOfYear", - "has one.calendar.daysInMonth", - "has one.calendar.daysInWeek", - "has one.calendar.daysInYear", - "has one.calendar.fields", - "has one.calendar.id", - "has one.calendar.inLeapYear", - "has one.calendar.mergeFields", - "has one.calendar.month", - "has one.calendar.monthCode", - "has one.calendar.monthDayFromFields", - "has one.calendar.monthsInYear", - "has one.calendar.weekOfYear", - "has one.calendar.year", - "has one.calendar.yearMonthFromFields", - "has one.calendar.yearOfWeek", - "get one.calendar.dateFromFields", - "get one.calendar.fields", - "call one.calendar.fields", // PrepareTemporalFields "get one.day", "get one.day.valueOf", @@ -69,42 +45,8 @@ const expected = [ "get one.year", "get one.year.valueOf", "call one.year.valueOf", - "has one.timeZone.getOffsetNanosecondsFor", - "has one.timeZone.getPossibleInstantsFor", - "has one.timeZone.id", - // InterpretTemporalDateTimeFields - "call one.calendar.dateFromFields", - // InterpretISODateTimeOffset - "get one.timeZone.getOffsetNanosecondsFor", - "get one.timeZone.getPossibleInstantsFor", - "call one.timeZone.getPossibleInstantsFor", - "call one.timeZone.getOffsetNanosecondsFor", // Same set of operations, for the other argument: "get two.calendar", - "has two.calendar.dateAdd", - "has two.calendar.dateFromFields", - "has two.calendar.dateUntil", - "has two.calendar.day", - "has two.calendar.dayOfWeek", - "has two.calendar.dayOfYear", - "has two.calendar.daysInMonth", - "has two.calendar.daysInWeek", - "has two.calendar.daysInYear", - "has two.calendar.fields", - "has two.calendar.id", - "has two.calendar.inLeapYear", - "has two.calendar.mergeFields", - "has two.calendar.month", - "has two.calendar.monthCode", - "has two.calendar.monthDayFromFields", - "has two.calendar.monthsInYear", - "has two.calendar.weekOfYear", - "has two.calendar.year", - "has two.calendar.yearMonthFromFields", - "has two.calendar.yearOfWeek", - "get two.calendar.dateFromFields", - "get two.calendar.fields", - "call two.calendar.fields", // PrepareTemporalFields "get two.day", "get two.day.valueOf", @@ -140,16 +82,6 @@ const expected = [ "get two.year", "get two.year.valueOf", "call two.year.valueOf", - "has two.timeZone.getOffsetNanosecondsFor", - "has two.timeZone.getPossibleInstantsFor", - "has two.timeZone.id", - // InterpretTemporalDateTimeFields - "call two.calendar.dateFromFields", - // InterpretISODateTimeOffset - "get two.timeZone.getOffsetNanosecondsFor", - "get two.timeZone.getPossibleInstantsFor", - "call two.timeZone.getPossibleInstantsFor", - "call two.timeZone.getOffsetNanosecondsFor", ]; const actual = []; @@ -165,9 +97,9 @@ const one = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "one.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "one.timeZone"), -}, "one"); + calendar: "iso8601", + timeZone: "UTC", +}, "one", ["calendar", "timeZone"]); const two = TemporalHelpers.propertyBagObserver(actual, { year: 2014, @@ -181,9 +113,9 @@ const two = TemporalHelpers.propertyBagObserver(actual, { microsecond: 456, nanosecond: 789, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "two.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "two.timeZone"), -}, "two"); + calendar: "iso8601", + timeZone: "UTC", +}, "two", ["calendar", "timeZone"]); Temporal.ZonedDateTime.compare(one, two); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/compare/proto-in-calendar-fields.js deleted file mode 100644 index c9c485eb35b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/proto-in-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.compare -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; -const datetime = Temporal.ZonedDateTime.from({ year: 2023, month: 5, monthCode: 'M05', day: 15, timeZone: 'Europe/Paris' }); - -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(arg, datetime)); -assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/ZonedDateTime/compare/read-time-fields-before-datefromfields.js deleted file mode 100644 index 02f194566a5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.zoneddatetime.compare steps 1–2: - 1. Set _one_ to ? ToTemporalZonedDateTime(_one_). - 2. Set _two_ to ? ToTemporalZonedDateTime(_two_). - sec-temporal-totemporalzoneddatetime step 2.j: - j. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const result = Temporal.ZonedDateTime.compare( - { year: 2000, month: 5, day: 2, hour: 12, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321, timeZone: "UTC", calendar }, - { year: 2000, month: 5, day: 2, hour: 6, minute: 54, second: 32, millisecond: 123, microsecond: 456, nanosecond: 789, timeZone: "UTC", calendar }, -); - -// will be 0 if the time fields are coerced to their max values due to Infinity -assert.sameValue(result, 1, "comparison result"); diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/ZonedDateTime/compare/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index bf31d074551..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/compare/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.compare -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.zoneddatetime.compare steps 1–2: - 1. Set _one_ to ? ToTemporalZonedDateTime(_one_). - 2. Set _two_ to ? ToTemporalZonedDateTime(_two_). - sec-temporal-totemporalzoneddatetime step 7: - 7. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], [...], _result_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, _disambiguation_, _offset_). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const expected1 = [ - "2000-05-02T00:00:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - Temporal.ZonedDateTime.compare( - { year: 2000, month: 5, day: 2, timeZone }, - { year: 2001, month: 6, day: 3, timeZone: "UTC" }, - ); -}, expected1); - -// Same, but on the other operand - -const expected2 = [ - "2001-06-03T00:00:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - Temporal.ZonedDateTime.compare( - { year: 2000, month: 5, day: 2, timeZone: "UTC" }, - { year: 2001, month: 6, day: 3, timeZone }, - ); -}, expected2); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 3d275f40573..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const timeZone = "UTC"; -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, timeZone, calendar: "iso8601" }; -Temporal.ZonedDateTime.from(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-ambiguous-wall-clock-time.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-ambiguous-wall-clock-time.js deleted file mode 100644 index 73be2534fd9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-ambiguous-wall-clock-time.js +++ /dev/null @@ -1,135 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: > - Correct time zone calls are made when converting a ZonedDateTime-like property - bag denoting an ambiguous wall-clock time -includes: [temporalHelpers.js, compareArray.js] -features: [Temporal] ----*/ - -const actual = []; - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone), - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone), -}); -const calendar = TemporalHelpers.calendarObserver(actual, "calendar"); - -const expected = [ - // GetTemporalCalendarSlotValueWithISODefault - "has calendar.dateAdd", - "has calendar.dateFromFields", - "has calendar.dateUntil", - "has calendar.day", - "has calendar.dayOfWeek", - "has calendar.dayOfYear", - "has calendar.daysInMonth", - "has calendar.daysInWeek", - "has calendar.daysInYear", - "has calendar.fields", - "has calendar.id", - "has calendar.inLeapYear", - "has calendar.mergeFields", - "has calendar.month", - "has calendar.monthCode", - "has calendar.monthDayFromFields", - "has calendar.monthsInYear", - "has calendar.weekOfYear", - "has calendar.year", - "has calendar.yearMonthFromFields", - "has calendar.yearOfWeek", - // lookup in ToTemporalZonedDateTime - "get calendar.dateFromFields", - "get calendar.fields", - // CalendarFields - "call calendar.fields", - // ToTemporalTimeZoneSlotValue - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - // InterpretTemporalDateTimeFields - "call calendar.dateFromFields", - // lookup in ToTemporalZonedDateTime - "get timeZone.getOffsetNanosecondsFor", - "get timeZone.getPossibleInstantsFor", -]; - -Temporal.ZonedDateTime.from( - { year: 2000, month: 4, day: 2, hour: 2, minute: 30, offset: "-08:00", timeZone, calendar }, - { offset: "use" } -); -assert.compareArray(actual, expected, "order of operations converting property bag at skipped wall-clock time with offset: use"); -actual.splice(0); // clear - -Temporal.ZonedDateTime.from( - { year: 2000, month: 4, day: 2, hour: 2, minute: 30, offset: "-08:00", timeZone, calendar }, - { offset: "ignore" } -); -assert.compareArray(actual, expected.concat([ - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", - // DisambiguatePossibleInstants - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getPossibleInstantsFor", -]), "order of operations converting property bag at skipped wall-clock time with offset: ignore"); -actual.splice(0); // clear - -Temporal.ZonedDateTime.from( - { year: 2000, month: 4, day: 2, hour: 2, minute: 30, offset: "-08:00", timeZone, calendar }, - { offset: "prefer" } -); -assert.compareArray(actual, expected.concat([ - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", - // DisambiguatePossibleInstants - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getPossibleInstantsFor", -]), "order of operations converting property bag at skipped wall-clock time with offset: prefer"); -actual.splice(0); // clear - -Temporal.ZonedDateTime.from( - { year: 2000, month: 10, day: 29, hour: 1, minute: 30, offset: "-08:00", timeZone, calendar }, - { offset: "use" } -); -assert.compareArray(actual, expected, "order of operations converting property bag at repeated wall-clock time with offset: use"); -actual.splice(0); // clear - -Temporal.ZonedDateTime.from( - { year: 2000, month: 10, day: 29, hour: 1, minute: 30, offset: "-08:00", timeZone, calendar }, - { offset: "ignore" } -); -assert.compareArray(actual, expected.concat([ - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", -]), "order of operations converting property bag at repeated wall-clock time with offset: ignore"); -actual.splice(0); // clear - -Temporal.ZonedDateTime.from( - { year: 2000, month: 10, day: 29, hour: 1, minute: 30, offset: "-08:00", timeZone, calendar }, - { offset: "prefer" } -); -assert.compareArray(actual, expected.concat([ - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", -]), "order of operations converting property bag at repeated wall-clock time with offset: prefer"); -actual.splice(0); // clear - -Temporal.ZonedDateTime.from( - { year: 2000, month: 10, day: 29, hour: 1, minute: 30, offset: "-08:00", timeZone, calendar }, - { offset: "reject" } -); -assert.compareArray(actual, expected.concat([ - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", -]), "order of operations converting property bag at repeated wall-clock time with offset: reject"); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-case-insensitive.js index 3baa8ff31fe..fb3ce13833c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-case-insensitive.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-case-insensitive.js @@ -7,7 +7,7 @@ description: The calendar name is case-insensitive features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar: "IsO8601" }; const result = Temporal.ZonedDateTime.from(arg); assert.sameValue(result.calendarId, "iso8601", "Calendar is case-insensitive"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-iso-string.js index f26955131d7..51c2432b8d0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-iso-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-iso-string.js @@ -17,9 +17,9 @@ for (const calendar of [ "2020-01", "2020-01[u-ca=iso8601]", ]) { - const timeZone = new Temporal.TimeZone("UTC"); + const timeZone = "UTC"; const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar }; const result = Temporal.ZonedDateTime.from(arg); assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${calendar}"`); - assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); + assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); } diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-leap-second.js index 338a162ad5f..a31b570f8fb 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-leap-second.js @@ -7,7 +7,7 @@ description: Leap second is a valid ISO string for a calendar in a property bag features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const calendar = "2016-12-31T23:59:60+00:00[UTC]"; const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar }; diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-number.js index fc9dbcb170a..97dc4d646f6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-number.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-number.js @@ -6,8 +6,7 @@ esid: sec-temporal.zoneddatetime.from description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ - -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const numbers = [ 1, diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-string.js index c9d1b7bddb9..4b9a1ff43b0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-string.js @@ -9,8 +9,8 @@ features: [Temporal] const calendar = "iso8601"; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar }; const result = Temporal.ZonedDateTime.from(arg); assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${calendar}"`); -assert.sameValue(result.getISOFields().calendar, "iso8601", "calendar slot stores a string"); +assert.sameValue(result.calendarId, "iso8601", "calendar string is iso8601"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-wrong-type.js index e4d9cb78859..7af51106053 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-calendar-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.zoneddatetime.from description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ @@ -28,10 +28,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 0d4c96b9df9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.from -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); -const arg = { year: 2000, month: 5, day: 2, timeZone, calendar: nonBuiltinISOCalendar }; - -Temporal.ZonedDateTime.from(arg); - -assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-invalid-offset-string.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-invalid-offset-string.js index daf623d3b0d..9603bda4865 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-invalid-offset-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-invalid-offset-string.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset is in the w features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const offsetOptions = ['use', 'prefer', 'ignore', 'reject']; diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-offset-not-agreeing-with-timezone.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-offset-not-agreeing-with-timezone.js index 4bce6c887db..4f82b9a08a7 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-offset-not-agreeing-with-timezone.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-offset-not-agreeing-with-timezone.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset does not ag features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+01:00"); +const timeZone = "+01:00"; const properties = { year: 2021, month: 10, day: 28, offset: "-07:00", timeZone }; assert.throws(RangeError, () => Temporal.ZonedDateTime.from(properties), "offset property not matching time zone is rejected"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-backward-offset-shift.js deleted file mode 100644 index a2acd7be7bb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.from -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-forward-offset-shift.js deleted file mode 100644 index 107d0f62d26..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.from -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 180242a629e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(RangeError, () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, timeZone })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 9d4fbf45fb5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.from -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach(notCallable => { - const timeZone = new Temporal.TimeZone("UTC"); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, offset: "+00:00", timeZone }, { offset: "prefer" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError (in offset=prefer and no disambiguation case)` - ); - - const badTimeZone = { - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor: notCallable, - }; - assert.throws( - TypeError, - () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, offset: "+00:00", timeZone: badTimeZone }, { offset: "ignore" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError (in offset=ignore and no possible instants case)` - ); - assert.throws( - TypeError, - () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, offset: "+00:00", timeZone: badTimeZone }, { offset: "prefer" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError (in offset=prefer and no possible instants case)` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 34d748a9116..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_001, 86400_000_000_001, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws(RangeError, () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, timeZone })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 745e9c4d1ea..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - - assert.throws( - TypeError, - () => Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, timeZone }), - `invalid offset: ${String(wrongOffset)} (${typeof wrongOffset})` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js index c70faa24301..cef83b02051 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.zoneddatetime.from -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string.js index a0a4175926e..d9f5357bdce 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string.js @@ -4,31 +4,10 @@ /*--- esid: sec-temporal.zoneddatetime.from description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - ["UTC", "+01:30"].forEach((timeZone) => { const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }); - assert.sameValue(result.getISOFields().timeZone, timeZone, `Time zone created from string "${timeZone}"`); + assert.sameValue(result.timeZoneId, timeZone, `Time zone created from string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-wrong-type.js index 0e49c1ccaf6..a1fb6246cf4 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-propertybag-timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.zoneddatetime.from description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ @@ -28,8 +28,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-zoneddatetime.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-zoneddatetime.js index d1452483ceb..99bbc6c99f3 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/argument-zoneddatetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-zoneddatetime.js @@ -7,12 +7,12 @@ description: A ZonedDateTime object is copied, not returned directly features: [Temporal] ---*/ -const orig = new Temporal.ZonedDateTime(946684800_000_000_010n, new Temporal.TimeZone("UTC")); +const orig = new Temporal.ZonedDateTime(946684800_000_000_010n, "UTC"); const result = Temporal.ZonedDateTime.from(orig); assert.sameValue(result.epochNanoseconds, 946684800_000_000_010n, "ZonedDateTime is copied"); assert.sameValue(result.timeZone, orig.timeZone, "time zone is the same"); -assert.sameValue(result.getISOFields().calendar, orig.getISOFields().calendar, "calendar is the same"); +assert.sameValue(result.calendarId, orig.calendarId, "calendar is the same"); assert.notSameValue( result, diff --git a/test/built-ins/Temporal/ZonedDateTime/from/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/from/balance-negative-time-units.js deleted file mode 100644 index 80eb5903e6c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/balance-negative-time-units.js +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: Negative time fields are balanced upwards -info: | - sec-temporal-balancetime steps 3–14: - 3. Set _microsecond_ to _microsecond_ + floor(_nanosecond_ / 1000). - 4. Set _nanosecond_ to _nanosecond_ modulo 1000. - 5. Set _millisecond_ to _millisecond_ + floor(_microsecond_ / 1000). - 6. Set _microsecond_ to _microsecond_ modulo 1000. - 7. Set _second_ to _second_ + floor(_millisecond_ / 1000). - 8. Set _millisecond_ to _millisecond_ modulo 1000. - 9. Set _minute_ to _minute_ + floor(_second_ / 60). - 10. Set _second_ to _second_ modulo 60. - 11. Set _hour_ to _hour_ + floor(_minute_ / 60). - 12. Set _minute_ to _minute_ modulo 60. - 13. Let _days_ be floor(_hour_ / 24). - 14. Set _hour_ to _hour_ modulo 24. - sec-temporal-addtime step 8: - 8. Return ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). - sec-temporal-adddatetime step 1: - 1. Let _timeResult_ be ? AddTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_). - sec-temporal-builtintimezonegetinstantfor step 13.a: - a. Let _earlier_ be ? AddDateTime(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], 0, 0, 0, 0, 0, 0, 0, 0, 0, −_nanoseconds_, *"constrain"*). - sec-temporal-interpretisodatetimeoffset steps 4–10: - 4. If _offsetNanoseconds_ is *null*, or _offset_ is *"ignore"*, then - a. Let _instant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _dateTime_, _disambiguation_). - ... - ... - 6. Assert: _offset_ is *"prefer"* or *"reject"*. - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - ... - 9. If _offset_ is *"reject"*, throw a *RangeError* exception. - 10. Let _instant_ be ? DisambiguatePossibleInstants(_possibleInstants_, _timeZone_, _dateTime_, _disambiguation_). - sec-temporal-totemporalzoneddatetime step 7: - 7. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, _disambiguation_, _offset_). - sec-temporal.zoneddatetime.from step 3: - 3. Return ? ToTemporalZonedDateTime(_item_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const shiftInstant = new Temporal.Instant(3661_001_001_001n); -const tz1 = TemporalHelpers.oneShiftTimeZone(shiftInstant, 2); - -// This code path is encountered if offset is `ignore` or `prefer`, -// disambiguation is `earlier` and the shift is a spring-forward change -Temporal.ZonedDateTime.from({ - year: 1970, - month: 1, - day: 1, - hour: 1, - minute: 1, - second: 1, - millisecond: 1, - microsecond: 1, - nanosecond: 1, - timeZone: tz1, -}, { offset: "ignore", disambiguation: "earlier" }); - -const expected1 = [ - "1970-01-01T01:01:01.001001001", - "1970-01-01T01:01:01.001000999", -]; -assert.compareArray(tz1.getPossibleInstantsForCalledWith, expected1); - -const tz2 = TemporalHelpers.oneShiftTimeZone(shiftInstant, 2); - -Temporal.ZonedDateTime.from({ - year: 1970, - month: 1, - day: 1, - hour: 1, - minute: 1, - second: 1, - millisecond: 1, - microsecond: 1, - nanosecond: 1, - timeZone: tz2, -}, { offset: "prefer", disambiguation: "earlier" }); - -const expected2 = [ - "1970-01-01T01:01:01.001001001", - "1970-01-01T01:01:01.001000999", -]; -assert.compareArray(tz2.getPossibleInstantsForCalledWith, expected2); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/from/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 6d75571b006..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const timeZone = new Temporal.TimeZone("UTC"); -const arg = { year: 2000, month: 5, day: 2, timeZone, calendar }; -Temporal.ZonedDateTime.from(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/from/calendar-fields-iterable.js deleted file mode 100644 index befdc925abb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/calendar-fields-iterable.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.zoneddatetime.from step 3: - 3. Return ? ToTemporalZonedDateTime(_item_, _options_). - sec-temporal-totemporalzoneddatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: "UTC", calendar }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/calendar-temporal-object.js b/test/built-ins/Temporal/ZonedDateTime/from/calendar-temporal-object.js index 0489c499255..57748dadee6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/calendar-temporal-object.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/calendar-temporal-object.js @@ -20,7 +20,7 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject, calendar) => { +TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { const result = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone: "UTC", calendar: temporalObject }); - assert.sameValue(result.getCalendar(), calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar"); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/from/constructor-in-calendar-fields.js deleted file mode 100644 index 520b3042edc..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.from -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; - -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-invalid-string.js index b9529653e0d..31eefbda2e7 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-invalid-string.js @@ -24,6 +24,5 @@ features: [Temporal] const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); assert.throws(RangeError, () => Temporal.ZonedDateTime.from(datetime, { disambiguation: "other string" })); -const timeZone = new Temporal.TimeZone("UTC"); -const propertyBag = { timeZone, year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321 }; +const propertyBag = { timeZone: "UTC", year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321 }; assert.throws(RangeError, () => Temporal.ZonedDateTime.from(propertyBag, { disambiguation: "other string" })); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-undefined.js b/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-undefined.js deleted file mode 100644 index 8c420894bcc..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-undefined.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: Fallback value for disambiguation option -info: | - sec-getoption step 3: - 3. If _value_ is *undefined*, return _fallback_. - sec-temporal-totemporaldisambiguation step 1: - 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). - sec-temporal-totemporalzoneddatetime step 5: - 5. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). - sec-temporal.zoneddatetime.from step 2: - 2. If Type(_item_) is Object and _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then - ... - d. Return ... - 3. Return ? ToTemporalZonedDateTime(_item_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const springForwardFields = { timeZone, year: 2000, month: 4, day: 2, hour: 2, minute: 30 }; -const fallBackFields = { timeZone, year: 2000, month: 10, day: 29, hour: 1, minute: 30 }; - -[ - [springForwardFields, 954671400_000_000_000n], - [fallBackFields, 972808200_000_000_000n], -].forEach(([fields, expected]) => { - const explicit = Temporal.ZonedDateTime.from(fields, { disambiguation: undefined }); - assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible (later)"); - - // See options-undefined.js for {} -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-wrong-type.js index f997510dc8d..842c3afa4ea 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/disambiguation-wrong-type.js @@ -28,8 +28,7 @@ TemporalHelpers.checkStringOptionWrongType("disambiguation", "compatible", (result, descr) => assert.sameValue(result.epochNanoseconds, 1_000_000_000_987_654_321n, descr), ); -const timeZone = new Temporal.TimeZone("UTC"); -const propertyBag = { timeZone, year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321 }; +const propertyBag = { timeZone: "UTC", year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321 }; TemporalHelpers.checkStringOptionWrongType("disambiguation", "compatible", (disambiguation) => Temporal.ZonedDateTime.from(propertyBag, { disambiguation }), (result, descr) => assert.sameValue(result.epochNanoseconds, 1_000_000_000_987_654_321n, descr), diff --git a/test/built-ins/Temporal/ZonedDateTime/from/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/from/duplicate-calendar-fields.js deleted file mode 100644 index 9af871f4232..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/duplicate-calendar-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.from -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const timeZone = 'Europe/Paris' - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; - - assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg)); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-primitive.js b/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-primitive.js index 6d3724cfabb..bbce75342f7 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-primitive.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-primitive.js @@ -9,17 +9,13 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.disambiguation", "get options.disambiguation", - "getOwnPropertyDescriptor options.offset", - "get options.offset", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", "get options.disambiguation.toString", "call options.disambiguation.toString", + "get options.offset", "get options.offset.toString", "call options.offset.toString", + "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", ]; @@ -36,14 +32,6 @@ assert.compareArray(actual, expected, "Successful call"); assert.sameValue(result.epochNanoseconds, 1_000_000_000_000_000_000n); actual.splice(0); // empty it for the next check -const failureExpected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.disambiguation", - "get options.disambiguation", - "getOwnPropertyDescriptor options.offset", - "get options.offset", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", -]; + assert.throws(TypeError, () => Temporal.ZonedDateTime.from(7, options)); -assert.compareArray(actual, failureExpected, "Failing call"); +assert.compareArray(actual, expected, "Failing call"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-string-invalid.js b/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-string-invalid.js index c7ab1200a3d..2b395b18904 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-string-invalid.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/observable-get-overflow-argument-string-invalid.js @@ -9,13 +9,15 @@ features: [Temporal] ---*/ const expected = [ - "ownKeys options", - "getOwnPropertyDescriptor options.disambiguation", "get options.disambiguation", - "getOwnPropertyDescriptor options.offset", + "get options.disambiguation.toString", + "call options.disambiguation.toString", "get options.offset", - "getOwnPropertyDescriptor options.overflow", + "get options.offset.toString", + "call options.offset.toString", "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", ]; let actual = []; diff --git a/test/built-ins/Temporal/ZonedDateTime/from/offset-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/from/offset-invalid-string.js index 730cbc0147e..588e469f1fe 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/offset-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/offset-invalid-string.js @@ -23,6 +23,5 @@ features: [Temporal] const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); assert.throws(RangeError, () => Temporal.ZonedDateTime.from(datetime, { offset: "other string" })); -const timeZone = new Temporal.TimeZone("UTC"); -const propertyBag = { timeZone, year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321 }; +const propertyBag = { timeZone: "UTC", year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321 }; assert.throws(RangeError, () => Temporal.ZonedDateTime.from(propertyBag, { offset: "other string" })); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/offset-undefined.js b/test/built-ins/Temporal/ZonedDateTime/from/offset-undefined.js index 1939303ec08..a3c67e1b527 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/offset-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/offset-undefined.js @@ -20,8 +20,7 @@ info: | features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("-04:00"); -const propertyBag = { timeZone, offset: "+01:00", year: 2020, month: 2, day: 16, hour: 23, minute: 45 }; +const propertyBag = { timeZone: "-04:00", offset: "+01:00", year: 2020, month: 2, day: 16, hour: 23, minute: 45 }; assert.throws(RangeError, () => Temporal.ZonedDateTime.from(propertyBag, { offset: undefined }), "default offset is reject"); // See options-undefined.js for {} diff --git a/test/built-ins/Temporal/ZonedDateTime/from/offset-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/from/offset-wrong-type.js index 5c5bc1f70c0..6c3df817ed0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/offset-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/offset-wrong-type.js @@ -27,8 +27,7 @@ TemporalHelpers.checkStringOptionWrongType("offset", "reject", (result, descr) => assert.sameValue(result.epochNanoseconds, 1_000_000_000_987_654_321n, descr), ); -const timeZone = new Temporal.TimeZone("UTC"); -const propertyBag = { timeZone, offset: "+00:00", year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321 }; +const propertyBag = { timeZone: "UTC", offset: "+00:00", year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321 }; TemporalHelpers.checkStringOptionWrongType("offset", "reject", (offset) => Temporal.ZonedDateTime.from(propertyBag, { offset }), (result, descr) => assert.sameValue(result.epochNanoseconds, 1_000_000_000_987_654_321n, descr), diff --git a/test/built-ins/Temporal/ZonedDateTime/from/options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/from/options-undefined.js deleted file mode 100644 index a8a8e3ebf5e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/options-undefined.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -includes: [temporalHelpers.js] -description: Verify that undefined options are handled correctly. -features: [Temporal] ----*/ - -const overflowFields = { year: 2000, month: 13, day: 2, timeZone: "UTC" }; - -const overflowExplicit = Temporal.ZonedDateTime.from(overflowFields, undefined); -assert.sameValue(overflowExplicit.month, 12, "default overflow is constrain"); - -const overflowPropertyImplicit = Temporal.ZonedDateTime.from(overflowFields, {}); -assert.sameValue(overflowPropertyImplicit.month, 12, "default overflow is constrain"); - -const overflowImplicit = Temporal.ZonedDateTime.from(overflowFields); -assert.sameValue(overflowImplicit.month, 12, "default overflow is constrain"); - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const disambiguationEarlierFields = { timeZone, year: 2000, month: 10, day: 29, hour: 1, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321 }; -const disambiguationLaterFields = { timeZone, year: 2000, month: 4, day: 2, hour: 2, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321 }; - -[ - [disambiguationEarlierFields, 972808496987654321n], - [disambiguationLaterFields, 954671696987654321n], -].forEach(([fields, expected]) => { - const explicit = Temporal.ZonedDateTime.from(fields, undefined); - assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); - - const propertyImplicit = Temporal.ZonedDateTime.from(fields, {}); - assert.sameValue(propertyImplicit.epochNanoseconds, expected, "default disambiguation is compatible"); - - const implicit = Temporal.ZonedDateTime.from(fields); - assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); -}); - -const offsetFields = { year: 2000, month: 5, day: 2, offset: "+23:59", timeZone: "UTC" }; -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(offsetFields, undefined), "default offset is reject"); -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(offsetFields, {}), "default offset is reject"); -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(offsetFields), "default offset is reject"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js index 53f55522b5c..ae18e7d83c5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/from/order-of-operations.js @@ -9,42 +9,20 @@ features: [Temporal] ---*/ const expected = [ - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", - "getOwnPropertyDescriptor options.disambiguation", + // GetTemporalDisambiguationOption "get options.disambiguation", - "getOwnPropertyDescriptor options.offset", + "get options.disambiguation.toString", + "call options.disambiguation.toString", + // GetTemporalOffsetOption "get options.offset", - "getOwnPropertyDescriptor options.extra", - "get options.extra", + "get options.offset.toString", + "call options.offset.toString", + // GetTemporalOverflowOption + "get options.overflow", + "get options.overflow.toString", + "call options.overflow.toString", // ToTemporalCalendar "get item.calendar", - "has item.calendar.dateAdd", - "has item.calendar.dateFromFields", - "has item.calendar.dateUntil", - "has item.calendar.day", - "has item.calendar.dayOfWeek", - "has item.calendar.dayOfYear", - "has item.calendar.daysInMonth", - "has item.calendar.daysInWeek", - "has item.calendar.daysInYear", - "has item.calendar.fields", - "has item.calendar.id", - "has item.calendar.inLeapYear", - "has item.calendar.mergeFields", - "has item.calendar.month", - "has item.calendar.monthCode", - "has item.calendar.monthDayFromFields", - "has item.calendar.monthsInYear", - "has item.calendar.weekOfYear", - "has item.calendar.year", - "has item.calendar.yearMonthFromFields", - "has item.calendar.yearOfWeek", - "get item.calendar.dateFromFields", - "get item.calendar.fields", - "call item.calendar.fields", // PrepareTemporalFields "get item.day", "get item.day.valueOf", @@ -80,23 +58,6 @@ const expected = [ "get item.year", "get item.year.valueOf", "call item.year.valueOf", - "has item.timeZone.getOffsetNanosecondsFor", - "has item.timeZone.getPossibleInstantsFor", - "has item.timeZone.id", - // InterpretTemporalDateTimeFields - "get options.disambiguation.toString", - "call options.disambiguation.toString", - "get options.offset.toString", - "call options.offset.toString", - "get options.overflow.toString", - "call options.overflow.toString", - "call item.calendar.dateFromFields", - // lookup in ToTemporalZonedDateTime - "get item.timeZone.getOffsetNanosecondsFor", - "get item.timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call item.timeZone.getPossibleInstantsFor", - "call item.timeZone.getOffsetNanosecondsFor", ]; const actual = []; @@ -112,9 +73,9 @@ const from = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "item.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "item.timeZone"), -}, "item"); + calendar: "iso8601", + timeZone: "UTC", +}, "item", ["calendar", "timeZone"]); function createOptionsObserver({ overflow = "constrain", disambiguation = "compatible", offset = "reject" } = {}) { return TemporalHelpers.propertyBagObserver(actual, { diff --git a/test/built-ins/Temporal/ZonedDateTime/from/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/from/proto-in-calendar-fields.js deleted file mode 100644 index 8683b2057f3..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.from -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; - -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/ZonedDateTime/from/read-time-fields-before-datefromfields.js deleted file mode 100644 index 09c14956d98..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.zoneddatetime.from step 3: - 3. Return ? ToTemporalDateTime(_item_, _options_). - sec-temporal-totemporalzoneddatetime step 2.j: - j. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321, timeZone: "UTC", calendar }); - -assert.sameValue(datetime.hour, 12, "hour value"); -assert.sameValue(datetime.minute, 34, "minute value"); -assert.sameValue(datetime.second, 56, "second value"); -assert.sameValue(datetime.millisecond, 987, "millisecond value"); -assert.sameValue(datetime.microsecond, 654, "microsecond value"); -assert.sameValue(datetime.nanosecond, 321, "nanosecond value"); diff --git a/test/built-ins/Temporal/ZonedDateTime/from/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/ZonedDateTime/from/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index de48fe6bd4f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/from/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.from -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.zoneddatetime.from step 3: - 3. Return ? ToTemporalZonedDateTime(_item_, _options_). - sec-temporal-totemporalzoneddatetime step 7: - 7. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], [...], _result_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, _disambiguation_, _offset_). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "2000-05-02T00:00:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - Temporal.ZonedDateTime.from({ year: 2000, month: 5, day: 2, timeZone }); -}, expected); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/builtin-calendar-no-observable-calls.js deleted file mode 100644 index a196a45ce33..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.add -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.add(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 9e5e22d980f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.add -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.add(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/calendar-dateadd.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/calendar-dateadd.js deleted file mode 100644 index 18b7ae50b83..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/calendar-dateadd.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.add -description: ZonedDateTime.prototype.add should call dateAdd with the appropriate values. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(plainDate, duration, options) { - ++calls; - TemporalHelpers.assertPlainDate(plainDate, 2020, 3, "M03", 14, "plainDate argument"); - TemporalHelpers.assertDuration(duration, 0, 10, 0, 0, 0, 0, 0, 0, 0, 0, "duration argument"); - assert.sameValue(typeof options, "object", "options argument: type"); - assert.sameValue(Object.getPrototypeOf(options), null, "options argument: prototype"); - return super.dateAdd(plainDate, duration, options); - } -} - -const zonedDateTime = new Temporal.ZonedDateTime(1584189296_987654321n, - new Temporal.TimeZone("UTC"), new CustomCalendar()); -const result = zonedDateTime.add({ months: 10, hours: 14 }); -assert.sameValue(result.epochNanoseconds, 1610678096_987654321n); -assert.sameValue(calls, 1, "should have called dateAdd"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js index b8eed6bb38c..b58ab688261 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/add/order-of-operations.js @@ -40,27 +40,14 @@ const expected = [ "get duration.years", "get duration.years.valueOf", "call duration.years.valueOf", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - "get this.calendar.dateAdd", - // AddZonedDateTime - "call this.timeZone.getOffsetNanosecondsFor", - "call this.calendar.dateAdd", - // ... inside Calendar.p.dateAdd + // GetTemporalOverflowOption "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", - // AddZonedDateTime again - "call this.timeZone.getPossibleInstantsFor", ]; const actual = []; -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const duration = TemporalHelpers.propertyBagObserver(actual, { years: 1, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 7b1526902bd..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.add -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.add(duration)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 9e7898a6202..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.add -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.add(duration), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index b5a9c2c3065..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.add -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.add(duration)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index bcccc035c23..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/add/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.add -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.add(duration)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 76826e23669..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/calendarId/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.calendarid -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.calendarId; - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/balance-negative-time-units.js index be9f273c935..06e6a00a07e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/day/balance-negative-time-units.js @@ -24,20 +24,18 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.day step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(86400_000_000_001n, tz); +const datetime = new Temporal.ZonedDateTime(86400_000_000_001n, "-00:02"); assert.sameValue(datetime.day, 1); assert.sameValue(datetime.hour, 23); -assert.sameValue(datetime.minute, 59); -assert.sameValue(datetime.second, 59); -assert.sameValue(datetime.millisecond, 999); -assert.sameValue(datetime.microsecond, 999); -assert.sameValue(datetime.nanosecond, 999); +assert.sameValue(datetime.minute, 58); +assert.sameValue(datetime.second, 0); +assert.sameValue(datetime.millisecond, 0); +assert.sameValue(datetime.microsecond, 0); +assert.sameValue(datetime.nanosecond, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 0d706f0fca7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.day -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "day"); -Object.defineProperty(Temporal.Calendar.prototype, "day", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("day should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.day; - -Object.defineProperty(Temporal.Calendar.prototype, "day", dayOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 46c6ed54eb4..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.day -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.day; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/custom.js deleted file mode 100644 index a1941fe8023..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.day -description: Custom calendar tests for day(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - day(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "day arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.day; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 0c895c4dc3b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.day -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.day); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 5ba75ff2e5b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.day -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.day, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index ce24e0e6c73..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.day -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.day); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 56625aecedd..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.day -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.day); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/day/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/day/validate-calendar-value.js deleted file mode 100644 index d02df877a9c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/day/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.day -description: Validate result returned from calendar day() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - day() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.day, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js deleted file mode 100644 index d041f62ae8c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.dayofweek -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfWeek"); -Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dayOfWeek should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.dayOfWeek; - -Object.defineProperty(Temporal.Calendar.prototype, "dayOfWeek", dayOfWeekOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 935614eff31..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.dayofweek -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.dayOfWeek; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/custom.js deleted file mode 100644 index b57a37ef915..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofweek -description: Custom calendar tests for dayOfWeek(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dayOfWeek(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "dayOfWeek arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.dayOfWeek; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index b447f3a213d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofweek -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.dayOfWeek); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index be448c7510d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofweek -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.dayOfWeek, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index cb9c52a9767..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofweek -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.dayOfWeek); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index d3260e80dfe..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofweek -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.dayOfWeek); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/validate-calendar-value.js deleted file mode 100644 index a62c3ef0581..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofweek -description: Validate result returned from calendar dayOfWeek() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - dayOfWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.dayOfWeek, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 56b34eaa136..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.dayofyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dayOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dayOfYear"); -Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dayOfYear should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.dayOfYear; - -Object.defineProperty(Temporal.Calendar.prototype, "dayOfYear", dayOfYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/builtin-timezone-no-observable-calls.js deleted file mode 100644 index dec583d631b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.dayofyear -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.dayOfYear; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/custom.js deleted file mode 100644 index c68d7022919..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofyear -description: Custom calendar tests for dayOfYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dayOfYear(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "dayOfYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.dayOfYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 026fd7b8cde..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.dayOfYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 2e6e00ff9b0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.dayOfYear, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index b35209759ce..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.dayOfYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 1a075b12543..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.dayOfYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/validate-calendar-value.js deleted file mode 100644 index 36169bd2b78..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.dayofyear -description: Validate result returned from calendar dayOfYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - dayOfYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.dayOfYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 29b0f586f35..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.daysinmonth -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInMonthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInMonth"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInMonth should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.daysInMonth; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInMonth", daysInMonthOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 80b9481e4cc..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.daysinmonth -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.daysInMonth; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/custom.js deleted file mode 100644 index 85104a9aed7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinmonth -description: Custom calendar tests for daysInMonth(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInMonth(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "daysInMonth arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.daysInMonth; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index faf1ad8ed55..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinmonth -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.daysInMonth); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 644ea335ac7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinmonth -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.daysInMonth, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 012f36ff4ce..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinmonth -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.daysInMonth); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index f679b31e057..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinmonth -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.daysInMonth); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/validate-calendar-value.js deleted file mode 100644 index e83065d98e2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinmonth -description: Validate result returned from calendar daysInMonth() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInMonth() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.daysInMonth, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 6063de15837..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.daysinweek -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInWeek"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInWeek should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.daysInWeek; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInWeek", daysInWeekOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/builtin-timezone-no-observable-calls.js deleted file mode 100644 index ef010891d51..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.daysinweek -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.daysInWeek; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/custom.js deleted file mode 100644 index 3d66c6f3592..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinweek -description: Custom calendar tests for daysInWeek(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInWeek(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "daysInWeek arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.daysInWeek; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 32c2a85e04e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinweek -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.daysInWeek); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index dc6289eaca9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinweek -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.daysInWeek, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 4f6b0885ab8..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinweek -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.daysInWeek); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 51ba3543268..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinweek -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.daysInWeek); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/validate-calendar-value.js deleted file mode 100644 index 7ab58de32f6..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinweek -description: Validate result returned from calendar daysInWeek() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.daysInWeek, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index b9488ccda69..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.daysinyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const daysInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "daysInYear"); -Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("daysInYear should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.daysInYear; - -Object.defineProperty(Temporal.Calendar.prototype, "daysInYear", daysInYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/builtin-timezone-no-observable-calls.js deleted file mode 100644 index bd57ba80618..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.daysinyear -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.daysInYear; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/custom.js deleted file mode 100644 index b0505cfb9d2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinyear -description: Custom calendar tests for daysInYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - daysInYear(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "daysInYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.daysInYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 5310ae0bc56..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.daysInYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index edd34a7f8ed..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.daysInYear, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 2e839dffa63..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.daysInYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index d60ff6634bd..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.daysInYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/validate-calendar-value.js deleted file mode 100644 index 9e483d7f686..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.daysinyear -description: Validate result returned from calendar daysInYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - daysInYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.daysInYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 2059ed83eb0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const timeZone = "UTC"; -const instance = new Temporal.ZonedDateTime(0n, timeZone); -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, timeZone, calendar: "iso8601" }; -instance.equals(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-object.js new file mode 100644 index 00000000000..27fe0e8c8f3 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-object.js @@ -0,0 +1,23 @@ +// Copyright (C) 2023 Justin Grant. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Tests that objects can be compared for equality +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const idsEqual0000 = [ + "+00:00", + "+0000", + "+00" +]; + +for (const arg of idsEqual0000) { + for (const receiver of idsEqual0000) { + const result = instance.withTimeZone(receiver).equals(instance.withTimeZone(arg)); + assert.sameValue(result, true, `Receiver ${receiver} should equal argument ${arg}`); + } +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-ambiguous-wall-clock-time.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-ambiguous-wall-clock-time.js deleted file mode 100644 index 4b4266dece8..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-ambiguous-wall-clock-time.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: > - Correct time zone calls are made when converting a ZonedDateTime-like property - bag denoting an ambiguous wall-clock time -includes: [temporalHelpers.js, compareArray.js] -features: [Temporal] ----*/ - -const actual = []; - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const dstTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone), - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone), -}); -const calendar = TemporalHelpers.calendarObserver(actual, "calendar"); - -const timeZone = "UTC"; -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -let arg = { year: 2000, month: 4, day: 2, hour: 2, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.equals(arg); - -const expected = [ - // GetTemporalCalendarSlotValueWithISODefault - "has calendar.dateAdd", - "has calendar.dateFromFields", - "has calendar.dateUntil", - "has calendar.day", - "has calendar.dayOfWeek", - "has calendar.dayOfYear", - "has calendar.daysInMonth", - "has calendar.daysInWeek", - "has calendar.daysInYear", - "has calendar.fields", - "has calendar.id", - "has calendar.inLeapYear", - "has calendar.mergeFields", - "has calendar.month", - "has calendar.monthCode", - "has calendar.monthDayFromFields", - "has calendar.monthsInYear", - "has calendar.weekOfYear", - "has calendar.year", - "has calendar.yearMonthFromFields", - "has calendar.yearOfWeek", - // lookup in ToTemporalZonedDateTime - "get calendar.dateFromFields", - "get calendar.fields", - // CalendarFields - "call calendar.fields", - // ToTemporalTimeZoneSlotValue - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - // InterpretTemporalDateTimeFields - "call calendar.dateFromFields", - // lookup in ToTemporalZonedDateTime - "get timeZone.getOffsetNanosecondsFor", - "get timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", -]; - -const expectedSpringForward = expected.concat([ - // DisambiguatePossibleInstants - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getPossibleInstantsFor", -]); -assert.compareArray( - actual.slice(0, expectedSpringForward.length), // ignore operations after ToTemporalZonedDateTime - expectedSpringForward, - "order of operations converting property bag at skipped wall-clock time" -); -actual.splice(0); // clear - -arg = { year: 2000, month: 10, day: 29, hour: 1, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.equals(arg); - -assert.compareArray( - actual.slice(0, expected.length), // ignore operations after ToTemporalZonedDateTime - expected, - "order of operations converting property bag at repeated wall-clock time" -); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-case-insensitive.js index fe11b2b851c..e4b80cb5130 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-case-insensitive.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-case-insensitive.js @@ -7,7 +7,7 @@ description: The calendar name is case-insensitive features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar: "IsO8601" }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js index 3012fc4a3b0..5b754d6a3db 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-iso-string.js @@ -7,7 +7,7 @@ description: An ISO 8601 string can be converted to a calendar ID in Calendar features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); for (const calendar of [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-leap-second.js index 43fca0aa85f..e1f96d3e0af 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-leap-second.js @@ -7,7 +7,7 @@ description: Leap second is a valid ISO string for a calendar in a property bag features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const calendar = "2016-12-31T23:59:60+00:00[UTC]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-number.js index 06248b267fb..a975129dfba 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-number.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-number.js @@ -7,7 +7,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const numbers = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-string.js index f9d8641d73b..c36e2a675f8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-string.js @@ -7,7 +7,7 @@ description: A calendar ID is valid input for Calendar features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const calendar = "iso8601"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-wrong-type.js index 794e1d61259..5c75ee186ad 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.zoneddatetime.prototype.equals description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js index dd1eae6d6a3..c6d9dae35c8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-calendar-year-zero.js @@ -14,7 +14,7 @@ const invalidStrings = [ "-000000-10-31T17:45+01:00", "-000000-10-31T17:45+00:00[UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((str) => { const arg = { year: 1976, month: 11, day: 18, calendar: str }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index a62b96b22c5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); -const arg = { year: 2000, month: 5, day: 2, timeZone, calendar: nonBuiltinISOCalendar }; - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.equals(arg); - -assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-invalid-offset-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-invalid-offset-string.js index 18538ce5ab6..0ca261212f7 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-invalid-offset-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-invalid-offset-string.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset is in the w features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const badOffsets = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-offset-not-agreeing-with-timezone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-offset-not-agreeing-with-timezone.js index 26055779672..72bbf070052 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-offset-not-agreeing-with-timezone.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-offset-not-agreeing-with-timezone.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset does not ag features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+01:00"); +const timeZone = "+01:00"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const properties = { year: 2021, month: 10, day: 28, offset: "-07:00", timeZone }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-backward-offset-shift.js deleted file mode 100644 index 64e0756027d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.equals(arg), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-forward-offset-shift.js deleted file mode 100644 index 6da3547568b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.equals(arg), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index a7bcac29602..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => datetime.equals({ year: 2000, month: 5, day: 2, hour: 12, timeZone })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index a21643466a5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.equals({ year: 2000, month: 5, day: 2, hour: 12, timeZone }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 89e38250db2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => datetime.equals({ year: 2000, month: 5, day: 2, hour: 12, timeZone })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 6ab8fd3a68f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(TypeError, () => datetime.equals({ year: 2000, month: 5, day: 2, hour: 12, timeZone })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-id-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-id-wrong-type.js deleted file mode 100644 index 38883faca68..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-id-wrong-type.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: TypeError thrown if time zone reports an id that is not a String -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -[ - undefined, - null, - true, - -1000, - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongId) => { - const timeZone = new CustomTimeZone(wrongId); - const datetime = new Temporal.ZonedDateTime(0n, "UTC"); - assert.throws(TypeError, () => datetime.equals({ year: 1970, month: 1, day: 1, timeZone })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-normalize-offset-strings.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-normalize-offset-strings.js index 5785d96a023..b66dc8e8733 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-normalize-offset-strings.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-normalize-offset-strings.js @@ -16,25 +16,9 @@ for (const test of tests) { const {idToTest, description} = test; const instance = new Temporal.ZonedDateTime(0n, "+00:00"); - const bag1 = { year: 1970, monthCode: "M01", day: 1, timeZone: idToTest }; - assert.sameValue(instance.equals(bag1), true, `Offset time zones are equal despite ${description} syntax in property bag argument`); + const bag = { year: 1970, monthCode: "M01", day: 1, timeZone: idToTest }; + assert.sameValue(instance.equals(bag), true, `Offset time zones are equal despite ${description} syntax in property bag argument`); const str = "1970-01-01[+00:00]"; assert.sameValue(instance.equals(str), true, `Offset time zones are equal despite ${description} syntax in ISO string argument`); - - const getPossibleInstantsFor = (pdt) => [Temporal.Instant.from(`${pdt.toString()}Z`)] - const plainObj = { id: idToTest, getPossibleInstantsFor, getOffsetNanosecondsFor: () => 0 }; - const bag2 = { year: 1970, monthCode: "M01", day: 1, timeZone: plainObj }; - assert.sameValue(instance.equals(bag2), true, `Offset time zones are equal despite ${description} syntax in plain object time zone ID`); - - class CustomTimeZone extends Temporal.TimeZone { - constructor() { - super(idToTest); - } - get id() { return idToTest; } - } - const customTimeZoneInstance = new CustomTimeZone(); - assert.sameValue(customTimeZoneInstance.id, idToTest); - const bag3 = { year: 1970, monthCode: "M01", day: 1, timeZone: customTimeZoneInstance }; - assert.sameValue(instance.equals(bag3), true, `Offset time zones are equal despite ${description} syntax in custom object time zone ID`); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-datetime.js index e39e593354d..516c2bbbd47 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-datetime.js @@ -13,6 +13,35 @@ const instance1 = new Temporal.ZonedDateTime(0n, expectedTimeZone); let timeZone = "2021-02-19T17:30"; assert.throws(RangeError, () => instance1.equals({ year: 1970, month: 1, day: 1, timeZone }), "bare date-time string is not a time zone"); +[ + "2021-08-19T17:30-07:00:01", + "2021-08-19T17:30-07:00:00", + "2021-08-19T17:30-07:00:00.1", + "2021-08-19T17:30-07:00:00.0", + "2021-08-19T17:30-07:00:00.01", + "2021-08-19T17:30-07:00:00.00", + "2021-08-19T17:30-07:00:00.001", + "2021-08-19T17:30-07:00:00.000", + "2021-08-19T17:30-07:00:00.0001", + "2021-08-19T17:30-07:00:00.0000", + "2021-08-19T17:30-07:00:00.00001", + "2021-08-19T17:30-07:00:00.00000", + "2021-08-19T17:30-07:00:00.000001", + "2021-08-19T17:30-07:00:00.000000", + "2021-08-19T17:30-07:00:00.0000001", + "2021-08-19T17:30-07:00:00.0000000", + "2021-08-19T17:30-07:00:00.00000001", + "2021-08-19T17:30-07:00:00.00000000", + "2021-08-19T17:30-07:00:00.000000001", + "2021-08-19T17:30-07:00:00.000000000", +].forEach((timeZone) => { + assert.throws( + RangeError, + () => instance1.equals({ year: 2020, month: 5, day: 2, timeZone }), + `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` + ); +}); + // The following are all valid strings so should not throw. They should produce // expectedTimeZone, so additionally the operation should return true, because // the property bag will produce an instance that's equal to the receiver. diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-leap-second.js index 4095674ad27..1ce2e31113d 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-leap-second.js @@ -7,7 +7,7 @@ description: Leap second is a valid ISO string for TimeZone features: [Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(1588377600_000_000_000n, new Temporal.TimeZone("UTC")); +const instance = new Temporal.ZonedDateTime(1588377600_000_000_000n, "UTC"); let timeZone = "2016-12-31T23:59:60+00:00[UTC]"; assert(instance.equals({ year: 2020, month: 5, day: 2, timeZone }), "leap second is a valid ISO string for TimeZone"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-year-zero.js index 54780e6540e..c83c6562e8f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-year-zero.js @@ -11,7 +11,7 @@ const invalidStrings = [ "-000000-10-31T17:45Z", "-000000-10-31T17:45+00:00[UTC]", ]; -const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); invalidStrings.forEach((timeZone) => { assert.throws( RangeError, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string.js index 57de6c0244c..c6df5823b2e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string.js @@ -4,32 +4,12 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.equals description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const instance1 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance1 = new Temporal.ZonedDateTime(0n, "UTC"); assert(instance1.equals({ year: 1970, month: 1, day: 1, timeZone: "UTC" }), "Time zone created from string 'UTC'"); -const instance2 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("-01:30")); +const instance2 = new Temporal.ZonedDateTime(0n, "-01:30"); assert(instance2.equals({ year: 1969, month: 12, day: 31, hour: 22, minute: 30, timeZone: "-01:30" }), "Time zone created from string '-01:30'"); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-wrong-type.js index 5f8aa22f5e7..5e66c7bb893 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.zoneddatetime.prototype.equals description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const primitiveTests = [ [null, "null"], @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation.js index 72352bbc3b7..c724776955b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-calendar-annotation.js @@ -13,8 +13,7 @@ const tests = [ ["1970-01-01T00:00[UTC][u-ca=iso8601][u-ca=discord]", "second annotation ignored"], ]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); tests.forEach(([arg, description]) => { const result = instance.equals(arg); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-critical-unknown-annotation.js index c1fcd5403a1..08e2e68651d 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-critical-unknown-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-critical-unknown-annotation.js @@ -13,8 +13,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][u-ca=iso8601][!foo=bar]", "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", ]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); invalidStrings.forEach((arg) => { assert.throws( RangeError, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-date-with-utc-offset.js index 6892a971050..6062e4df27b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-date-with-utc-offset.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-date-with-utc-offset.js @@ -7,8 +7,7 @@ description: UTC offset not valid with format that does not include a time features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const validStrings = [ "1970-01-01T00Z[UTC]", diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-calendar.js index 7627303897b..2826b7f24aa 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-calendar.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-calendar.js @@ -14,8 +14,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][!u-ca=iso8601][u-ca=iso8601]", "1970-01-01T00:00[UTC][u-ca=iso8601][foo=bar][!u-ca=iso8601]", ]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); invalidStrings.forEach((arg) => { assert.throws( RangeError, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-time-zone.js index 642bb280c27..b33bf53fd14 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-time-zone.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-multiple-time-zone.js @@ -14,8 +14,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", "1970-01-01T00:00[UTC][foo=bar][UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); invalidStrings.forEach((arg) => { assert.throws( RangeError, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-separators.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-separators.js index 3c5f4f802ab..fc8d5a4032c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-separators.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-separators.js @@ -13,8 +13,7 @@ const tests = [ ["1970-01-01 00:00+00:00[UTC]", "space between date and time"], ]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); tests.forEach(([arg, description]) => { const result = instance.equals(arg); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-zone-annotation.js index 3de8846476c..871fae193c8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-zone-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-time-zone-annotation.js @@ -23,8 +23,7 @@ const tests = [ ]; tests.forEach(([arg, expectedZone, description]) => { - const timeZone = new Temporal.TimeZone(expectedZone); - const instance = new Temporal.ZonedDateTime(0n, timeZone); + const instance = new Temporal.ZonedDateTime(0n, expectedZone); const result = instance.equals(arg); assert.sameValue( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-unknown-annotation.js index eb815b4d71f..5b1b95123b2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-unknown-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-string-unknown-annotation.js @@ -14,8 +14,7 @@ const tests = [ ["1970-01-01T00:00[UTC][foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], ]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); tests.forEach(([arg, description]) => { const result = instance.equals(arg); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-valid.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-valid.js new file mode 100644 index 00000000000..34522d954fb --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-valid.js @@ -0,0 +1,35 @@ +// Copyright (C) 2023 Justin Grant. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Built-in time zones are compared correctly out of valid strings +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const validsEqual = [ + ["+0330", "+03:30"], + ["-0650", "-06:50"], + ["-08", "-08:00"], + ["1994-11-05T08:15:30-05:00", "-05:00"], + ["1994-11-05T13:15:30Z", "UTC"] +]; + +for (const [valid, canonical] of validsEqual) { + assert(instance.withTimeZone(valid).equals(instance.withTimeZone(canonical)), `${valid} time zone equals ${canonical}`); + assert(instance.withTimeZone(canonical).equals(instance.withTimeZone(valid)), `${canonical} time zone equals ${valid}`); +} + +const validsNotEqual = [ + ["+0330", "+03:31"], + ["-0650", "-06:51"], + ["-08", "-08:01"], + ["1994-11-05T08:15:30-05:00", "-05:01"], +]; + +for (const [valid, canonical] of validsNotEqual) { + assert(!instance.withTimeZone(valid).equals(instance.withTimeZone(canonical)), `${valid} time zone does not equal ${canonical}`); + assert(!instance.withTimeZone(canonical).equals(instance.withTimeZone(valid)), `${canonical} time zone does not equal ${valid}`); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-wrong-type.js index 4cf570fd748..e3170621ff8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const primitiveTests = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/branding.js index 3d135a3d381..aad00b4013e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/branding.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/branding.js @@ -11,7 +11,7 @@ const equals = Temporal.ZonedDateTime.prototype.equals; assert.sameValue(typeof equals, "function"); -const args = [new Temporal.ZonedDateTime(123456n, new Temporal.TimeZone("UTC"))]; +const args = [new Temporal.ZonedDateTime(123456n, "UTC")]; assert.throws(TypeError, () => equals.apply(undefined, args), "undefined"); assert.throws(TypeError, () => equals.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/builtin-calendar-no-observable-calls.js deleted file mode 100644 index cef90b77f8d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.equals(new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC")); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 6c8a4188bb0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id"); -Object.defineProperty(Temporal.TimeZone.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.equals(new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC")); - -Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 79a0560dec5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); -const arg = { year: 2000, month: 5, day: 2, timeZone, calendar }; -instance.equals(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-fields-iterable.js deleted file mode 100644 index 732f3fd1ebf..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.zoneddatetime.prototype.equals step 3: - 3. Set _other_ to ? ToTemporalZonedDateTime(_other_). - sec-temporal-totemporalzoneddatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -datetime.equals({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/constructor-in-calendar-fields.js deleted file mode 100644 index c353bbb70d5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/constructor-in-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/duplicate-calendar-fields.js deleted file mode 100644 index 1bceadc5ca7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/duplicate-calendar-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const timeZone = 'Europe/Paris' - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; - const instance = new Temporal.ZonedDateTime(0n, timeZone); - - assert.throws(RangeError, () => instance.equals(arg)); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/leap-second.js index cc57129d4ee..23636509293 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/leap-second.js @@ -7,7 +7,7 @@ description: Leap second is a valid ISO string for ZonedDateTime features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(1_483_228_799_000_000_000n, timeZone); let arg = "2016-12-31T23:59:60+00:00[UTC]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js index 04847b5b45c..b1497c8e51e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/order-of-operations.js @@ -10,30 +10,6 @@ features: [Temporal] const expected = [ "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.dateFromFields", - "get other.calendar.fields", - "call other.calendar.fields", // PrepareTemporalFields "get other.day", "get other.day.valueOf", @@ -69,23 +45,6 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", - "has other.timeZone.getOffsetNanosecondsFor", - "has other.timeZone.getPossibleInstantsFor", - "has other.timeZone.id", - // InterpretTemporalDateTimeFields - "call other.calendar.dateFromFields", - // lookup in ToTemporalZonedDateTime - "get other.timeZone.getOffsetNanosecondsFor", - "get other.timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call other.timeZone.getPossibleInstantsFor", - "call other.timeZone.getOffsetNanosecondsFor", - // TimeZoneEquals - "get this.timeZone.id", - "get other.timeZone.id", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", ]; const actual = []; @@ -101,18 +60,11 @@ const other = TemporalHelpers.propertyBagObserver(actual, { microsecond: 654, nanosecond: 321, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"), -}, "other"); + calendar: "iso8601", + timeZone: "UTC", +}, "other", ["calendar", "timeZone"]); -const instance = new Temporal.ZonedDateTime( - 988786472_987_654_321n, /* 2001-05-02T06:54:32.987654321Z */ - TemporalHelpers.timeZoneObserver(actual, "this.timeZone"), - TemporalHelpers.calendarObserver(actual, "this.calendar"), -); -// clear any observable operations that happen due to time zone or calendar -// calls on the constructor -actual.splice(0); +const instance = new Temporal.ZonedDateTime(988786472_987_654_321n, /* 2001-05-02T06:54:32.987654321Z */ "UTC"); instance.equals(other); assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/proto-in-calendar-fields.js deleted file mode 100644 index 72df1a3def8..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/proto-in-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -assert.throws(RangeError, () => instance.equals(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/read-time-fields-before-datefromfields.js deleted file mode 100644 index c5d5bd9cdec..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.zoneddatetime.prototype.equals step 3: - 3. Set _other_ to ? ToTemporalZonedDateTime(_other_). - sec-temporal-totemporalzoneddatetime step 2.j: - j. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); -const result = datetime.equals({ year: 2001, month: 9, day: 9, hour: 1, minute: 46, second: 40, millisecond: 987, microsecond: 654, nanosecond: 321, timeZone: "UTC", calendar }); - -assert(result, "time fields are not modified"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index 4a0cc24f772..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.zoneddatetime.prototype.equals step 3: - 3. Set _other_ to ? ToTemporalZonedDateTime(_other_). - sec-temporal-totemporalzoneddatetime step 7: - 7. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], [...], _result_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, _disambiguation_, _offset_). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// Not called on the instance's time zone - -const expected1 = []; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - datetime.equals({ year: 2005, month: 6, day: 2, timeZone: "UTC" }); -}, expected1); - -// Called on the argument's time zone - -const expected2 = [ - "2005-06-02T00:00:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - datetime.equals({ year: 2005, month: 6, day: 2, timeZone }); -}, expected2); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js index 3e87ae88931..6fd3a523688 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/year-zero.js @@ -12,8 +12,7 @@ const invalidStrings = [ "-0000000-01-01T00:02+00:00[UTC]", "-0000000-01-01T00:02:00.000000000+00:00[UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); invalidStrings.forEach((arg) => { assert.throws( RangeError, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js index 72686fb9697..f0044989a05 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string-multiple-offsets.js @@ -7,7 +7,7 @@ description: Sub-minute offset trailing zeroes allowed in ISO string but not in features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+01:35"); +const timeZone = "+01:35"; const instance = new Temporal.ZonedDateTime(0n, timeZone); let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string.js index 68202ab8b82..9a7e7f4f967 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/zoneddatetime-string.js @@ -7,7 +7,7 @@ description: Conversion of ISO date-time strings to Temporal.ZonedDateTime insta features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+01:00"); +const timeZone = "+01:00"; const instance = new Temporal.ZonedDateTime(0n, timeZone); let str = "1970-01-01T00:00"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/branding.js deleted file mode 100644 index 3dfefde3bf3..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getcalendar -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getCalendar = Temporal.ZonedDateTime.prototype.getCalendar; - -assert.sameValue(typeof getCalendar, "function"); - -assert.throws(TypeError, () => getCalendar.call(undefined), "undefined"); -assert.throws(TypeError, () => getCalendar.call(null), "null"); -assert.throws(TypeError, () => getCalendar.call(true), "true"); -assert.throws(TypeError, () => getCalendar.call(""), "empty string"); -assert.throws(TypeError, () => getCalendar.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getCalendar.call(1), "1"); -assert.throws(TypeError, () => getCalendar.call({}), "plain object"); -assert.throws(TypeError, () => getCalendar.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime"); -assert.throws(TypeError, () => getCalendar.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/builtin.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/builtin.js deleted file mode 100644 index 65be1d8c8fa..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getcalendar -description: > - Tests that Temporal.ZonedDateTime.prototype.getCalendar - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.getCalendar), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.getCalendar), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.getCalendar), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.ZonedDateTime.prototype.getCalendar.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/length.js deleted file mode 100644 index 2fb3cc1ba7c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getcalendar -description: Temporal.ZonedDateTime.prototype.getCalendar.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.ZonedDateTime.prototype.getCalendar, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/name.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/name.js deleted file mode 100644 index ad363666038..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getcalendar -description: Temporal.ZonedDateTime.prototype.getCalendar.name is "getCalendar". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.ZonedDateTime.prototype.getCalendar, "name", { - value: "getCalendar", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/not-a-constructor.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/not-a-constructor.js deleted file mode 100644 index 2f7c96899f5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getcalendar -description: > - Temporal.ZonedDateTime.prototype.getCalendar does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.ZonedDateTime.prototype.getCalendar(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.getCalendar), false, - "isConstructor(Temporal.ZonedDateTime.prototype.getCalendar)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/prop-desc.js deleted file mode 100644 index a6346fbccf9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getCalendar/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getcalendar -description: The "getCalendar" property of Temporal.ZonedDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.ZonedDateTime.prototype.getCalendar, - "function", - "`typeof ZonedDateTime.prototype.getCalendar` is `function`" -); - -verifyProperty(Temporal.ZonedDateTime.prototype, "getCalendar", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/balance-negative-time-units.js deleted file mode 100644 index 3ebd5e70bb9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/balance-negative-time-units.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: Negative time fields are balanced upwards -info: | - sec-temporal-balancetime steps 3–14: - 3. Set _microsecond_ to _microsecond_ + floor(_nanosecond_ / 1000). - 4. Set _nanosecond_ to _nanosecond_ modulo 1000. - 5. Set _millisecond_ to _millisecond_ + floor(_microsecond_ / 1000). - 6. Set _microsecond_ to _microsecond_ modulo 1000. - 7. Set _second_ to _second_ + floor(_millisecond_ / 1000). - 8. Set _millisecond_ to _millisecond_ modulo 1000. - 9. Set _minute_ to _minute_ + floor(_second_ / 60). - 10. Set _second_ to _second_ modulo 60. - 11. Set _hour_ to _hour_ + floor(_minute_ / 60). - 12. Set _minute_ to _minute_ modulo 60. - 13. Let _days_ be floor(_hour_ / 24). - 14. Set _hour_ to _hour_ modulo 24. - sec-temporal-balanceisodatetime step 1: - 1. Let _balancedTime_ be ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). - sec-temporal-builtintimezonegetplaindatetimefor step 3: - 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). - sec-get-temporal.zoneddatetime.prototype.getisofields step 7: - 7. Let _dateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// This code path is encountered if the time zone offset is negative and its -// absolute value in nanoseconds is greater than the nanosecond field of the -// ZonedDateTime -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(1001n, tz); - -const fields = datetime.getISOFields(); - -assert.sameValue(fields.isoMicrosecond, 0); -assert.sameValue(fields.isoNanosecond, 999); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/branding.js deleted file mode 100644 index 9524ed7e602..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getISOFields = Temporal.ZonedDateTime.prototype.getISOFields; - -assert.sameValue(typeof getISOFields, "function"); - -assert.throws(TypeError, () => getISOFields.call(undefined), "undefined"); -assert.throws(TypeError, () => getISOFields.call(null), "null"); -assert.throws(TypeError, () => getISOFields.call(true), "true"); -assert.throws(TypeError, () => getISOFields.call(""), "empty string"); -assert.throws(TypeError, () => getISOFields.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getISOFields.call(1), "1"); -assert.throws(TypeError, () => getISOFields.call({}), "plain object"); -assert.throws(TypeError, () => getISOFields.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime"); -assert.throws(TypeError, () => getISOFields.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/builtin-timezone-no-observable-calls.js deleted file mode 100644 index d4384733e62..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.getISOFields(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/builtin.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/builtin.js deleted file mode 100644 index ed925e1e4ed..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: > - Tests that Temporal.ZonedDateTime.prototype.getISOFields - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.getISOFields), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.getISOFields), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.getISOFields), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.ZonedDateTime.prototype.getISOFields.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/custom.js deleted file mode 100644 index 2900a83ee07..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/custom.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: getISOFields does not call into user code. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarThrowEverything(); -const instance = new Temporal.ZonedDateTime(1_000_086_400_987_654_321n, "UTC", calendar); -const result = instance.getISOFields(); - -assert.sameValue(result.isoYear, 2001, "isoYear result"); -assert.sameValue(result.isoMonth, 9, "isoMonth result"); -assert.sameValue(result.isoDay, 10, "isoDay result"); -assert.sameValue(result.isoHour, 1, "isoHour result"); -assert.sameValue(result.isoMinute, 46, "isoMinute result"); -assert.sameValue(result.isoSecond, 40, "isoSecond result"); -assert.sameValue(result.isoMillisecond, 987, "isoMillisecond result"); -assert.sameValue(result.isoMicrosecond, 654, "isoMicrosecond result"); -assert.sameValue(result.isoNanosecond, 321, "isoNanosecond result"); -assert.sameValue(result.offset, "+00:00", "offset result"); -assert.sameValue(result.calendar, calendar, "calendar result"); -assert.sameValue(result.timeZone, "UTC", "timeZone result"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/field-names.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/field-names.js deleted file mode 100644 index 10861de182b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/field-names.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: Correct field names on the object returned from getISOFields -features: [Temporal] ----*/ - -const datetime = new Temporal.ZonedDateTime(1_000_086_400_987_654_321n, "UTC"); - -const result = datetime.getISOFields(); -assert.sameValue(result.isoYear, 2001, "isoYear result"); -assert.sameValue(result.isoMonth, 9, "isoMonth result"); -assert.sameValue(result.isoDay, 10, "isoDay result"); -assert.sameValue(result.isoHour, 1, "isoHour result"); -assert.sameValue(result.isoMinute, 46, "isoMinute result"); -assert.sameValue(result.isoSecond, 40, "isoSecond result"); -assert.sameValue(result.isoMillisecond, 987, "isoMillisecond result"); -assert.sameValue(result.isoMicrosecond, 654, "isoMicrosecond result"); -assert.sameValue(result.isoNanosecond, 321, "isoNanosecond result"); -assert.sameValue(result.offset, "+00:00", "offset result"); -assert.sameValue(result.calendar, "iso8601", "calendar result"); -assert.sameValue(result.timeZone, "UTC", "timeZone result"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/field-prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/field-prop-desc.js deleted file mode 100644 index 30afae90935..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/field-prop-desc.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: Properties on the returned object have the correct descriptor -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoHour", - "isoMicrosecond", - "isoMillisecond", - "isoMinute", - "isoMonth", - "isoNanosecond", - "isoSecond", - "isoYear", - "offset", - "timeZone", -]; - -const datetime = new Temporal.ZonedDateTime(1_000_086_400_987_654_321n, "UTC"); -const result = datetime.getISOFields(); - -for (const property of expected) { - verifyProperty(result, property, { - writable: true, - enumerable: true, - configurable: true, - }); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/field-traversal-order.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/field-traversal-order.js deleted file mode 100644 index a7b600d1187..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/field-traversal-order.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: Properties added in correct order to object returned from getISOFields -includes: [compareArray.js] -features: [Temporal] ----*/ - -const expected = [ - "calendar", - "isoDay", - "isoHour", - "isoMicrosecond", - "isoMillisecond", - "isoMinute", - "isoMonth", - "isoNanosecond", - "isoSecond", - "isoYear", - "offset", - "timeZone", -]; - -const datetime = new Temporal.ZonedDateTime(1_000_086_400_987_654_321n, "UTC"); -const result = datetime.getISOFields(); - -assert.compareArray(Object.keys(result), expected); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/length.js deleted file mode 100644 index 0a99d6dcc5c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: Temporal.ZonedDateTime.prototype.getISOFields.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.ZonedDateTime.prototype.getISOFields, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/name.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/name.js deleted file mode 100644 index e68c8bdc4e9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: Temporal.ZonedDateTime.prototype.getISOFields.name is "getISOFields". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.ZonedDateTime.prototype.getISOFields, "name", { - value: "getISOFields", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/negative-epochnanoseconds.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/negative-epochnanoseconds.js deleted file mode 100644 index 7a4350cecc5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/negative-epochnanoseconds.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: A pre-epoch value is handled correctly by the modulo operation in GetISOPartsFromEpoch -info: | - sec-temporal-getisopartsfromepoch step 1: - 1. Let _remainderNs_ be the mathematical value whose sign is the sign of _epochNanoseconds_ and whose magnitude is abs(_epochNanoseconds_) modulo 106. - sec-temporal-builtintimezonegetplaindatetimefor step 2: - 2. Let _result_ be ! GetISOPartsFromEpoch(_instant_.[[Nanoseconds]]). -features: [Temporal] -includes: [deepEqual.js] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const calendar = new Temporal.Calendar("iso8601"); -const datetime = new Temporal.ZonedDateTime(-13849764_999_999_999n, timeZone, calendar); - -// This code path shows up anywhere we convert an exact time, before the Unix -// epoch, with nonzero microseconds or nanoseconds, into a wall time. - -const result = datetime.getISOFields(); -assert.deepEqual(result, { - calendar, - isoDay: 24, - isoHour: 16, - isoMicrosecond: 0, - isoMillisecond: 0, - isoMinute: 50, - isoMonth: 7, - isoNanosecond: 1, - isoSecond: 35, - isoYear: 1969, - offset: "+00:00", - timeZone, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/not-a-constructor.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/not-a-constructor.js deleted file mode 100644 index 7ebdadf8a56..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: > - Temporal.ZonedDateTime.prototype.getISOFields does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.ZonedDateTime.prototype.getISOFields(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.getISOFields), false, - "isConstructor(Temporal.ZonedDateTime.prototype.getISOFields)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/offset.js deleted file mode 100644 index 96fa20c61fc..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/offset.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: The offset property of returned object -features: [BigInt, Temporal] ----*/ - -function test(timeZoneIdentifier, expectedOffsetString, description) { - const timeZone = new Temporal.TimeZone(timeZoneIdentifier); - const datetime = new Temporal.ZonedDateTime(0n, timeZone); - const fields = datetime.getISOFields(); - assert.sameValue(fields.offset, expectedOffsetString, description); -} - -test("UTC", "+00:00", "offset of UTC is +00:00"); -test("+01:00", "+01:00", "positive offset"); -test("-05:00", "-05:00", "negative offset"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/order-of-operations.js deleted file mode 100644 index 155ccd19bac..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/order-of-operations.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: > - Properties on the calendar or time zone of the receiver of getISOFields() - are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", -]; -const actual = []; - -const instance = new Temporal.ZonedDateTime( - 988786472_987_654_321n, /* 2001-05-02T06:54:32.987654321Z */ - TemporalHelpers.timeZoneObserver(actual, "this.timeZone"), - TemporalHelpers.calendarObserver(actual, "this.calendar"), -); -// clear any observable operations that happen due to time zone or calendar -// calls on the constructor -actual.splice(0); - -instance.getISOFields(); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/prop-desc.js deleted file mode 100644 index 4a7416a6583..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: The "getISOFields" property of Temporal.ZonedDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.ZonedDateTime.prototype.getISOFields, - "function", - "`typeof ZonedDateTime.prototype.getISOFields` is `function`" -); - -verifyProperty(Temporal.ZonedDateTime.prototype, "getISOFields", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/prototype.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/prototype.js deleted file mode 100644 index 83988ce4315..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/prototype.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: Correct prototype on the object returned from getISOFields -features: [Temporal] ----*/ - -const instance = new Temporal.ZonedDateTime(1_000_086_400_987_654_321n, "UTC"); -const result = instance.getISOFields(); -assert.sameValue(Object.getPrototypeOf(result), Object.prototype, "prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index ef507e52ada..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.getISOFields()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index e9af8821a22..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.getISOFields(), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 500292b41e1..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.getISOFields()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 6ca3f881fbf..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getISOFields/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.getisofields -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.getISOFields()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/branding.js deleted file mode 100644 index c76788b8c09..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.gettimezone -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const getTimeZone = Temporal.ZonedDateTime.prototype.getTimeZone; - -assert.sameValue(typeof getTimeZone, "function"); - -assert.throws(TypeError, () => getTimeZone.call(undefined), "undefined"); -assert.throws(TypeError, () => getTimeZone.call(null), "null"); -assert.throws(TypeError, () => getTimeZone.call(true), "true"); -assert.throws(TypeError, () => getTimeZone.call(""), "empty string"); -assert.throws(TypeError, () => getTimeZone.call(Symbol()), "symbol"); -assert.throws(TypeError, () => getTimeZone.call(1), "1"); -assert.throws(TypeError, () => getTimeZone.call({}), "plain object"); -assert.throws(TypeError, () => getTimeZone.call(Temporal.ZonedDateTime), "Temporal.ZonedDateTime"); -assert.throws(TypeError, () => getTimeZone.call(Temporal.ZonedDateTime.prototype), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/builtin.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/builtin.js deleted file mode 100644 index 57e6dddd755..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.gettimezone -description: > - Tests that Temporal.ZonedDateTime.prototype.getTimeZone - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.getTimeZone), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.getTimeZone), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.getTimeZone), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.ZonedDateTime.prototype.getTimeZone.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/length.js deleted file mode 100644 index 20da9dcdc71..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.gettimezone -description: Temporal.ZonedDateTime.prototype.getTimeZone.length is 0 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZone, "length", { - value: 0, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/name.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/name.js deleted file mode 100644 index 4f4af47f7bb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.gettimezone -description: Temporal.ZonedDateTime.prototype.getTimeZone.name is "getTimeZone". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZone, "name", { - value: "getTimeZone", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/not-a-constructor.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/not-a-constructor.js deleted file mode 100644 index 56bea9fcd7a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.gettimezone -description: > - Temporal.ZonedDateTime.prototype.getTimeZone does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.ZonedDateTime.prototype.getTimeZone(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.getTimeZone), false, - "isConstructor(Temporal.ZonedDateTime.prototype.getTimeZone)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/prop-desc.js deleted file mode 100644 index 074f4345aa0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZone/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.gettimezone -description: The "getTimeZone" property of Temporal.ZonedDateTime.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.ZonedDateTime.prototype.getTimeZone, - "function", - "`typeof ZonedDateTime.prototype.getTimeZone` is `function`" -); - -verifyProperty(Temporal.ZonedDateTime.prototype, "getTimeZone", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/branding.js new file mode 100644 index 00000000000..f15818dd7e9 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/branding.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Throw a TypeError if the receiver is invalid +features: [Symbol, Temporal] +---*/ + +const getTimeZoneTransition = Temporal.ZonedDateTime.prototype.getTimeZoneTransition; + +assert.sameValue(typeof getTimeZoneTransition, "function"); + +const args = ["next"]; + +assert.throws(TypeError, () => getTimeZoneTransition.apply(undefined, args), "undefined"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(null, args), "null"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(true, args), "true"); +assert.throws(TypeError, () => getTimeZoneTransition.apply("", args), "empty string"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(Symbol(), args), "symbol"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(1, args), "1"); +assert.throws(TypeError, () => getTimeZoneTransition.apply({}, args), "plain object"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(Temporal.ZonedDateTime, args), "Temporal.ZonedDateTime"); +assert.throws(TypeError, () => getTimeZoneTransition.apply(Temporal.ZonedDateTime.prototype, args), "Temporal.ZonedDateTime.prototype"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/builtin.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/builtin.js new file mode 100644 index 00000000000..6da129db63f --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/builtin.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Tests that Temporal.ZonedDateTime.prototype.getTimeZoneTransition + meets the requirements for built-in objects defined by the + introduction of chapter 17 of the ECMAScript Language Specification. +info: | + Built-in functions that are not constructors do not have a "prototype" property unless + otherwise specified in the description of a particular function. + + Unless specified otherwise, a built-in object that is callable as a function is a built-in + function object with the characteristics described in 10.3. Unless specified otherwise, the + [[Extensible]] internal slot of a built-in object initially has the value true. + + Unless otherwise specified every built-in function and every built-in constructor has the + Function prototype object [...] as the value of its [[Prototype]] internal slot. +features: [Temporal] +---*/ + +assert.sameValue(Object.isExtensible(Temporal.ZonedDateTime.prototype.getTimeZoneTransition), + true, "Built-in objects must be extensible."); + +assert.sameValue(Object.prototype.toString.call(Temporal.ZonedDateTime.prototype.getTimeZoneTransition), + "[object Function]", "Object.prototype.toString"); + +assert.sameValue(Object.getPrototypeOf(Temporal.ZonedDateTime.prototype.getTimeZoneTransition), + Function.prototype, "prototype"); + +assert.sameValue(Temporal.ZonedDateTime.prototype.getTimeZoneTransition.hasOwnProperty("prototype"), + false, "prototype property"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-undefined.js new file mode 100644 index 00000000000..a1cacf2be8d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-undefined.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: If using options bag form, direction property is required +info: | + 1. Let _direction_ be ? GetDirectionOption(_directionParam_). +features: [Temporal] +---*/ + +const zdt = new Temporal.ZonedDateTime(0n, "UTC"); +assert.throws(RangeError, () => zdt.getTimeZoneTransition({})); +assert.throws(RangeError, () => zdt.getTimeZoneTransition({ direction: undefined })); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-wrong-type.js new file mode 100644 index 00000000000..8a250c6b2ce --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/direction-wrong-type.js @@ -0,0 +1,18 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Value of direction property cannot be a primitive other than string +info: | + 1. Let _direction_ be ? GetDirectionOption(_directionParam_). +features: [Temporal] +---*/ + +const zdt = new Temporal.ZonedDateTime(0n, "UTC"); + +const rangeErrorValues = [false, 42, 55n, null]; +for (const badValue of rangeErrorValues) { + assert.throws(RangeError, () => zdt.getTimeZoneTransition({ direction: badValue }), "Non-Symbol throws a RangeError"); +} +assert.throws(TypeError, () => zdt.getTimeZoneTransition({ direction: Symbol("next") }), "Symbol throws a TypeError"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/length.js new file mode 100644 index 00000000000..8118b516766 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/length.js @@ -0,0 +1,25 @@ +// Copyright (C) 2020 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Temporal.ZonedDateTime.prototype.getTimeZoneTransition.length is 0 +info: | + Every built-in function object, including constructors, has a "length" property whose value is + an integer. Unless otherwise specified, this value is equal to the largest number of named + arguments shown in the subclause headings for the function description. Optional parameters + (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form + «...name») are not included in the default argument count. + + Unless otherwise specified, the "length" property of a built-in function object has the + attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Temporal] +---*/ + +verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZoneTransition, "length", { + value: 1, + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/name.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/name.js new file mode 100644 index 00000000000..b6e4d806663 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/name.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Temporal.ZonedDateTime.prototype.getTimeZoneTransition.name is "getTimeZoneTransition". +info: | + Every built-in function object, including constructors, that is not identified as an anonymous + function has a "name" property whose value is a String. Unless otherwise specified, this value + is the name that is given to the function in this specification. + + Unless otherwise specified, the "name" property of a built-in function object, if it exists, + has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. +includes: [propertyHelper.js] +features: [Temporal] +---*/ + +verifyProperty(Temporal.ZonedDateTime.prototype.getTimeZoneTransition, "name", { + value: "getTimeZoneTransition", + writable: false, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/not-a-constructor.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/not-a-constructor.js new file mode 100644 index 00000000000..38cb5680c26 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/not-a-constructor.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Temporal.ZonedDateTime.prototype.getTimeZoneTransition does not implement [[Construct]], is not new-able +info: | + Built-in function objects that are not identified as constructors do not implement the + [[Construct]] internal method unless otherwise specified in the description of a particular + function. +includes: [isConstructor.js] +features: [Reflect.construct, Temporal] +---*/ + +assert.throws(TypeError, () => { + new Temporal.ZonedDateTime.prototype.getTimeZoneTransition(); +}, "Calling as constructor"); + +assert.sameValue(isConstructor(Temporal.ZonedDateTime.prototype.getTimeZoneTransition), false, + "isConstructor(Temporal.ZonedDateTime.prototype.getTimeZoneTransition)"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/offset-timezone-no-transitions.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/offset-timezone-no-transitions.js new file mode 100644 index 00000000000..b64f3ee5eee --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/offset-timezone-no-transitions.js @@ -0,0 +1,12 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: An offset time zone has no transitions. +features: [Temporal] +---*/ + +const zdt = new Temporal.ZonedDateTime(0n, "-10:00"); +assert.sameValue(zdt.getTimeZoneTransition("next"), null, "An offset time zone has no next transition"); +assert.sameValue(zdt.getTimeZoneTransition("previous"), null, "An offset time zone has no previous transition"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/options-undefined.js new file mode 100644 index 00000000000..eaec7462ffa --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/options-undefined.js @@ -0,0 +1,15 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Options argument is required +info: | + 1. If _directionParam_ is *undefined*, throw a *TypeError* exception. +features: [Temporal] +---*/ + +const zdt = new Temporal.ZonedDateTime(0n, "UTC"); + +assert.throws(TypeError, () => zdt.getTimeZoneTransition()); +assert.throws(TypeError, () => zdt.getTimeZoneTransition(undefined)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/prop-desc.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/prop-desc.js new file mode 100644 index 00000000000..7f1736e4e97 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/prop-desc.js @@ -0,0 +1,21 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: The "getTimeZoneTransition" property of Temporal.ZonedDateTime.prototype +includes: [propertyHelper.js] +features: [Temporal] +---*/ + +assert.sameValue( + typeof Temporal.ZonedDateTime.prototype.getTimeZoneTransition, + "function", + "`typeof ZonedDateTime.prototype.getTimeZoneTransition` is `function`" +); + +verifyProperty(Temporal.ZonedDateTime.prototype, "getTimeZoneTransition", { + writable: true, + enumerable: false, + configurable: true, +}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/utc-no-transitions.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/utc-no-transitions.js new file mode 100644 index 00000000000..fc6e849ed55 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/utc-no-transitions.js @@ -0,0 +1,12 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: The UTC time zone has no transitions. +features: [Temporal] +---*/ + +const zdt = new Temporal.ZonedDateTime(0n, "UTC"); +assert.sameValue(zdt.getTimeZoneTransition("next"), null, "The UTC time zone has no next transition"); +assert.sameValue(zdt.getTimeZoneTransition("previous"), null, "The UTC time zone has no previous transition"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-string.js new file mode 100644 index 00000000000..ff0ee1151bc --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-string.js @@ -0,0 +1,25 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Shorthand form is treated the same as options bag form with respect to + incorrect strings +info: | + 1. If _directionParam_ is a String, then + 1. Let _paramString_ be _directionParam_. + 1. Set _roundTo_ to OrdinaryObjectCreate(*null*). + 1. Perform ! CreateDataPropertyOrThrow(_directionParam_, *"direction"*, _paramString_). + ... + 1. Let _direction_ be ? GetDirectionOption(_directionParam_). +features: [Temporal] +---*/ + +const zdt = new Temporal.ZonedDateTime(0n, "UTC"); + +const badStrings = ['PREVIOUS', 'following', 'next\0', 'prevıous']; +for (const badString of badStrings) { + assert.throws(RangeError, () => zdt.getTimeZoneTransition(badString)); + assert.throws(RangeError, () => zdt.getTimeZoneTransition({ direction: badString })); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-type.js new file mode 100644 index 00000000000..33a6731e4e1 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/wrong-type.js @@ -0,0 +1,21 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Options bag cannot be anything other than a string, an object, or undefined +info: | + 1. If _directionParam_ is a String, then + ... + 1. Else, + 1. Set _directionParam_ to ? GetOptionsObject(_directionParam_). +features: [Temporal] +---*/ + +const zdt = new Temporal.ZonedDateTime(0n, "UTC"); + +const badValues = [false, 42, 55n, Symbol("foo"), null]; +for (const badValue of badValues) { + assert.throws(TypeError, () => zdt.getTimeZoneTransition(badValue)); +} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hour/balance-negative-time-units.js index 5343d7074ec..00549317f95 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/hour/balance-negative-time-units.js @@ -22,19 +22,17 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.hour step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3600_000_000_001n, tz); +const datetime = new Temporal.ZonedDateTime(3600_000_000_001n, "-00:02"); assert.sameValue(datetime.hour, 0); -assert.sameValue(datetime.minute, 59); -assert.sameValue(datetime.second, 59); -assert.sameValue(datetime.millisecond, 999); -assert.sameValue(datetime.microsecond, 999); -assert.sameValue(datetime.nanosecond, 999); +assert.sameValue(datetime.minute, 58); +assert.sameValue(datetime.second, 0); +assert.sameValue(datetime.millisecond, 0); +assert.sameValue(datetime.microsecond, 0); +assert.sameValue(datetime.nanosecond, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hour/builtin-timezone-no-observable-calls.js deleted file mode 100644 index e34f3fc6b5d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.hour -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.hour; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 2580dd770d4..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hour -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.hour); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 59b12653fbc..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hour -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.hour, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 7fb54f810ec..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hour -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.hour); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 75eb9fbaab4..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hour/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hour -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.hour); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index 6cab9948529..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.hoursinday -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants can be at most 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - calls++; - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12 })]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.hoursInDay; - -assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js deleted file mode 100644 index a09c761ba4c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.hoursinday -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.hoursInDay, "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 0d80199a52d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.hoursinday -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone, nonBuiltinISOCalendar); -instance.hoursInDay; - -assert.sameValue(timeZone.calls, 4, "getPossibleInstantsFor should have been called 4 times"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index 3b72e208df0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-maximum-backward-offset-shift.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.hoursinday -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - calls++; - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12 }), - utcInstant.add({ hours: 12 }) - ]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.hoursInDay; - -assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index f0e539eaf3c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.hoursinday -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.hoursInDay, "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/order-of-operations.js deleted file mode 100644 index e4d6b60e46f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/order-of-operations.js +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hoursinday -description: User code calls happen in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - // GetPlainDateTimeFor - "call this.timeZone.getOffsetNanosecondsFor", - // GetInstantFor - "call this.timeZone.getPossibleInstantsFor", - // GetInstantFor - "call this.timeZone.getPossibleInstantsFor", -]; - -// Time zone with special requirements for testing DisambiguatePossibleInstants: -// midnight 1970-01-01 and 1970-01-02 are each in the middle of a fall-back -// transition of 1 h. Midnight 1970-01-03 and 1970-01-04 are each in the middle -// of a spring-forward transition of 1 h. -// The fall-back transitions occur 30 minutes after the day boundaries at local -// time: at epoch seconds 1800 and 91800. the spring-forward transitions occur -// 30 minutes before the day boundaries at local time: at epoch seconds 167400 -// and 257400. -// This is because calculating the hours in the instance's day requires calling -// getPossibleInstantsFor on both the preceding local midnight and the following -// local midnight. -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor(instant) { - const epochNs = instant.epochNanoseconds; - if (epochNs < 1800_000_000_000n) return 0; - if (epochNs < 91800_000_000_000n) return 3600_000_000_000; - if (epochNs < 167400_000_000_000n) return 7200_000_000_000; - if (epochNs < 257400_000_000_000n) return 3600_000_000_000; - return 0; - }, - getPossibleInstantsFor(dt) { - const cmp = Temporal.PlainDateTime.compare; - - const zero = new Temporal.TimeZone("+00:00").getInstantFor(dt); - const one = new Temporal.TimeZone("+01:00").getInstantFor(dt); - const two = new Temporal.TimeZone("+02:00").getInstantFor(dt); - - const fallBackLocalOne = new Temporal.PlainDateTime(1970, 1, 1, 0, 30); - const fallBackLocalTwo = new Temporal.PlainDateTime(1970, 1, 2, 0, 30); - const springForwardLocalOne = new Temporal.PlainDateTime(1970, 1, 2, 23, 30); - const springForwardLocalTwo = new Temporal.PlainDateTime(1970, 1, 3, 23, 30); - - if (cmp(dt, fallBackLocalOne) < 0) return [zero]; - if (cmp(dt, fallBackLocalOne.add({ hours: 1 })) < 0) return [zero, one]; - if (cmp(dt, fallBackLocalTwo) < 0) return [one]; - if (cmp(dt, fallBackLocalTwo.add({ hours: 1 })) < 0) return [one, two]; - if (cmp(dt, springForwardLocalOne) < 0) return [two]; - if (cmp(dt, springForwardLocalOne.add({ hours: 1 })) < 0) return []; - if (cmp(dt, springForwardLocalTwo) < 0) return [one]; - if (cmp(dt, springForwardLocalTwo.add({ hours: 1 })) < 0) return []; - return [zero]; - }, -}); - -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone, calendar); -const fallBackInstance = new Temporal.ZonedDateTime(43200_000_000_000n /* 1970-01-01T12:00 */, timeZone, calendar); -const springForwardInstance = new Temporal.ZonedDateTime(216000_000_000_000n /* 1970-01-03T12:00 */, timeZone, calendar); -actual.splice(0); // clear calls that happened in constructors - -instance.hoursInDay; -assert.compareArray(actual, expected, "order of operations with both midnights at normal wall-clock times"); -actual.splice(0); // clear - -fallBackInstance.hoursInDay; -assert.compareArray(actual, expected, "order of operations with both midnights at repeated wall-clock times"); -actual.splice(0); // clear - -springForwardInstance.hoursInDay; -assert.compareArray(actual, [ - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - // GetPlainDateTimeFor - "call this.timeZone.getOffsetNanosecondsFor", - // GetInstantFor - "call this.timeZone.getPossibleInstantsFor", - // DisambiguatePossibleInstants - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - // Note, no call to dateAdd as addition takes place in the ISO calendar - "call this.timeZone.getPossibleInstantsFor", - // GetInstantFor - "call this.timeZone.getPossibleInstantsFor", - // DisambiguatePossibleInstants - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - // Note, no call to dateAdd here either - "call this.timeZone.getPossibleInstantsFor", -], "order of operations with both midnights at skipped wall-clock times"); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/precision-exact-mathematical-values-2.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/precision-exact-mathematical-values-2.js deleted file mode 100644 index faec865e151..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/precision-exact-mathematical-values-2.js +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (C) 2024 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hoursinday -description: > - Hours in day is correctly rounded using precise mathematical values. -info: | - get Temporal.ZonedDateTime.prototype.hoursInDay - - ... - 14. Let diffNs be tomorrowInstant.[[Nanoseconds]] - todayInstant.[[Nanoseconds]]. - 15. Return 𝔽(diffNs / (3.6 × 10^12)). -features: [Temporal] ----*/ - -// Randomly generated test data. -const data = [ - { - hours: 816, - nanoseconds: 2049_187_497_660, - }, - { - hours: 7825, - nanoseconds: 1865_665_040_770, - }, - { - hours: 0, - nanoseconds: 1049_560_584_034, - }, - { - hours: 2055144, - nanoseconds: 2502_078_444_371, - }, - { - hours: 31, - nanoseconds: 1010_734_758_745, - }, - { - hours: 24, - nanoseconds: 2958_999_560_387, - }, - { - hours: 0, - nanoseconds: 342_058_521_588, - }, - { - hours: 17746, - nanoseconds: 3009_093_506_309, - }, - { - hours: 4, - nanoseconds: 892_480_914_569, - }, - { - hours: 3954, - nanoseconds: 571_647_777_618, - }, - { - hours: 27, - nanoseconds: 2322_199_502_640, - }, - { - hours: 258054064, - nanoseconds: 2782_411_891_222, - }, - { - hours: 1485, - nanoseconds: 2422_559_903_100, - }, - { - hours: 0, - nanoseconds: 1461_068_214_153, - }, - { - hours: 393, - nanoseconds: 1250_229_561_658, - }, - { - hours: 0, - nanoseconds: 91_035_820, - }, - { - hours: 0, - nanoseconds: 790_982_655, - }, - { - hours: 150, - nanoseconds: 608_531_524, - }, - { - hours: 5469, - nanoseconds: 889_204_952, - }, - { - hours: 7870, - nanoseconds: 680_042_770, - }, -]; - -const nsPerHour = 3600_000_000_000; - -const fractionDigits = Math.log10(nsPerHour) + Math.log10(100_000_000_000) - Math.log10(36); -assert.sameValue(fractionDigits, 22); - -for (let {hours, nanoseconds} of data) { - assert(nanoseconds < nsPerHour); - - // Compute enough fractional digits to approximate the exact result. Use BigInts - // to avoid floating point precision loss. Fill to the left with implicit zeros. - let fraction = ((BigInt(nanoseconds) * 100_000_000_000n) / 36n).toString().padStart(fractionDigits, "0"); - - // Get the Number approximation from the string representation. - let expected = Number(`${hours}.${fraction}`); - - let todayInstant = 0n; - let tomorrowInstant = BigInt(hours) * BigInt(nsPerHour) + BigInt(nanoseconds); - - let timeZone = new class extends Temporal.TimeZone { - #getPossibleInstantsFor = 0; - - getPossibleInstantsFor() { - if (++this.#getPossibleInstantsFor === 1) { - return [new Temporal.Instant(todayInstant)]; - } - assert.sameValue(this.#getPossibleInstantsFor, 2); - return [new Temporal.Instant(tomorrowInstant)]; - } - }("UTC"); - - let zdt = new Temporal.ZonedDateTime(0n, timeZone); - let actual = zdt.hoursInDay; - - assert.sameValue( - actual, - expected, - `hours=${hours}, nanoseconds=${nanoseconds}`, - ); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/precision-exact-mathematical-values.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/precision-exact-mathematical-values.js deleted file mode 100644 index adb6380cfff..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/precision-exact-mathematical-values.js +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hoursinday -description: > - Hours in day is correctly rounded using precise mathematical values. -info: | - get Temporal.ZonedDateTime.prototype.hoursInDay - - ... - 15. Let diffNs be tomorrowInstant.[[Nanoseconds]] - todayInstant.[[Nanoseconds]]. - 16. Return 𝔽(diffNs / (3.6 × 10^12)). -features: [Temporal] ----*/ - -const maxInstant = 86_40000_00000_00000_00000n; - -function nextUp(num) { - if (!Number.isFinite(num)) { - return num; - } - if (num === 0) { - return Number.MIN_VALUE; - } - - var f64 = new Float64Array([num]); - var u64 = new BigUint64Array(f64.buffer); - u64[0] += (num < 0 ? -1n : 1n); - return f64[0]; -} - -function nextDown(num) { - if (!Number.isFinite(num)) { - return num; - } - if (num === 0) { - return -Number.MIN_VALUE; - } - - var f64 = new Float64Array([num]); - var u64 = new BigUint64Array(f64.buffer); - u64[0] += (num < 0 ? 1n : -1n); - return f64[0]; -} - -function BigIntAbs(n) { - return n >= 0 ? n : -n; -} - -function test(todayInstant, tomorrowInstant, expected) { - let timeZone = new class extends Temporal.TimeZone { - #getPossibleInstantsFor = 0; - - getPossibleInstantsFor() { - if (++this.#getPossibleInstantsFor === 1) { - return [new Temporal.Instant(todayInstant)]; - } - assert.sameValue(this.#getPossibleInstantsFor, 2); - return [new Temporal.Instant(tomorrowInstant)]; - } - }("UTC"); - - let zdt = new Temporal.ZonedDateTime(0n, timeZone); - let zdt_hoursInDay = zdt.hoursInDay; - - assert.sameValue(zdt_hoursInDay, expected, "hoursInDay return value"); - - // Ensure the |expected| value is actually correctly rounded. - - const nsPerSec = 1000n * 1000n * 1000n; - const secPerHour = 60n * 60n; - const nsPerHour = secPerHour * nsPerSec; - - function toNanoseconds(hours) { - let wholeHours = BigInt(Math.trunc(hours)) * nsPerHour; - let fractionalHours = BigInt(Math.trunc(hours % 1 * Number(nsPerHour))); - return wholeHours + fractionalHours; - } - - let diff = tomorrowInstant - todayInstant; - let nanosInDay = toNanoseconds(zdt_hoursInDay); - - // The next number gives a less precise result. - let next = toNanoseconds(nextUp(zdt_hoursInDay)); - assert(BigIntAbs(diff - nanosInDay) <= BigIntAbs(diff - next)); - - // The previous number gives a less precise result. - let prev = toNanoseconds(nextDown(zdt_hoursInDay)); - assert(BigIntAbs(diff - nanosInDay) <= BigIntAbs(diff - prev)); - - // This computation can be inaccurate. - let inaccurate = Number(diff) / Number(nsPerHour); - - // Doing it component-wise can produce more accurate results. - let hours = Number(diff / nsPerSec) / Number(secPerHour); - let fractionalHours = Number(diff % nsPerSec) / Number(nsPerHour); - assert.sameValue(hours + fractionalHours, expected); - - // Ensure the result is more precise than the inaccurate result. - let inaccurateNanosInDay = toNanoseconds(inaccurate); - assert(BigIntAbs(diff - nanosInDay) <= BigIntAbs(diff - inaccurateNanosInDay)); -} - -test(-maxInstant, 0n, 2400000000); -test(-maxInstant, 1n, 2400000000); -test(-maxInstant, 10n, 2400000000); -test(-maxInstant, 100n, 2400000000); - -test(-maxInstant, 1_000n, 2400000000); -test(-maxInstant, 10_000n, 2400000000); -test(-maxInstant, 100_000n, 2400000000); - -test(-maxInstant, 1_000_000n, 2400000000.0000005); -test(-maxInstant, 10_000_000n, 2400000000.000003); -test(-maxInstant, 100_000_000n, 2400000000.0000277); - -test(-maxInstant, 1_000_000_000n, 2400000000.000278); -test(-maxInstant, 10_000_000_000n, 2400000000.0027776); -test(-maxInstant, 100_000_000_000n, 2400000000.0277777); - -test(-maxInstant, maxInstant, 4800000000); -test(-maxInstant, maxInstant - 10_000_000_000n, 4799999999.997222); -test(-maxInstant, maxInstant - 10_000_000_000n + 1n, 4799999999.997222); -test(-maxInstant, maxInstant - 10_000_000_000n - 1n, 4799999999.997222); - -test(maxInstant, -maxInstant, -4800000000); -test(maxInstant, -(maxInstant - 10_000_000_000n), -4799999999.997222); -test(maxInstant, -(maxInstant - 10_000_000_000n + 1n), -4799999999.997222); -test(maxInstant, -(maxInstant - 10_000_000_000n - 1n), -4799999999.997222); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 8b90e4062fa..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hoursinday -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.hoursInDay); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 13656da7015..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hoursinday -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.hoursInDay, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 331fc4f400f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hoursinday -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.hoursInDay); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 23c89aa7953..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hoursinday -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.hoursInDay); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index 49bcb52c99a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/hoursInDay/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.hoursinday -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-get-temporal.zoneddatetime.prototype.hoursinday steps 13–14: - 13. Let _todayInstant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _today_, *"compatible"*). - 14. Let _tomorrowInstant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _tomorrow_, *"compatible"*). - sec-temporal-builtintimezonegetinstantfor step 1: - 1. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-builtintimezonegetinstantfor step 14: - 14. Assert: _disambiguation_ is *"compatible"* or *"later"*. - sec-temporal-builtintimezonegetinstantfor step 16: - 16. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _later_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected1 = [ - "2001-09-09T00:00:00", - "2001-09-10T00:00:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - datetime.hoursInDay; -}, expected1); - -// Same, but test the other path where the time doesn't exist and -// GetPossibleInstantsFor is called again on a later time - -const expected2 = [ - "2030-01-01T00:00:00", - "2030-01-01T01:00:00", - "2030-01-02T00:00:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_893_457_800_000_000_000n, timeZone); - datetime.hoursInDay; -}, expected2); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 2cf3b7ed483..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.inleapyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const inLeapYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "inLeapYear"); -Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("inLeapYear should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.inLeapYear; - -Object.defineProperty(Temporal.Calendar.prototype, "inLeapYear", inLeapYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 7de82ddce37..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.inleapyear -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.inLeapYear; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/custom.js deleted file mode 100644 index 79f36f1fd8b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.inleapyear -description: Custom calendar tests for inLeapYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - inLeapYear(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "inLeapYear arguments"); - return true; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.inLeapYear; -assert.sameValue(result, true, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 67e5b10c697..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.inleapyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.inLeapYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 17b750eea70..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.inleapyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.inLeapYear, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 14c4d7f2232..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.inleapyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.inLeapYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index d7e66fcc70e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.inleapyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.inLeapYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/validate-calendar-value.js deleted file mode 100644 index b2bad194c95..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/validate-calendar-value.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.inleapyear -description: Validate result returned from calendar inLeapYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [0, TypeError], - [-0, TypeError], - [42, TypeError], - [7.1, TypeError], - [NaN, TypeError], - [Infinity, TypeError], - [-Infinity, TypeError], - ["", TypeError], - ["a string", TypeError], - ["0", TypeError], - [Symbol("foo"), TypeError], - [0n, TypeError], - [42n, TypeError], - [{}, TypeError], - [{valueOf() { return false; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - inLeapYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.inLeapYear, `${typeof result} ${String(result)} not converted to boolean`); -}); - -const preservedResults = [ - true, - false, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - inLeapYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.sameValue(instance.inLeapYear, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/balance-negative-time-units.js index 1e3dedd64a5..eaaf97372a8 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/balance-negative-time-units.js @@ -14,15 +14,14 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.microsecond step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(1001n, tz); +const datetime = new Temporal.ZonedDateTime(1001n, "-00:02"); -assert.sameValue(datetime.microsecond, 0); -assert.sameValue(datetime.nanosecond, 999); +assert.sameValue(datetime.minute, 58); +assert.sameValue(datetime.microsecond, 1); +assert.sameValue(datetime.nanosecond, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 2a4fce9dcde..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.microsecond -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.microsecond; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index e56d8609cad..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.microsecond -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.microsecond); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 728b3fc80d1..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.microsecond -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.microsecond, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 0ca3db64980..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.microsecond -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.microsecond); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index c9acf66eccc..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/microsecond/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.microsecond -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.microsecond); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/balance-negative-time-units.js index dc42bfd3c05..c3f560473ab 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/balance-negative-time-units.js @@ -16,16 +16,15 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.millisecond step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(1_000_001n, tz); +const datetime = new Temporal.ZonedDateTime(1_000_001n, "-00:02"); -assert.sameValue(datetime.millisecond, 0); -assert.sameValue(datetime.microsecond, 999); -assert.sameValue(datetime.nanosecond, 999); +assert.sameValue(datetime.minute, 58); +assert.sameValue(datetime.millisecond, 1); +assert.sameValue(datetime.microsecond, 0); +assert.sameValue(datetime.nanosecond, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 118840853d2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.millisecond -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.millisecond; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 0b15aad2c8f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.millisecond -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.millisecond); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index f95ef34d5ca..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.millisecond -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.millisecond, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index e5407893020..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.millisecond -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.millisecond); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 8b66d91b40e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/millisecond/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.millisecond -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.millisecond); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/minute/balance-negative-time-units.js index 89e91160bc6..8d60a1a0565 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/minute/balance-negative-time-units.js @@ -22,18 +22,16 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.minute step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(60_000_000_001n, tz); +const datetime = new Temporal.ZonedDateTime(60_000_000_001n, "-00:02"); -assert.sameValue(datetime.minute, 0); -assert.sameValue(datetime.second, 59); -assert.sameValue(datetime.millisecond, 999); -assert.sameValue(datetime.microsecond, 999); -assert.sameValue(datetime.nanosecond, 999); +assert.sameValue(datetime.minute, 59); +assert.sameValue(datetime.second, 0); +assert.sameValue(datetime.millisecond, 0); +assert.sameValue(datetime.microsecond, 0); +assert.sameValue(datetime.nanosecond, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/minute/builtin-timezone-no-observable-calls.js deleted file mode 100644 index b3caf18e341..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.minute -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.minute; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 924e3d95e5a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.minute -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.minute); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index b5031a93f6c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.minute -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.minute, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index ba95e3ae301..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.minute -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.minute); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index deec12ba684..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/minute/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.minute -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.minute); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/month/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/month/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 5a9c1bf7fff..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/month/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.month -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "month"); -Object.defineProperty(Temporal.Calendar.prototype, "month", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("month should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.month; - -Object.defineProperty(Temporal.Calendar.prototype, "month", monthOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/month/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/month/builtin-timezone-no-observable-calls.js deleted file mode 100644 index ed00a42a108..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/month/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.month -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.month; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/month/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/month/custom.js deleted file mode 100644 index 8cd1a8e6305..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/month/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.month -description: Custom calendar tests for month(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - month(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "month arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.month; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index aa924d43e09..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.month -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.month); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index e215e1dd347..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.month -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.month, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index f1bce82834a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.month -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.month); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 53619e29477..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/month/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.month -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.month); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/month/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/month/validate-calendar-value.js deleted file mode 100644 index de3bce9165d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/month/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.month -description: Validate result returned from calendar month() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - month() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.month, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 423e7893f2b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.monthcode -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthCodeOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthCode"); -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthCode should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.monthCode; - -Object.defineProperty(Temporal.Calendar.prototype, "monthCode", monthCodeOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 11e3f269a03..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.monthcode -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.monthCode; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/custom.js deleted file mode 100644 index baf8bba18eb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthcode -description: Custom calendar tests for monthCode(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthCode(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "monthCode arguments"); - return "M01"; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.monthCode; -assert.sameValue(result, "M01", "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index e1ac5491cc7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthcode -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.monthCode); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 6e5a5f5d116..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthcode -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.monthCode, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 2f37aeb3dce..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthcode -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.monthCode); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 44ba555abc0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthcode -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.monthCode); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/validate-calendar-value.js deleted file mode 100644 index 13f44844845..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/validate-calendar-value.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthcode -description: Validate result returned from calendar monthCode() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [Symbol("foo"), TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, TypeError], - [{toString() { return "M01"; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - monthCode() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.monthCode, `${typeof result} ${String(result)} not converted to string`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 36152494b80..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.monthsinyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const monthsInYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "monthsInYear"); -Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("monthsInYear should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.monthsInYear; - -Object.defineProperty(Temporal.Calendar.prototype, "monthsInYear", monthsInYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/builtin-timezone-no-observable-calls.js deleted file mode 100644 index ecced9bc89d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.monthsinyear -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.monthsInYear; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/custom.js deleted file mode 100644 index ef7df9da1b5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthsinyear -description: Custom calendar tests for monthsInYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - monthsInYear(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "monthsInYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.monthsInYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 2a39282f902..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthsinyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.monthsInYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index b8b4b5a0e66..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthsinyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.monthsInYear, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 72af675c49b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthsinyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.monthsInYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 775e3ff036a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthsinyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.monthsInYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/validate-calendar-value.js deleted file mode 100644 index 9d4abcff3e5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/validate-calendar-value.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.monthsinyear -description: Validate result returned from calendar monthsInYear() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - monthsInYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.monthsInYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/builtin-timezone-no-observable-calls.js deleted file mode 100644 index ad09cfacb41..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.nanosecond -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.nanosecond; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 2963371913d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.nanosecond -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.nanosecond); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 91ea2582f1e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.nanosecond -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.nanosecond, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index bc6173a8c62..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.nanosecond -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.nanosecond); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 5ef67518a73..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/nanosecond/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.nanosecond -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.nanosecond); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js index 6c104323ed3..16d2ddb3bf4 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/offset/basic.js @@ -8,8 +8,7 @@ features: [BigInt, Temporal] ---*/ function test(timeZoneIdentifier, expectedOffsetString, description) { - const timeZone = new Temporal.TimeZone(timeZoneIdentifier); - const datetime = new Temporal.ZonedDateTime(0n, timeZone); + const datetime = new Temporal.ZonedDateTime(0n, timeZoneIdentifier); assert.sameValue(datetime.offset, expectedOffsetString, description); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offset/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 64cd54cb41a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.offset -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.offset; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 04ffbc671f7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.offset -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.offset); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 62dcb082b88..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.offset -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.offset, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 10f9550711a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.offset -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.offset); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index ab0f673797e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offset/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.offset -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.offset); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/builtin-timezone-no-observable-calls.js deleted file mode 100644 index a8ed9865a89..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.offsetnanoseconds -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.offsetNanoseconds; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 3d9ae8909a4..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.offsetnanoseconds -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.offsetNanoseconds); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 9cfb8b26550..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.offsetnanoseconds -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.offsetNanoseconds, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 5b1a5a3a10d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.offsetnanoseconds -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.offsetNanoseconds); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index cbdc863445c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/offsetNanoseconds/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.offsetnanoseconds -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.offsetNanoseconds); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/builtin-calendar-no-observable-calls.js deleted file mode 100644 index a15f42abb33..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.round("day"); - -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 437977d9993..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.round("day"); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/div-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/div-zero.js deleted file mode 100644 index 52819eb64fb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/div-zero.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: RangeError thrown if the calculated day length is zero -features: [Temporal] ----*/ - -class TimeZone extends Temporal.TimeZone { - #calls = 0; - getPossibleInstantsFor(dateTime) { - if (++this.#calls === 2) { - return super.getPossibleInstantsFor(dateTime.withCalendar("iso8601").subtract({ days: 1 })); - } - return super.getPossibleInstantsFor(dateTime); - } -} - -const zdt = new Temporal.ZonedDateTime(0n, new TimeZone("UTC")); - -assert.throws(RangeError, () => zdt.round({ smallestUnit: "day" }), `zero day-length with smallestUnit 'day'`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index 71083e6456d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/getoffsetnanosecondsfor-maximum-forward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants can be at most 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - calls++; - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12 })]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.round({ smallestUnit: "hours" }); - -assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 3645752d2ec..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone, nonBuiltinISOCalendar); -instance.round({ smallestUnit: "day" }); - -assert.sameValue(timeZone.calls, 4, "getPossibleInstantsFor should have been called 4 times"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index 1e554269a56..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-maximum-backward-offset-shift.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - calls++; - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12 }), - utcInstant.add({ hours: 12 }) - ]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.round({ smallestUnit: "hours" }); - -assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index 9edd6c4fdd0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/getpossibleinstantsfor-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.round({ smallestUnit: "hours" }), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js index 9f6ddf12958..679327d750d 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/round/order-of-operations.js @@ -18,14 +18,6 @@ const expected = [ "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - // GetPlainDateTimeFor on receiver's instant - "call this.timeZone.getOffsetNanosecondsFor", - // InterpretISODateTimeOffset - "call this.timeZone.getPossibleInstantsFor", - "call this.timeZone.getOffsetNanosecondsFor", ]; const actual = []; @@ -41,75 +33,8 @@ const nextHourOptions = TemporalHelpers.propertyBagObserver(actual, { roundingIncrement: 1, }, "options"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime( - 988786472_987_654_321n, /* 2001-05-02T06:54:32.987654321Z */ - TemporalHelpers.timeZoneObserver(actual, "this.timeZone"), - calendar, -); - -const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(1800_000), -3600_000_000_000); -const fallBackTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor: fallBackTimeZone.getOffsetNanosecondsFor.bind(fallBackTimeZone), - getPossibleInstantsFor: fallBackTimeZone.getPossibleInstantsFor.bind(fallBackTimeZone), -}); -const fallBackInstance = new Temporal.ZonedDateTime(0n, fallBackTimeZoneObserver, calendar); -const beforeFallBackInstance = new Temporal.ZonedDateTime(-3599_000_000_000n, fallBackTimeZoneObserver, calendar); - -const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(-1800_000), 3600_000_000_000); -const springForwardTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor: springForwardTimeZone.getOffsetNanosecondsFor.bind(springForwardTimeZone), - getPossibleInstantsFor: springForwardTimeZone.getPossibleInstantsFor.bind(springForwardTimeZone), -}); -const springForwardInstance = new Temporal.ZonedDateTime(0n, springForwardTimeZoneObserver, calendar); -const beforeSpringForwardInstance = new Temporal.ZonedDateTime(-3599_000_000_000n, springForwardTimeZoneObserver, calendar); -// clear any observable operations that happen due to time zone or calendar -// calls in the constructors -actual.splice(0); +const instance = new Temporal.ZonedDateTime(988786472_987_654_321n, /* 2001-05-02T06:54:32.987654321Z */ "UTC"); instance.round(options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -fallBackInstance.round(options); -assert.compareArray(actual, expected, "order of operations with preceding midnight at repeated wall-clock time"); -actual.splice(0); // clear - -beforeFallBackInstance.round(nextHourOptions); -assert.compareArray(actual, expected, "order of operations with rounding result at repeated wall-clock time"); -actual.splice(0); // clear - -springForwardInstance.round(options); -assert.compareArray(actual, expected, "order of operations with preceding midnight at skipped wall-clock time"); -actual.splice(0); // clear - -const expectedSkippedResult = [ - "get options.roundingIncrement", - "get options.roundingIncrement.valueOf", - "call options.roundingIncrement.valueOf", - "get options.roundingMode", - "get options.roundingMode.toString", - "call options.roundingMode.toString", - "get options.smallestUnit", - "get options.smallestUnit.toString", - "call options.smallestUnit.toString", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - // GetPlainDateTimeFor on receiver's instant - "call this.timeZone.getOffsetNanosecondsFor", - // InterpretISODateTimeOffset - "call this.timeZone.getPossibleInstantsFor", - // DisambiguatePossibleInstants - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", -]; - -beforeSpringForwardInstance.round(nextHourOptions); -assert.compareArray( - actual, - expectedSkippedResult, - "order of operations with following midnight and rounding result at skipped wall-clock time" -); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/rounding-is-noop.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/rounding-is-noop.js index f0e7787490f..7eed8b48e17 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/rounding-is-noop.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/round/rounding-is-noop.js @@ -3,16 +3,11 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.round -description: > - No calendar or time zone methods are called under circumstances where rounding - is a no-op -includes: [temporalHelpers.js] +description: Circumstances where rounding is a no-op features: [Temporal] ---*/ -const calendar = TemporalHelpers.calendarThrowEverything(); -const timeZone = TemporalHelpers.timeZoneThrowEverything(); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const noopRoundingOperations = [ [{ smallestUnit: "nanoseconds" }, "smallestUnit ns"], @@ -22,14 +17,4 @@ for (const [options, descr] of noopRoundingOperations) { const result = instance.round(options); assert.notSameValue(result, instance, "rounding result should be a new object"); assert.sameValue(result.epochNanoseconds, instance.epochNanoseconds, "instant should be unchanged"); - assert.sameValue(result.getCalendar(), instance.getCalendar(), "calendar should be preserved"); - assert.sameValue(result.getTimeZone(), instance.getTimeZone(), "time zone should be preserved"); -} - -const notNoopRoundingOperations = [ - [{ smallestUnit: "microseconds" }, "round to 1 µs"], - [{ smallestUnit: "nanoseconds", roundingIncrement: 2 }, "round to 2 ns"], -]; -for (const [options, descr] of notNoopRoundingOperations) { - assert.throws(Test262Error, () => instance.round(options), `rounding should not be a no-op with ${descr}`); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-too-large.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-too-large.js deleted file mode 100644 index b305fb92725..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-too-large.js +++ /dev/null @@ -1,84 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: > - Round smallestUnit "day" with very large or very small divisor (dayLengthNs). -info: | - Temporal.ZonedDateTime.prototype.round ( roundTo ) - ... - 18. Let dayLengthNs be ℝ(endNs - startNs). - 19. If dayLengthNs ≤ 0, then - a. Throw a RangeError exception. - 20. Let roundResult be ! RoundISODateTime(temporalDateTime.[[ISOYear]], - temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], - temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], - temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], - temporalDateTime.[[ISONanosecond]], roundingIncrement, smallestUnit, roundingMode, - dayLengthNs). - ... - - RoundISODateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, - increment, unit, roundingMode [ , dayLength ] ) - ... - 4. Let roundedTime be ! RoundTime(hour, minute, second, millisecond, microsecond, nanosecond, - increment, unit, roundingMode, dayLength). - ... - - RoundTime ( hour, minute, second, millisecond, microsecond, nanosecond, increment, unit, - roundingMode [ , dayLengthNs ] ) - ... - 4. If unit is "day", then - ... - b. Let quantity be (((((hour × 60 + minute) × 60 + second) × 1000 + millisecond) × 1000 + - microsecond) × 1000 + nanosecond) / dayLengthNs. - ... -features: [Temporal] ----*/ - -class TimeZone extends Temporal.TimeZone { - #count = 0; - #nanoseconds; - - constructor(nanoseconds) { - super("UTC"); - this.#nanoseconds = nanoseconds; - } - getPossibleInstantsFor(dateTime) { - if (++this.#count === 2) { - return [new Temporal.Instant(this.#nanoseconds)]; - } - return super.getPossibleInstantsFor(dateTime); - } -} - -const maxInstant = 86_40000_00000_00000_00000n; -const minInstant = -86_40000_00000_00000_00000n; -const oneDay = 24n * 60n * 60n * 1000n * 1000n * 1000n - -// Divisor too large. -{ - let tz = new TimeZone(maxInstant); - let zoned = new Temporal.ZonedDateTime(0n, tz); - let result = zoned.round({ smallestUnit: "days" }); - assert(zoned.equals(result)); -} -{ - let tz = new TimeZone(maxInstant); - let zoned = new Temporal.ZonedDateTime(minInstant, tz); - let result = zoned.round({ smallestUnit: "days" }); - assert(zoned.equals(result)); -} - -// Divisor too small. -{ - let tz = new TimeZone(minInstant); - let zoned = new Temporal.ZonedDateTime(0n, tz); - assert.throws(RangeError, () => zoned.round({ smallestUnit: "days" })); -} -{ - let tz = new TimeZone(minInstant); - let zoned = new Temporal.ZonedDateTime(maxInstant - oneDay, tz); - assert.throws(RangeError, () => zoned.round({ smallestUnit: "days" })); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-zero-or-negative.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-zero-or-negative.js deleted file mode 100644 index 747c628530e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-daylength-zero-or-negative.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: > - Round smallestUnit "day" with zero or negative day length. -info: | - Temporal.ZonedDateTime.prototype.round ( roundTo ) - ... - 18. Let dayLengthNs be ℝ(endNs - startNs). - 19. If dayLengthNs ≤ 0, then - a. Throw a RangeError exception. - 20. Let roundResult be ! RoundISODateTime(temporalDateTime.[[ISOYear]], - temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], - temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], - temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], - temporalDateTime.[[ISONanosecond]], roundingIncrement, smallestUnit, roundingMode, - dayLengthNs). - ... - - RoundISODateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, - increment, unit, roundingMode [ , dayLength ] ) - ... - 4. Let roundedTime be ! RoundTime(hour, minute, second, millisecond, microsecond, nanosecond, - increment, unit, roundingMode, dayLength). - ... - - RoundTime ( hour, minute, second, millisecond, microsecond, nanosecond, increment, unit, - roundingMode [ , dayLengthNs ] ) - ... - 4. If unit is "day", then - ... - b. Let quantity be (((((hour × 60 + minute) × 60 + second) × 1000 + millisecond) × 1000 + - microsecond) × 1000 + nanosecond) / dayLengthNs. - ... -features: [Temporal] ----*/ - -class TimeZone extends Temporal.TimeZone { - #count = 0; - #nanoseconds; - - constructor(nanoseconds) { - super("UTC"); - this.#nanoseconds = nanoseconds; - } - getPossibleInstantsFor(dateTime) { - if (++this.#count === 2) { - return [new Temporal.Instant(this.#nanoseconds)]; - } - return super.getPossibleInstantsFor(dateTime); - } -} - -{ - let tz = new TimeZone(0n); - let zoned = new Temporal.ZonedDateTime(0n, tz); - assert.throws(RangeError, () => zoned.round({ smallestUnit: "days" })); -} - -{ - let tz = new TimeZone(-1n); - let zoned = new Temporal.ZonedDateTime(0n, tz); - assert.throws(RangeError, () => zoned.round({ smallestUnit: "days" })); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-rounding-modes.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-rounding-modes.js deleted file mode 100644 index a3f1a250770..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/smallest-unit-day-rounding-modes.js +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: > - Round smallestUnit "day" with various rounding modes. -info: | - Temporal.ZonedDateTime.prototype.round ( roundTo ) - ... - 18. Let dayLengthNs be ℝ(endNs - startNs). - ... - 20. Let roundResult be ! RoundISODateTime(temporalDateTime.[[ISOYear]], - temporalDateTime.[[ISOMonth]], temporalDateTime.[[ISODay]], temporalDateTime.[[ISOHour]], - temporalDateTime.[[ISOMinute]], temporalDateTime.[[ISOSecond]], - temporalDateTime.[[ISOMillisecond]], temporalDateTime.[[ISOMicrosecond]], - temporalDateTime.[[ISONanosecond]], roundingIncrement, smallestUnit, roundingMode, - dayLengthNs). - ... - - RoundISODateTime ( year, month, day, hour, minute, second, millisecond, microsecond, nanosecond, - increment, unit, roundingMode [ , dayLength ] ) - ... - 4. Let roundedTime be ! RoundTime(hour, minute, second, millisecond, microsecond, nanosecond, - increment, unit, roundingMode, dayLength). - ... - - RoundTime ( hour, minute, second, millisecond, microsecond, nanosecond, increment, unit, - roundingMode [ , dayLengthNs ] ) - ... - 4. If unit is "day", then - ... - b. Let quantity be (((((hour × 60 + minute) × 60 + second) × 1000 + millisecond) × 1000 + - microsecond) × 1000 + nanosecond) / dayLengthNs. - ... -features: [Temporal] ----*/ - -class TimeZone extends Temporal.TimeZone { - #count = 0; - #nanoseconds; - - constructor(todayEpochNanoseconds, tomorrowEpochNanoseconds) { - super("UTC"); - this.#nanoseconds = [todayEpochNanoseconds, tomorrowEpochNanoseconds]; - } - getPossibleInstantsFor(dateTime) { - const nanoseconds = this.#nanoseconds[this.#count++]; - if (nanoseconds === undefined) { - return super.getPossibleInstantsFor(dateTime); - } - return [new Temporal.Instant(nanoseconds)]; - } -} - -function test(epochNanoseconds, todayEpochNanoseconds, tomorrowEpochNanoseconds, testCases) { - for (let [roundingMode, expected] of Object.entries(testCases)) { - let timeZone = new TimeZone(todayEpochNanoseconds, tomorrowEpochNanoseconds); - let zoned = new Temporal.ZonedDateTime(epochNanoseconds, timeZone); - let result = zoned.round({ smallestUnit: "days", roundingMode }); - assert.sameValue(result.epochNanoseconds, expected); - } -} - -const oneDay = 24n * 60n * 60n * 1000n * 1000n * 1000n; - -test(3n, undefined, 10n, { - ceil: 10n, // end-of-day according to TimeZone protocol - floor: 0n, - trunc: 0n, - halfExpand: 0n, -}); - -test(-3n, undefined, 10n, { - ceil: 10n, // end-of-day according to TimeZone protocol - floor: -oneDay, - trunc: -oneDay, - halfExpand: 10n, // end-of-day according to TimeZone protocol -}); - -assert.throws(RangeError, () => { - test(-3n, 0n, 10n, { ceil: undefined }); -}, "instant is before TimeZone protocol's start-of-day"); - -assert.throws(RangeError, () => { - test(-3n, undefined, -10n, { ceil: undefined }); -}, "instant is after TimeZone protocol's end-of-day"); - -assert.throws(RangeError, () => { - test(0n, 0n, 0n, { ceil: undefined }); -}, "instant is within zero-duration day"); - -// Test values at int64 boundaries. -test(3n, undefined, /*INT64_MAX=*/ 9223372036854775807n, { - ceil: /*INT64_MAX=*/ 9223372036854775807n, // end-of-day according to TimeZone protocol - floor: 0n, - trunc: 0n, - halfExpand: 0n, -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index e2560dcfc2c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.round({ smallestUnit: "second" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 21ef8f1ca19..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.round({ smallestUnit: "second" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index ac187b8d6e7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.round({ smallestUnit: "second" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index e60edea3a5b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.round({ smallestUnit: "second" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index 4908568ae2c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/round/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.round -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.zoneddatetime.prototype.round steps 14, 16, and 20: - 14. Let _instantStart_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _dtStart_, *"compatible"*). - 16. Let _endNs_ be ? AddZonedDateTime(_startNs_, _timeZone_, _zonedDateTime_.[[Calendar]], 0, 0, 0, 1, 0, 0, 0, 0, 0, 0). - 20. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_roundResult_.[[Year]], [...], _roundResult_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, *"compatible"*, *"prefer"*). - sec-temporal-addzoneddatetime step 8: - 8. Let _intermediateInstant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _intermediateDateTime_, *"compatible"*). - sec-temporal-builtintimezonegetinstantfor step 1: - 1. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "2001-09-09T02:00:00", // called once on the rounding result -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - datetime.round({ smallestUnit: 'hour' }); -}, expected); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/second/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/second/balance-negative-time-units.js index 8422d20a5f2..933ffd49206 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/second/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/second/balance-negative-time-units.js @@ -18,17 +18,16 @@ info: | 3. Set _result_ to ? BalanceISODateTime(_result_.[[Year]], _result_.[[Month]], _result_.[[Day]], _result_.[[Hour]], _result_.[[Minute]], _result_.[[Second]], _result_.[[Millisecond]], _result_.[[Microsecond]], _result_.[[Nanosecond]] + _offsetNanoseconds_). sec-get-temporal.zoneddatetime.prototype.second step 6: 6. Let _temporalDateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _calendar_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(1_000_000_001n, tz); +const datetime = new Temporal.ZonedDateTime(1_000_000_001n, "-00:02"); -assert.sameValue(datetime.second, 0); -assert.sameValue(datetime.millisecond, 999); -assert.sameValue(datetime.microsecond, 999); -assert.sameValue(datetime.nanosecond, 999); +assert.sameValue(datetime.minute, 58); +assert.sameValue(datetime.second, 1); +assert.sameValue(datetime.millisecond, 0); +assert.sameValue(datetime.microsecond, 0); +assert.sameValue(datetime.nanosecond, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/second/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/second/builtin-timezone-no-observable-calls.js deleted file mode 100644 index fcae38ebceb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/second/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.second -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.second; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 64583eff4ce..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.second -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.second); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 131f289c8f8..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.second -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.second, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index d769f456ab5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.second -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.second); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 0a183139f35..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/second/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.second -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.second); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index ced06ddb0f1..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const timeZone = "UTC"; -const instance = new Temporal.ZonedDateTime(0n, timeZone); -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, timeZone, calendar: "iso8601" }; -instance.since(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-ambiguous-wall-clock-time.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-ambiguous-wall-clock-time.js deleted file mode 100644 index c94e7fbdb94..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-ambiguous-wall-clock-time.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Correct time zone calls are made when converting a ZonedDateTime-like property - bag denoting an ambiguous wall-clock time -includes: [temporalHelpers.js, compareArray.js] -features: [Temporal] ----*/ - -const actual = []; - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const dstTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone), - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone), -}); -const calendar = TemporalHelpers.calendarObserver(actual, "calendar"); - -const timeZone = "UTC"; -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -let arg = { year: 2000, month: 4, day: 2, hour: 2, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.since(arg); - -const expected = [ - // GetTemporalCalendarSlotValueWithISODefault - "has calendar.dateAdd", - "has calendar.dateFromFields", - "has calendar.dateUntil", - "has calendar.day", - "has calendar.dayOfWeek", - "has calendar.dayOfYear", - "has calendar.daysInMonth", - "has calendar.daysInWeek", - "has calendar.daysInYear", - "has calendar.fields", - "has calendar.id", - "has calendar.inLeapYear", - "has calendar.mergeFields", - "has calendar.month", - "has calendar.monthCode", - "has calendar.monthDayFromFields", - "has calendar.monthsInYear", - "has calendar.weekOfYear", - "has calendar.year", - "has calendar.yearMonthFromFields", - "has calendar.yearOfWeek", - // lookup in ToTemporalZonedDateTime - "get calendar.dateFromFields", - "get calendar.fields", - // CalendarFields - "call calendar.fields", - // ToTemporalTimeZoneSlotValue - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - // InterpretTemporalDateTimeFields - "call calendar.dateFromFields", - // lookup in ToTemporalZonedDateTime - "get timeZone.getOffsetNanosecondsFor", - "get timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", -]; - -const expectedSpringForward = expected.concat([ - // DisambiguatePossibleInstants - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getPossibleInstantsFor", -]); -assert.compareArray( - actual.slice(0, expectedSpringForward.length), // ignore operations after ToTemporalZonedDateTime - expectedSpringForward, - "order of operations converting property bag at skipped wall-clock time" -); -actual.splice(0); // clear - -arg = { year: 2000, month: 10, day: 29, hour: 1, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.since(arg); - -assert.compareArray( - actual.slice(0, expected.length), // ignore operations after ToTemporalZonedDateTime - expected, - "order of operations converting property bag at repeated wall-clock time" -); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-case-insensitive.js index bc37379656f..c9ff89c434a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-case-insensitive.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-case-insensitive.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar: "IsO8601" }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-iso-string.js index 8d6e9b9e09e..57cd4b962e4 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-iso-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-iso-string.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); for (const calendar of [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-leap-second.js index c2c39d97de7..3b428fc2ac9 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-leap-second.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const calendar = "2016-12-31T23:59:60+00:00[UTC]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-number.js index 7b318fbf4d3..49ce7c5ad97 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-number.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-number.js @@ -7,7 +7,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const numbers = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-string.js index ba81bd841da..bf1138e0b1f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-string.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const calendar = "iso8601"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-wrong-type.js index 7b9aa6dccf6..6ba45bec1f5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js index 5c294a53737..d6ea39cb347 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-calendar-year-zero.js @@ -14,7 +14,7 @@ const invalidStrings = [ "-000000-10-31T17:45+01:00", "-000000-10-31T17:45+00:00[UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((str) => { const arg = { year: 1976, month: 11, day: 18, calendar: str }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index a3253b4ef09..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); -const arg = { year: 2000, month: 5, day: 2, timeZone, calendar: nonBuiltinISOCalendar }; - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.since(arg); - -assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-invalid-offset-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-invalid-offset-string.js index 8aa2efceb5c..5ac866e413a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-invalid-offset-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-invalid-offset-string.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset is in the w features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const badOffsets = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-offset-not-agreeing-with-timezone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-offset-not-agreeing-with-timezone.js index e7c2b3fe331..97b1b07cef0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-offset-not-agreeing-with-timezone.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-offset-not-agreeing-with-timezone.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset does not ag features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+01:00"); +const timeZone = "+01:00"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const properties = { year: 2021, month: 10, day: 28, offset: "-07:00", timeZone }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-backward-offset-shift.js deleted file mode 100644 index 25b2533adb3..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.since(arg), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-forward-offset-shift.js deleted file mode 100644 index 1ccc59c6c9b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.since(arg), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 2f5d14bc1cb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => datetime.since(properties, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index b51c92a5f2a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - timeZone.getPossibleInstantsFor = function () { - return []; - }; - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.since(properties, { largestUnit: "days" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 3277c5ecb76..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => datetime.since(properties, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 6420cbceefa..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(TypeError, () => datetime.since(properties, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-id-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-id-wrong-type.js deleted file mode 100644 index 490702bc761..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-id-wrong-type.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: TypeError thrown if time zone reports an id that is not a String -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -[ - undefined, - null, - true, - -1000, - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongId) => { - const timeZone = new CustomTimeZone(wrongId); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - assert.throws(TypeError, () => datetime.since(properties, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-year-zero.js index 27e043ae0e2..4f2dce8ab46 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string-year-zero.js @@ -11,7 +11,7 @@ const invalidStrings = [ "-000000-10-31T17:45Z", "-000000-10-31T17:45+00:00[UTC]", ]; -const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); invalidStrings.forEach((timeZone) => { assert.throws( RangeError, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string.js index bc33b46d393..468686541c0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.since description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance1 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance1 = new Temporal.ZonedDateTime(0n, "UTC"); assert(instance1.since({ year: 1970, month: 1, day: 1, timeZone: "UTC" }).blank, "Time zone created from string 'UTC'"); -const instance2 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("-01:30")); +const instance2 = new Temporal.ZonedDateTime(0n, "-01:30"); assert(instance2.since({ year: 1969, month: 12, day: 31, hour: 22, minute: 30, timeZone: "-01:30" }).blank, "Time zone created from string '-01:30'"); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-wrong-type.js index 5278a935d71..e6f013fbd3b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-propertybag-timezone-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const primitiveTests = [ [null, "null"], @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js index c1705471d40..444b8c473a6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation-invalid-key.js @@ -12,7 +12,7 @@ const invalidStrings = [ ["1970-01-01T00:00[UTC][u-CA=iso8601]", "invalid partially-capitalized key"], ["1970-01-01T00:00[UTC][FOO=bar]", "invalid capitalized unrecognized key"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach(([arg, descr]) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation.js index 575382d8ed6..e86d3f5b5ee 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-calendar-annotation.js @@ -14,7 +14,7 @@ const tests = [ ["1970-01-01T00:00[UTC][u-ca=iso8601][u-ca=discord]", "second annotation ignored"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-critical-unknown-annotation.js index b7b184ddd0c..32d1c29a592 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-critical-unknown-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-critical-unknown-annotation.js @@ -13,7 +13,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][u-ca=iso8601][!foo=bar]", "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-date-with-utc-offset.js index 6ceb051eb3a..f1dfa246d07 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-date-with-utc-offset.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-date-with-utc-offset.js @@ -8,7 +8,7 @@ features: [Temporal] includes: [temporalHelpers.js] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const validStrings = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-calendar.js index 4e6737e1832..4154f1e92d1 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-calendar.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-calendar.js @@ -14,7 +14,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][!u-ca=iso8601][u-ca=iso8601]", "1970-01-01T00:00[UTC][u-ca=iso8601][foo=bar][!u-ca=iso8601]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-time-zone.js index c5c328d3c65..c98ac91db83 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-time-zone.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-multiple-time-zone.js @@ -14,7 +14,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", "1970-01-01T00:00[UTC][foo=bar][UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-separators.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-separators.js index 1e5915d4ecb..81560e5ae67 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-separators.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-separators.js @@ -14,7 +14,7 @@ const tests = [ ["1970-01-01 00:00+00:00[UTC]", "space between date and time"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-zone-annotation.js index cdf5de9ff5a..ac780489ca3 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-zone-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-time-zone-annotation.js @@ -23,7 +23,7 @@ const tests = [ ["1970-01-01T00:00+00:00[!+00:00]", "numeric, with offset and !"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-unknown-annotation.js index 8e3b643be9c..b42a0960d96 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-unknown-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-string-unknown-annotation.js @@ -15,7 +15,7 @@ const tests = [ ["1970-01-01T00:00[UTC][foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-wrong-type.js index 65793e8dec9..253d4a1a119 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const primitiveTests = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/balance-negative-time-units.js index 801b00cd19e..bface19af84 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/balance-negative-time-units.js @@ -30,7 +30,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const datetime = new Temporal.ZonedDateTime(830998861_001_001_001n, timeZone); const options = { largestUnit: "days" }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/branding.js index 5695e13f2ec..4c1efdf444d 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/branding.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/branding.js @@ -11,7 +11,7 @@ const since = Temporal.ZonedDateTime.prototype.since; assert.sameValue(typeof since, "function"); -const args = [new Temporal.ZonedDateTime(123456n, new Temporal.TimeZone("UTC"))]; +const args = [new Temporal.ZonedDateTime(123456n, "UTC")]; assert.throws(TypeError, () => since.apply(undefined, args), "undefined"); assert.throws(TypeError, () => since.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 054dadd5416..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.since(new Temporal.ZonedDateTime(0n, "UTC")); - -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 3b7e4ac0f08..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.since(new Temporal.ZonedDateTime(0n, "UTC")); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js deleted file mode 100644 index 0ad19e91ea7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateadd-called-with-options-undefined.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - BuiltinTimeZoneGetInstantFor calls Calendar.dateAdd with undefined as the - options value -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddUndefinedOptions(); -const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9); -const earlier = new Temporal.ZonedDateTime(0n, timeZone, calendar); -const later = new Temporal.ZonedDateTime(1_213_200_000_000_000n, timeZone, calendar); - -// Difference with rounding, with smallestUnit a calendar unit. -// The calls come from these paths: -// ZonedDateTime.since() -> DifferenceZonedDateTimeWithRounding -> RoundRelativeDuration -> NudgeToCalendarUnit -> -// AddDateTime -> calendar.dateAdd() - -later.since(earlier, { smallestUnit: "weeks" }); -assert.sameValue(calendar.dateAddCallCount, 2, "rounding difference with calendar smallestUnit"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index a6ad8e4d030..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); -const arg = { year: 2000, month: 5, day: 2, timeZone, calendar }; -instance.since(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-copy-of-options.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-copy-of-options.js deleted file mode 100644 index 46e69aef297..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-copy-of-options.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: The dateUntil() method on the calendar is called with a copy of the options bag -features: [Temporal] ----*/ - -const originalOptions = { - largestUnit: "year", - shouldBeCopied: {}, -}; -let called = false; - -class Calendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateUntil(d1, d2, options) { - called = true; - assert.notSameValue(options, originalOptions, "options bag should be a copy"); - assert.sameValue(options.shouldBeCopied, originalOptions.shouldBeCopied, "options bag should be a shallow copy"); - return new Temporal.Duration(-1); - } -} -const calendar = new Calendar(); -const earlier = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -// exactly one year later; avoids NanosecondsToDays path -const later = new Temporal.ZonedDateTime(1_031_536_000_000_000_000n, "UTC", calendar); -later.since(earlier, originalOptions); -assert(called, "calendar.dateUntil must be called"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js deleted file mode 100644 index aca6c7bf7a1..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Calendar.dateUntil method is called with a null-prototype object as the - options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.ZonedDateTime(0n, "UTC", calendar); -const argument = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -instance.since(argument, { largestUnit: "year" }); -assert.sameValue(calendar.dateUntilCallCount, 1, "dateUntil should have been called on the calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index 812b1f2b67f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - The options object passed to calendar.dateUntil has a largestUnit property - with its value in the singular form -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); - const later = new Temporal.ZonedDateTime(1_086_403_661_988_655_322n, "UTC", calendar); - later.since(earlier, { largestUnit }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); - -// Additionally check the path that goes through AdjustRoundedDurationDays - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.ZonedDateTime(-31536000_000_000_000n /* = -365 days */, "UTC", calendar); - const later = new Temporal.ZonedDateTime(86_399_999_999_999n, "UTC", calendar); - later.since(earlier, { largestUnit, roundingIncrement: 2, roundingMode: 'ceil' }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); - -// Also check the path that goes through RoundDuration when smallestUnit is -// given - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, smallestUnit) => { - const earlier = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); - const later = new Temporal.ZonedDateTime(1_086_403_661_988_655_322n, "UTC", calendar); - later.since(earlier, { smallestUnit }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week", "week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-fields-iterable.js deleted file mode 100644 index 66267a5cca2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.zoneddatetime.prototype.since step 3: - 3. Set _other_ to ? ToTemporalZonedDateTime(_other_). - sec-temporal-totemporalzoneddatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -datetime.since({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-temporal-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-temporal-object.js index 8db1101ec36..ca2d6816ad7 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-temporal-object.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", temporalObject); + const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); datetime.since({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/constructor-in-calendar-fields.js deleted file mode 100644 index b91c1f73867..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/constructor-in-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/date-and-time-durations-opposite-signs.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/date-and-time-durations-opposite-signs.js deleted file mode 100644 index 5db16682f15..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/date-and-time-durations-opposite-signs.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Rounding calculation in difference method can result in duration date and - time components with opposite signs -info: | - DifferenceTemporalZonedDateTime ( operation, zonedDateTime, other, options ) - 17. If _roundingGranularityIsNoop_ is *false*, then - ... - e. Let _adjustResult_ be ? AdjustRoundedDurationDays(_roundResult_.[[Years]], _roundResult_.[[Months]], - _roundResult_.[[Weeks]], _days_, _daysResult_.[[NormalizedTime]], _settings_.[[RoundingIncrement]], - _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]], _zonedDateTime_, _calendarRec_, _timeZoneRec_, - _precalculatedPlainDateTime_). - f. Let _balanceResult_ be ? BalanceDateDurationRelative(_adjustResult_.[[Years]], _adjustResult_.[[Months]], - _adjustResult_.[[Weeks]], _adjustResult_.[[Days]], _settings_.[[LargestUnit]], _settings_.[[SmallestUnit]], - _plainRelativeTo_, _calendarRec_). - g. Set _result_ to ? CombineDateAndNormalizedTimeDuration(_balanceResult_, _adjustResult_.[[NormalizedTime]]). -features: [Temporal] ----*/ - -// Based on a test case by André Bargull - -const calendar = new class extends Temporal.Calendar { - dateUntil(one, two, options) { - return super.dateUntil(one, two, options).negated(); - } -}("iso8601"); - -const oneDay = 86400_000_000_000; -const start = new Temporal.ZonedDateTime(0n, "UTC", calendar); -const end = new Temporal.ZonedDateTime(BigInt(500.5 * oneDay), "UTC", calendar); - -assert.throws(RangeError, () => end.since(start, { - largestUnit: "years", - smallestUnit: "hours", -})); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/differencezoneddatetime-inconsistent-custom-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/differencezoneddatetime-inconsistent-custom-calendar.js deleted file mode 100644 index e15f9c360ad..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/differencezoneddatetime-inconsistent-custom-calendar.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Throws a RangeError when custom calendar method returns inconsistent result -info: | - DifferenceZonedDateTime ( ... ) - 8. Repeat 3 times: - ... - g. If _sign_ = 0, or _timeSign_ = 0, or _sign_ = _timeSign_, then - ... - viii. Return ? CreateNormalizedDurationRecord(_dateDifference_.[[Years]], - _dateDifference_.[[Months]], _dateDifference_.[[Weeks]], - _dateDifference_.[[Days]], _norm_). - h. Set _dayCorrection_ to _dayCorrection_ + 1. - 9. NOTE: This step is only reached when custom calendar or time zone methods - return inconsistent values. - 10. Throw a *RangeError* exception. -features: [Temporal] ----*/ - -// Based partly on a test case by André Bargull - -const fiftyDays12Hours = 50n * 86400_000_000_000n + 12n * 3600_000_000_000n; - -{ - const tz = new (class extends Temporal.TimeZone { - getPossibleInstantsFor(dateTime) { - return super.getPossibleInstantsFor(dateTime.subtract({ days: 3 })); - } - })("UTC"); - - const zdt1 = new Temporal.ZonedDateTime(0n, tz); - const zdt2 = new Temporal.ZonedDateTime(fiftyDays12Hours, tz); - - assert.throws(RangeError, () => zdt2.since(zdt1, { largestUnit: "weeks" }), - "Calendar calculation where more than 2 days correction is needed should cause RangeError"); -} - -{ - const cal = new (class extends Temporal.Calendar { - dateUntil(one, two, options) { - return super.dateUntil(one, two, options).negated(); - } - })("iso8601"); - - const zdt1 = new Temporal.ZonedDateTime(0n, "UTC", cal); - const zdt2 = new Temporal.ZonedDateTime(fiftyDays12Hours, "UTC", cal); - - assert.throws(RangeError, () => zdt2.since(zdt1, { largestUnit: "weeks" }), - "Calendar calculation causing mixed-sign values should cause RangeError"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-balancing-result.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-balancing-result.js deleted file mode 100644 index 1cca27eb9ee..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-balancing-result.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Balancing the resulting duration takes the time zone's UTC offset shifts - into account -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -// Based on a test case by Adam Shaw -{ - const start = new Temporal.ZonedDateTime( - 941184000_000_000_000n /* = 1999-10-29T08Z */, - timeZone); /* = 1999-10-29T00-08 in local time */ - const end = new Temporal.ZonedDateTime( - 972889200_000_000_000n /* = 2000-10-30T07Z */, - timeZone); /* = 2000-10-29T23-08 in local time */ - - const duration = start.since(end, { largestUnit: "years" }); - TemporalHelpers.assertDuration(duration, -1, 0, 0, 0, -24, 0, 0, 0, 0, 0, - "24 hours does not balance to 1 day in 25-hour day"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-month-day-boundary.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-month-day-boundary.js deleted file mode 100644 index ce9aad31d36..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-month-day-boundary.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Difference with the endpoint being the end of a skipped hour, chooses the - smaller of two possible durations -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// Based on a test case by Adam Shaw - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -const d1 = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00-07:00 */, timeZone); -const d2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T03:00-07:00 */, timeZone); -// NOTE: nonexistent hour just before d2 - -const result = d1.since(d2, { largestUnit: "months" }); - -TemporalHelpers.assertDuration( - result, 0, 0, 0, 29, 23, 0, 0, 0, 0, 0, - "Result should not balance up to months, but pick the smaller of two possible durations" -); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-rounding-result.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-rounding-result.js deleted file mode 100644 index b47be48140f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/dst-rounding-result.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - Rounding the resulting duration takes the time zone's UTC offset shifts - into account -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// Based on a test case by Adam Shaw - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -{ - // Month-only part of duration lands on skipped DST hour, should not cause - // disambiguation - const start = new Temporal.ZonedDateTime( - 950868000_000_000_000n /* = 2000-02-18T10Z */, - timeZone); /* = 2000-02-18T02-08 in local time */ - const end = new Temporal.ZonedDateTime( - 954709200_000_000_000n /* = 2000-04-02T21Z */, - timeZone); /* = 2000-04-02T14-07 in local time */ - - const duration = start.since(end, { largestUnit: "months" }); - TemporalHelpers.assertDuration(duration, 0, -1, 0, -15, -11, 0, 0, 0, 0, 0, - "1-month rounding window is shortened by DST"); -} - - -{ - // Month-only part of duration lands on skipped DST hour, should not cause - // disambiguation - const start = new Temporal.ZonedDateTime( - 951991200_000_000_000n /* = 2000-03-02T10Z */, - timeZone); /* = 2000-03-02T02-08 in local time */ - const end = new Temporal.ZonedDateTime( - 956005200_000_000_000n /* = 2000-04-17T21Z */, - timeZone); /* = 2000-04-17T14-07 in local time */ - - const duration = start.since(end, { largestUnit: "months" }); - TemporalHelpers.assertDuration(duration, 0, -1, 0, -15, -12, 0, 0, 0, 0, 0, - "1-month rounding window is not shortened by DST"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/duplicate-calendar-fields.js deleted file mode 100644 index bdd842fa3a3..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/duplicate-calendar-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const timeZone = 'Europe/Paris' - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; - const instance = new Temporal.ZonedDateTime(0n, timeZone); - - assert.throws(RangeError, () => instance.since(arg)); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/find-intermediate-instant.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/find-intermediate-instant.js deleted file mode 100644 index 34f564dd0fc..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/find-intermediate-instant.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Up to 3 intermediate instants may be tried when calculating ZonedDateTime - difference -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Temporal] ----*/ - -const calls = []; - -const springFallZone = TemporalHelpers.springForwardFallBackTimeZone(); -TemporalHelpers.observeMethod(calls, springFallZone, "getPossibleInstantsFor"); - -const dateLineZone = TemporalHelpers.crossDateLineTimeZone(); -TemporalHelpers.observeMethod(calls, dateLineZone, "getPossibleInstantsFor"); - -const zdt2 = new Temporal.ZonedDateTime(946722600_000_000_000n /* = 2000-01-01T02:30 local */, springFallZone); - -// Future -> past, without wall-clock overshoot -// Expects valid intermediate Instant WITHOUT day correction (computed once) -{ - const zdt1 = new Temporal.ZonedDateTime(949442400_000_000_000n /* = 2000-02-01T14:00 local */, springFallZone); - const result = zdt1.since(zdt2, { largestUnit: "years" }); - TemporalHelpers.assertDuration(result, 0, 1, 0, 0, 11, 30, 0, 0, 0, 0, "no wall-clock overshoot, no DST"); - assert.compareArray(calls, [ - "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime - ], "one intermediate should be tried"); -} - -calls.splice(0); // clear - -// Future -> past, WITH wall-clock overshoot -// Expects valid intermediate Instant with guaranteed 1-DAY correction (computed once) -{ - const zdt1 = new Temporal.ZonedDateTime(949395600_000_000_000n /* = 2000-02-01T01:00 local */, springFallZone); - const result = zdt1.since(zdt2, { largestUnit: "years" }); - TemporalHelpers.assertDuration(result, 0, 0, 0, 30, 22, 30, 0, 0, 0, 0, "wall-clock overshoot, no DST"); - assert.compareArray(calls, [ - "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime - ], "one intermediate should be tried"); -} - -calls.splice(0); // clear - -// Future -> past, WITH wall-clock overshoot -// Expects valid intermediate Instant with guaranteed 1-DAY correction (computed once) -// Intermediate Instant falls within spring DST gap and gets pushed forward, -// but since moving from future -> past, not possible to exacerbate overflow, -// so no other day corrections. -{ - const end = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00 local */, springFallZone); - const start = new Temporal.ZonedDateTime(954671400_000_000_000n /* = 2000-04-02T03:30-07:00 local */, springFallZone); - const result = end.since(start, { largestUnit: "years" }); - TemporalHelpers.assertDuration(result, 0, 0, 0, 29, 22, 30, 0, 0, 0, 0, "wall-clock overshoot, inconsiquential DST"); - assert.compareArray(calls, [ - "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime - ], "one intermediate should be tried"); -} - -calls.splice(0); // clear - -// Past -> future, WITH wall-clock overshoot -// Tries intermediate Instant with 1-DAY correction (first compute) -// Then, ANOTHER day correction because updated intermediate Instant falls within dateline DST gap, -// pushing it forward, causing wall-clock overshoot again -// (Not possible when going backwards) -// (This test is just the same as the corresponding one in until(), but negative) -{ - const start = new Temporal.ZonedDateTime(1325102400_000_000_000n /* = 2011-12-28T10:00 local */, dateLineZone); - const end = new Temporal.ZonedDateTime(1325257200_000_000_000n /* = 2011-12-31T05:00 local */, dateLineZone); - const result = start.since(end, { largestUnit: "days" }); - TemporalHelpers.assertDuration(result, 0, 0, 0, -1, -19, 0, 0, 0, 0, 0, "wall-clock overshoot, consiquential DST"); - assert.compareArray(calls, [ - "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime - "call getPossibleInstantsFor", // second intermediate in DifferenceZonedDateTime - "call getPossibleInstantsFor", // DisambiguatePossibleInstants on second intermediate - ], "two intermediates should be tried, with disambiguation"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/leap-second.js index e3611500bb8..cc1e4ec3b7b 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/leap-second.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(1_483_228_799_000_000_000n, timeZone); let arg = "2016-12-31T23:59:60+00:00[UTC]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js index e9552231bca..9c83ff6f07a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/order-of-operations.js @@ -11,30 +11,6 @@ features: [Temporal] const expected = [ // ToTemporalZonedDateTime "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.dateFromFields", - "get other.calendar.fields", - "call other.calendar.fields", "get other.day", "get other.day.valueOf", "call other.day.valueOf", @@ -69,56 +45,23 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", - "has other.timeZone.getOffsetNanosecondsFor", - "has other.timeZone.getPossibleInstantsFor", - "has other.timeZone.id", - "call other.calendar.dateFromFields", - "get other.timeZone.getOffsetNanosecondsFor", - "get other.timeZone.getPossibleInstantsFor", - "call other.timeZone.getPossibleInstantsFor", - "call other.timeZone.getOffsetNanosecondsFor", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; const actual = []; -const ownTimeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, ownTimeZone, ownCalendar); - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const ownDstTimeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); -const otherDstTimeZone = TemporalHelpers.timeZoneObserver(actual, "other.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); -/* 2000-10-29T01:30-07:00, in the middle of the first repeated hour: */ -const fallBackInstance = new Temporal.ZonedDateTime(972808200_000_000_000n, ownDstTimeZone, ownCalendar); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2004, @@ -132,14 +75,12 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { microsecond: 500, nanosecond: 750, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"), -}, "other"); + calendar: "iso8601", + timeZone: "UTC", +}, "other", ["calendar", "timeZone"]); function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { - // order is significant, due to iterating through properties in order to - // copy them to an internal null-prototype object: roundingIncrement, roundingMode, largestUnit, @@ -148,220 +89,7 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au }, "options"); } -// clear any observable things that happened while constructing the objects -actual.splice(0); - // basic order of observable operations, without rounding: instance.since(otherDateTimePropertyBag, createOptionsObserver()); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -// short-circuit for identical objects will still test TimeZoneEquals if -// largestUnit is a calendar unit: -const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2001, - month: 9, - monthCode: "M09", - day: 9, - hour: 1, - minute: 46, - second: 40, - millisecond: 0, - microsecond: 0, - nanosecond: 0, - offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"), -}, "other"); - -instance.since(identicalPropertyBag, createOptionsObserver({ largestUnit: "years" })); -assert.compareArray(actual, expected.concat([ - "get this.timeZone.id", - "get other.timeZone.id", -]), "order of operations with identical dates and largestUnit a calendar unit"); -actual.splice(0); // clear - -// two ZonedDateTimes that denote the same wall-clock time in the time zone can -// avoid calling some calendar methods: -const fallBackPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 10, - monthCode: "M10", - day: 29, - hour: 1, - minute: 30, - second: 0, - millisecond: 0, - microsecond: 0, - nanosecond: 0, - offset: "-08:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: otherDstTimeZone, -}, "other"); -fallBackInstance.since(fallBackPropertyBag, createOptionsObserver({ largestUnit: "days" })); -assert.compareArray(actual, [ - // ToTemporalZonedDateTime - "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.dateFromFields", - "get other.calendar.fields", - "call other.calendar.fields", - "get other.day", - "get other.day.valueOf", - "call other.day.valueOf", - "get other.hour", - "get other.hour.valueOf", - "call other.hour.valueOf", - "get other.microsecond", - "get other.microsecond.valueOf", - "call other.microsecond.valueOf", - "get other.millisecond", - "get other.millisecond.valueOf", - "call other.millisecond.valueOf", - "get other.minute", - "get other.minute.valueOf", - "call other.minute.valueOf", - "get other.month", - "get other.month.valueOf", - "call other.month.valueOf", - "get other.monthCode", - "get other.monthCode.toString", - "call other.monthCode.toString", - "get other.nanosecond", - "get other.nanosecond.valueOf", - "call other.nanosecond.valueOf", - "get other.offset", - "get other.offset.toString", - "call other.offset.toString", - "get other.second", - "get other.second.valueOf", - "call other.second.valueOf", - "get other.timeZone", - "get other.year", - "get other.year.valueOf", - "call other.year.valueOf", - "has other.timeZone.getOffsetNanosecondsFor", - "has other.timeZone.getPossibleInstantsFor", - "has other.timeZone.id", - "call other.calendar.dateFromFields", - "get other.timeZone.getOffsetNanosecondsFor", - "get other.timeZone.getPossibleInstantsFor", - "call other.timeZone.getPossibleInstantsFor", - "call other.timeZone.getOffsetNanosecondsFor", - // NOTE: extra because of wall-clock time ambiguity: - "call other.timeZone.getOffsetNanosecondsFor", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", - // GetDifferenceSettings - "get options.largestUnit.toString", - "call options.largestUnit.toString", - "get options.roundingIncrement.valueOf", - "call options.roundingIncrement.valueOf", - "get options.roundingMode.toString", - "call options.roundingMode.toString", - "get options.smallestUnit.toString", - "call options.smallestUnit.toString", - // TimeZoneEquals - "get this.timeZone.id", - "get other.timeZone.id", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // DifferenceZonedDateTime - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", -], "order of operations with identical wall-clock times and largestUnit a calendar unit"); -actual.splice(0); // clear - -// Making largestUnit a calendar unit adds the following observable operations: -const expectedOpsForCalendarDifference = [ - // TimeZoneEquals - "get this.timeZone.id", - "get other.timeZone.id", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // precalculate PlainDateTime - "call this.timeZone.getOffsetNanosecondsFor", - // DifferenceZonedDateTime - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", - "call this.calendar.dateUntil", -]; - -const expectedOpsForCalendarRounding = expected.concat(expectedOpsForCalendarDifference, [ - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", - "call this.timeZone.getPossibleInstantsFor", - "call this.timeZone.getPossibleInstantsFor", -]); - -// code path that skips RoundRelativeDuration: -instance.since(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years", smallestUnit: "nanoseconds", roundingIncrement: 1 })); -assert.compareArray(actual, expected.concat(expectedOpsForCalendarDifference), "order of operations with largestUnit years and no rounding"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest year: -instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForCalendarRounding, "order of operations with smallestUnit = years"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest month: -instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" })); -assert.compareArray(actual, expectedOpsForCalendarRounding, "order of operations with smallestUnit = months"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest week: -instance.since(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); -assert.compareArray(actual, expected.concat(expectedOpsForCalendarDifference, [ - // RoundRelativeDuration - "call this.calendar.dateUntil", - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", - "call this.timeZone.getPossibleInstantsFor", - "call this.timeZone.getPossibleInstantsFor", -]), "order of operations with smallestUnit = weeks"); -actual.splice(0); // clear - -instance.since(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "hours" })); -assert.compareArray(actual, expected, "order of operations with largestUnit being a time unit"); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/proto-in-calendar-fields.js deleted file mode 100644 index a8e540675be..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/proto-in-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -assert.throws(RangeError, () => instance.since(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/read-time-fields-before-datefromfields.js deleted file mode 100644 index dee3a85d412..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.zoneddatetime.prototype.since step 3: - 3. Set _other_ to ? ToTemporalZonedDateTime(_other_). - sec-temporal-totemporalzoneddatetime step 2.j: - j. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); -const duration = datetime.since({ year: 2001, month: 9, day: 9, timeZone: "UTC", calendar }); - -TemporalHelpers.assertDuration(duration, 0, 0, 0, 0, 1, 46, 40, 987, 654, 321); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/rounding-zero-year-month-week-length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/rounding-zero-year-month-week-length.js deleted file mode 100644 index 166359f0c8d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/rounding-zero-year-month-week-length.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const dt1 = new Temporal.ZonedDateTime(0n, "UTC", cal); -const dt2 = new Temporal.ZonedDateTime(365n * 86400_000_000_000n + 1n, "UTC", cal); - -assert.throws(RangeError, () => dt1.since(dt2, { smallestUnit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => dt1.since(dt2, { smallestUnit: "months" }), "zero month length handled correctly"); -assert.throws(RangeError, () => dt1.since(dt2, { smallestUnit: "weeks" }), "zero week length handled correctly"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 0169317fa45..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const other = new Temporal.ZonedDateTime(1_100_000_000_123_456_789n, timeZone); - assert.throws(RangeError, () => datetime.since(other, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index db5b7651cee..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const other = new Temporal.ZonedDateTime(1_100_000_000_123_456_789n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.since(other, { largestUnit: "days" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 7f40af9df74..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const other = new Temporal.ZonedDateTime(1_100_000_000_123_456_789n, timeZone); - assert.throws(RangeError, () => datetime.since(other, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 3dffda84fa9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const other = new Temporal.ZonedDateTime(1_100_000_000_123_456_789n, timeZone); - assert.throws(TypeError, () => datetime.since(other, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index 7497e4d67ac..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.zoneddatetime.prototype.since step 3: - 3. Set _other_ to ? ToTemporalZonedDateTime(_other_). - sec-temporal-totemporalzoneddatetime step 7: - 7. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], [...], _result_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, _disambiguation_, _offset_). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// Not called on the instance's time zone - -const expected1 = []; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - datetime.since({ year: 2005, month: 6, day: 2, timeZone: "UTC" }); -}, expected1); - -// Called on the argument's time zone - -const expected2 = [ - "2005-06-02T00:00:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - datetime.since({ year: 2005, month: 6, day: 2, timeZone }); -}, expected2); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js index a33e732fba8..0d246a0732a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/year-zero.js @@ -12,7 +12,7 @@ const invalidStrings = [ "-0000000-01-01T00:02+00:00[UTC]", "-0000000-01-01T00:02:00.000000000+00:00[UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js index d973fd768c2..54388a33a60 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string-multiple-offsets.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+01:35"); +const timeZone = "+01:35"; const instance = new Temporal.ZonedDateTime(0n, timeZone); let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string.js index 6d641e291a7..6886504ad95 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/zoneddatetime-string.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); let str = "1970-01-01T00:00"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 60141122a26..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.startOfDay(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index b0989c59e2e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-maximum-forward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants can be at most 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 0n - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - calls++; - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12 })]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.startOfDay(); - -assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js deleted file mode 100644 index dc8f94a11a6..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 0n - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.startOfDay(), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 92c72edfe81..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone, nonBuiltinISOCalendar); -instance.startOfDay(); - -assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index b9d10d40bf0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-maximum-backward-offset-shift.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - calls++; - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12 }), - utcInstant.add({ hours: 12 }) - ]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.startOfDay(); - -assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index 70be6c2b0f7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/getpossibleinstantsfor-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.startOfDay(), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/order-of-operations.js deleted file mode 100644 index c01b80f40d5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/order-of-operations.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: User code calls happen in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - // GetPlainDateTimeFor - "call this.timeZone.getOffsetNanosecondsFor", - // GetInstantFor on preceding midnight - "call this.timeZone.getPossibleInstantsFor", -]; -const actual = []; - -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime( - 1_000_000_000_000_000_000n, - TemporalHelpers.timeZoneObserver(actual, "this.timeZone"), - calendar, -); - -const fallBackTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(1800_000), -3600_000_000_000); -const fallBackInstance = new Temporal.ZonedDateTime( - 0n, - TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor: fallBackTimeZone.getOffsetNanosecondsFor.bind(fallBackTimeZone), - getPossibleInstantsFor: fallBackTimeZone.getPossibleInstantsFor.bind(fallBackTimeZone), - }), - calendar, -); -const springForwardTimeZone = TemporalHelpers.oneShiftTimeZone(Temporal.Instant.fromEpochMilliseconds(-1800_000), 3600_000_000_000); -const springForwardInstance = new Temporal.ZonedDateTime( - 0n, - TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor: springForwardTimeZone.getOffsetNanosecondsFor.bind(springForwardTimeZone), - getPossibleInstantsFor: springForwardTimeZone.getPossibleInstantsFor.bind(springForwardTimeZone), - }), - calendar, -); -// clear any observable operations that happen due to time zone or calendar -// calls in the constructors -actual.splice(0); - -instance.startOfDay(); -assert.compareArray(actual, expected, "order of operations"); -actual.splice(0); // clear - -fallBackInstance.startOfDay(); -assert.compareArray(actual, expected, "order of operations with preceding midnight at repeated wall-clock time"); -actual.splice(0); // clear - -springForwardInstance.startOfDay(); -assert.compareArray(actual, expected.concat([ - // DisambiguatePossibleInstants - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", -]), "order of operations with preceding midnight at skipped wall-clock time"); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index ec6fb2cadba..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.startOfDay()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index d684b204e51..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.startOfDay(), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index ce26fb03451..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.startOfDay()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 0140d3b9ffc..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/startOfDay/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.startofday -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.startOfDay()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 008e58843e0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.subtract -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateAddOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateAdd"); -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateAdd should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.subtract(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.Calendar.prototype, "dateAdd", dateAddOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 1d1f7f974a8..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.subtract -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.subtract(new Temporal.Duration(1)); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/calendar-dateadd.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/calendar-dateadd.js deleted file mode 100644 index ca29a9cfcce..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/calendar-dateadd.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.subtract -description: ZonedDateTime.prototype.subtract should call dateAdd with the appropriate values. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateAdd(plainDate, duration, options) { - ++calls; - TemporalHelpers.assertPlainDate(plainDate, 2020, 3, "M03", 14, "plainDate argument"); - TemporalHelpers.assertDuration(duration, 0, -10, 0, 0, 0, 0, 0, 0, 0, 0, "duration argument"); - assert.sameValue(typeof options, "object", "options argument: type"); - assert.sameValue(Object.getPrototypeOf(options), null, "options argument: prototype"); - return super.dateAdd(plainDate, duration, options); - } -} - -const zonedDateTime = new Temporal.ZonedDateTime(1584189296_987654321n, - new Temporal.TimeZone("UTC"), new CustomCalendar()); -const result = zonedDateTime.subtract({ months: 10, hours: 14 }); -assert.sameValue(result.epochNanoseconds, 1557786896_987654321n); -assert.sameValue(calls, 1, "should have called dateAdd"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js index e9be6a85168..dc7a1c24d5c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/order-of-operations.js @@ -40,27 +40,13 @@ const expected = [ "get duration.years", "get duration.years.valueOf", "call duration.years.valueOf", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - "get this.calendar.dateAdd", - // AddZonedDateTime - "call this.timeZone.getOffsetNanosecondsFor", - "call this.calendar.dateAdd", - // ... inside Calendar.p.dateAdd "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", - // AddZonedDateTime again - "call this.timeZone.getPossibleInstantsFor", ]; const actual = []; -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.ZonedDateTime(0n, "UTC", "iso8601"); const duration = TemporalHelpers.propertyBagObserver(actual, { years: 1, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 043be5d89ba..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.subtract -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.subtract(duration)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index f259d4d1115..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.subtract -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.subtract(duration), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index c3eb79b7010..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.subtract -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.subtract(duration)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 1f60290951c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/subtract/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.subtract -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const duration = new Temporal.Duration(1); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.subtract(duration)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/timeZoneId/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/timeZoneId/builtin-timezone-no-observable-calls.js deleted file mode 100644 index f7ec46285c3..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/timeZoneId/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.timezoneid -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id"); -Object.defineProperty(Temporal.TimeZone.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.timeZoneId; - -Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/timeZoneId/timezone-id-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/timeZoneId/timezone-id-wrong-type.js deleted file mode 100644 index 2301386f141..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/timeZoneId/timezone-id-wrong-type.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: TypeError thrown if time zone reports an id that is not a String -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -[ - undefined, - null, - true, - -1000, - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongId) => { - const timeZone = new CustomTimeZone(wrongId); - const zdt = Temporal.ZonedDateTime.from({ year: 1970, month: 1, day: 1, timeZone }); - assert.throws(TypeError, () => zdt.timeZoneId); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/balance-negative-time-units.js index b396a8e4272..3c6d3b46400 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/balance-negative-time-units.js @@ -26,16 +26,14 @@ info: | 9. Let _dateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _isoCalendar_). sec-get-temporal.zoneddatetime.prototype.tojson step 3: 3. Return ? TemporalZonedDateTimeToString(_zonedDateTime_, *"auto"*, *"auto"*, *"auto"*, *"auto"*). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // ZonedDateTime -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(1001n, tz); +const datetime = new Temporal.ZonedDateTime(1001n, "-00:02"); const jsonString = datetime.toJSON(); -assert.sameValue(jsonString, "1970-01-01T00:00:00.000000999+00:00[-00:00:00.000000002]"); +assert.sameValue(jsonString, "1969-12-31T23:58:00.000001001-00:02[-00:02]"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js deleted file mode 100644 index f3a62d7b326..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tojson -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toJSON(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 8f5de5a5603..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tojson -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id"); -Object.defineProperty(Temporal.TimeZone.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toJSON(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js index e3246b9946d..36d1f8a47b0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/offset.js @@ -8,8 +8,7 @@ features: [BigInt, Temporal] ---*/ function test(timeZoneIdentifier, expected, description) { - const timeZone = new Temporal.TimeZone(timeZoneIdentifier); - const datetime = new Temporal.ZonedDateTime(0n, timeZone); + const datetime = new Temporal.ZonedDateTime(0n, timeZoneIdentifier); assert.sameValue(datetime.toJSON(), expected, description); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/order-of-operations.js deleted file mode 100644 index 91c3008fc52..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/order-of-operations.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tojson -description: Properties on objects passed to toJSON() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.id", - "get this.calendar.id", -]; -const actual = []; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); - -instance.toJSON(); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index a30ed166433..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tojson -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toJSON()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index ae63bf8160c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tojson -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.toJSON(), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index c159ab853be..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tojson -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toJSON()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index d0cca238d42..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tojson -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.toJSON()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-id-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-id-wrong-type.js deleted file mode 100644 index b6ac702a9a8..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/timezone-id-wrong-type.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: TypeError thrown if time zone reports an id that is not a String -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -[ - undefined, - null, - true, - -1000, - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongId) => { - const timeZone = new CustomTimeZone(wrongId); - const zdt = Temporal.ZonedDateTime.from({ year: 1970, month: 1, day: 1, timeZone }); - assert.throws(TypeError, () => zdt.toJSON()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/year-format.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/year-format.js index d532f99c4a6..64bdf8d41dd 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/year-format.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toJSON/year-format.js @@ -13,43 +13,41 @@ function epochNsInYear(year) { return (year - 1970n) * avgNsPerYear + (avgNsPerYear / 2n); } -const utc = new Temporal.TimeZone("UTC"); - -let instance = new Temporal.ZonedDateTime(epochNsInYear(-100000n), utc); +let instance = new Temporal.ZonedDateTime(epochNsInYear(-100000n), "UTC"); assert.sameValue(instance.toJSON(), "-100000-07-01T21:30:36+00:00[UTC]", "large negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-10000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-10000n), "UTC"); assert.sameValue(instance.toJSON(), "-010000-07-01T21:30:36+00:00[UTC]", "smallest 5-digit negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-9999n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-9999n), "UTC"); assert.sameValue(instance.toJSON(), "-009999-07-02T03:19:48+00:00[UTC]", "largest 4-digit negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-1000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-1000n), "UTC"); assert.sameValue(instance.toJSON(), "-001000-07-02T09:30:36+00:00[UTC]", "smallest 4-digit negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-999n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-999n), "UTC"); assert.sameValue(instance.toJSON(), "-000999-07-02T15:19:48+00:00[UTC]", "largest 3-digit negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-1n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-1n), "UTC"); assert.sameValue(instance.toJSON(), "-000001-07-02T15:41:24+00:00[UTC]", "year -1 formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(0n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(0n), "UTC"); assert.sameValue(instance.toJSON(), "0000-07-01T21:30:36+00:00[UTC]", "year 0 formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(1n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(1n), "UTC"); assert.sameValue(instance.toJSON(), "0001-07-02T03:19:48+00:00[UTC]", "year 1 formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(999n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(999n), "UTC"); assert.sameValue(instance.toJSON(), "0999-07-02T03:41:24+00:00[UTC]", "largest 3-digit positive year formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(1000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(1000n), "UTC"); assert.sameValue(instance.toJSON(), "1000-07-02T09:30:36+00:00[UTC]", "smallest 4-digit positive year formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(9999n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(9999n), "UTC"); assert.sameValue(instance.toJSON(), "9999-07-02T15:41:24+00:00[UTC]", "largest 4-digit positive year formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(10000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(10000n), "UTC"); assert.sameValue(instance.toJSON(), "+010000-07-01T21:30:36+00:00[UTC]", "smallest 5-digit positive year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(100000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(100000n), "UTC"); assert.sameValue(instance.toJSON(), "+100000-07-01T21:30:36+00:00[UTC]", "large positive year formatted as 6-digit"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index e820073c718..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tolocalestring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toLocaleString(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 00ff2997c10..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tolocalestring -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id"); -Object.defineProperty(Temporal.TimeZone.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toLocaleString(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/timezone-id-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/timezone-id-wrong-type.js deleted file mode 100644 index 8b9c856054d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toLocaleString/timezone-id-wrong-type.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: TypeError thrown if time zone reports an id that is not a String -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -[ - undefined, - null, - true, - -1000, - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongId) => { - const timeZone = new CustomTimeZone(wrongId); - const zdt = Temporal.ZonedDateTime.from({ year: 1970, month: 1, day: 1, timeZone }); - assert.throws(TypeError, () => zdt.toLocaleString()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/builtin-timezone-no-observable-calls.js deleted file mode 100644 index cf4cb037cf5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindate -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toPlainDate(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 8cc238b12ab..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindate -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toPlainDate()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 0ed5d282550..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindate -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.toPlainDate(), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index d3a8810fb3d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindate -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toPlainDate()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index c22035e5390..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDate/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindate -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.toPlainDate()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/balance-negative-time-units.js index e9dbd5088ec..de999358846 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/balance-negative-time-units.js @@ -31,9 +31,8 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(1001n, tz); +const datetime = new Temporal.ZonedDateTime(1001n, "-00:02"); const pdt = datetime.toPlainDateTime(); -TemporalHelpers.assertPlainDateTime(pdt, 1970, 1, "M01", 1, 0, 0, 0, 0, 0, 999); +TemporalHelpers.assertPlainDateTime(pdt, 1969, 12, "M12", 31, 23, 58, 0, 0, 1, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/builtin-timezone-no-observable-calls.js deleted file mode 100644 index afaabb6410d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindatetime -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toPlainDateTime(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/limits.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/limits.js new file mode 100644 index 00000000000..57f06adceda --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/limits.js @@ -0,0 +1,24 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.toplaindatetime +description: Checking limits of representable PlainDateTime +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const min = new Temporal.ZonedDateTime(-8_640_000_000_000_000_000_000n, "-23:59"); +const max = new Temporal.ZonedDateTime(8_640_000_000_000_000_000_000n, "+23:59"); + +TemporalHelpers.assertPlainDateTime( + min.toPlainDateTime(), + -271821, 4, "M04", 19, 0, 1, 0, 0, 0, 0, + "minimum" +); + +TemporalHelpers.assertPlainDateTime( + max.toPlainDateTime(), + 275760, 9, "M09", 13, 23, 59, 0, 0, 0, 0, + "maximum" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/plain-custom-timezone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/plain-custom-timezone.js deleted file mode 100644 index 1ec1b9a7394..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/plain-custom-timezone.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindatetime -description: timeZone.getOffsetNanosecondsFor() called -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const actual = []; -const expected = [ - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - "get timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", -]; - -const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor: -8735135802468, -}); - -const zdt = new Temporal.ZonedDateTime(160583136123456789n, timeZone); -const dateTime = Temporal.PlainDateTime.from("1975-02-02T12:00:00.987654321"); -const result = zdt.toPlainDateTime(); -for (const property of ["year", "month", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond"]) { - assert.sameValue(result[property], dateTime[property], property); -} - -assert.compareArray(actual, expected); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/pre-epoch.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/pre-epoch.js new file mode 100644 index 00000000000..520f57dac5d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/pre-epoch.js @@ -0,0 +1,13 @@ +// Copyright (C) 2020 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.toplaindatetime +description: Test of basic functionality for an exact time earlier than the Unix epoch +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const zdt = Temporal.ZonedDateTime.from("1969-07-16T13:32:01.234567891Z[-04:00]"); +const dateTime = zdt.toPlainDateTime(); +TemporalHelpers.assertPlainDateTime(dateTime, 1969, 7, "M07", 16, 9, 32, 1, 234, 567, 891); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 888ebc14d93..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindatetime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toPlainDateTime()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 3e762a1139e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindatetime -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.toPlainDateTime(), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index d564ffb4244..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindatetime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toPlainDateTime()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index f559b4aa2e9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainDateTime/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaindatetime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.toPlainDateTime()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/balance-negative-time-units.js index c9b0107d314..423eee1a886 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/balance-negative-time-units.js @@ -31,9 +31,8 @@ features: [Temporal] // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(1001n, tz); +const datetime = new Temporal.ZonedDateTime(1001n, "-00:02"); const time = datetime.toPlainTime(); -TemporalHelpers.assertPlainTime(time, 0, 0, 0, 0, 0, 999); +TemporalHelpers.assertPlainTime(time, 23, 58, 0, 0, 1, 1); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 04fac73de94..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaintime -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toPlainTime(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 8ac9757f363..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaintime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toPlainTime()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 8b3b63f2e2d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaintime -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.toPlainTime(), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 0d535db4b6f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaintime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toPlainTime()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index f5c4a4f5480..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainTime/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.toplaintime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.toPlainTime()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/balance-negative-time-units.js index e3db9562d2d..0cd8568ad89 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/balance-negative-time-units.js @@ -26,16 +26,14 @@ info: | 9. Let _dateTime_ be ? BuiltinTimeZoneGetPlainDateTimeFor(_timeZone_, _instant_, _isoCalendar_). sec-get-temporal.zoneddatetime.prototype.tostring step 9: 9. Return ? TemporalZonedDateTimeToString(_zonedDateTime_, _precision_.[[Precision]], _showCalendar_, _showTimeZone_, _showOffset_, _precision_.[[Increment]], _precision_.[[Unit]], _roundingMode_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // ZonedDateTime -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(1001n, tz); +const datetime = new Temporal.ZonedDateTime(1001n, "-00:02"); const isoString = datetime.toString(); -assert.sameValue(isoString, "1970-01-01T00:00:00.000000999+00:00[-00:00:00.000000002]"); +assert.sameValue(isoString, "1969-12-31T23:58:00.000001001-00:02[-00:02]"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 0f43ef3f131..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tostring -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toString(); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 37682749831..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tostring -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id"); -Object.defineProperty(Temporal.TimeZone.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.toString(); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js deleted file mode 100644 index 3c4b251bede..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendar-tostring.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.protoype.tostring -description: Number of observable 'toString' calls on the calendar for each value of calendarName -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -let calls; -const customCalendar = { - get id() { - ++calls; - return "custom"; - }, - toString() { - TemporalHelpers.assertUnreachable('toString should not be called'); - }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const date = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", customCalendar); -[ - ["always", "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", 1], - ["auto", "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", 1], - ["critical", "2001-09-09T01:46:40.987654321+00:00[UTC][!u-ca=custom]", 1], - ["never", "2001-09-09T01:46:40.987654321+00:00[UTC]", 0], - [undefined, "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", 1], -].forEach(([calendarName, expectedResult, expectedCalls]) => { - calls = 0; - const result = date.toString({ calendarName }); - assert.sameValue(result, expectedResult, `id for calendarName = ${calendarName}`); - assert.sameValue(calls, expectedCalls, `calls to id getter for calendarName = ${calendarName}`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js index 08d3803acda..7ace486c457 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js @@ -7,39 +7,6 @@ description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); - const result = date.toString({ calendarName: "always" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = always`); -} +const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC"); +const result = date.toString({ calendarName: "always" }); +assert.sameValue(result, "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=iso8601]", `built-in ISO calendar for calendarName = always`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js index 5685d98990b..996cfe4bd01 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js @@ -7,39 +7,6 @@ description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); - const result = date.toString({ calendarName: "auto" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); -} +const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC"); +const result = date.toString({ calendarName: "auto" }); +assert.sameValue(result, "1970-01-01T01:01:01.987654321+00:00[UTC]", `built-in ISO calendar for calendarName = auto`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js index 4cd5f7bcde0..5f9c83f66ba 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js @@ -9,39 +9,6 @@ description: > features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=iso8601]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=iso8601]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); - const result = date.toString({ calendarName: "critical" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); -} +const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC"); +const result = date.toString({ calendarName: "critical" }); +assert.sameValue(result, "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=iso8601]", `built-in ISO calendar for calendarName = critical`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js index 23d81baa91b..aaec4137a23 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js @@ -7,39 +7,6 @@ description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); - const result = date.toString({ calendarName: "never" }); - assert.sameValue(result, expected, `${description} calendar for calendarName = never`); -} +const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC"); +const result = date.toString({ calendarName: "never" }); +assert.sameValue(result, "1970-01-01T01:01:01.987654321+00:00[UTC]", `built-in ISO calendar for calendarName = never`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js index 245597ed63b..13a21aaa1c5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js @@ -14,40 +14,7 @@ info: | features: [Temporal] ---*/ -const calendarMethods = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - -const tests = [ - [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], - [[{ id: "custom", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=custom]", "custom"], - [[{ id: "iso8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC]", "custom with iso8601 id"], - [[{ id: "ISO8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=ISO8601]", "custom with caps id"], - [[{ id: "\u0131so8601", ...calendarMethods }], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=\u0131so8601]", "custom with dotless i id"], -]; - -for (const [args, expected, description] of tests) { - const datetime = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); - const result = datetime.toString({ calendarName: undefined }); - assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); - // See options-object.js for {} and options-undefined.js for absent options arg -} +const datetime = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC"); +const result = datetime.toString({ calendarName: undefined }); +assert.sameValue(result, "1970-01-01T01:01:01.987654321+00:00[UTC]", `default calendarName option is auto with built-in ISO calendar`); +// See options-object.js for {} and options-undefined.js for absent options arg diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js index 21bca7e70e2..039906e795a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js @@ -15,32 +15,9 @@ includes: [compareArray.js, temporalHelpers.js] features: [Temporal] ---*/ -const calendar = { - id: "custom", - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); +const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", "iso8601"); TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", (calendarName) => datetime.toString({ calendarName }), - (result, descr) => assert.sameValue(result, "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=custom]", descr), + (result, descr) => assert.sameValue(result, "2001-09-09T01:46:40.987654321+00:00[UTC]", descr), ); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js index 5ff25b6c716..69905f17c68 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/offset.js @@ -8,8 +8,7 @@ features: [BigInt, Temporal] ---*/ function test(timeZoneIdentifier, expected, description) { - const timeZone = new Temporal.TimeZone(timeZoneIdentifier); - const datetime = new Temporal.ZonedDateTime(0n, timeZone); + const datetime = new Temporal.ZonedDateTime(0n, timeZoneIdentifier); assert.sameValue(datetime.toString(), expected, description); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-undefined.js deleted file mode 100644 index c8ba5fce0f5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/options-undefined.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tostring -description: Verify that undefined options are handled correctly. -features: [Temporal] ----*/ - -const calendar = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "custom", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -const datetime1 = new Temporal.ZonedDateTime(957270896_987_650_000n, "UTC"); -const datetime2 = new Temporal.ZonedDateTime(957270896_987_650_000n, "UTC", calendar); - -[ - [datetime1, "2000-05-02T12:34:56.98765+00:00[UTC]"], - [datetime2, "2000-05-02T12:34:56.98765+00:00[UTC][u-ca=custom]"], -].forEach(([datetime, expected]) => { - const explicit = datetime.toString(undefined); - assert.sameValue(explicit, expected, "default show options are auto, precision is auto, and no rounding"); - - const propertyImplicit = datetime.toString({}); - assert.sameValue(propertyImplicit, expected, "default show options are auto, precision is auto, and no rounding"); - - const implicit = datetime.toString(); - assert.sameValue(implicit, expected, "default show options are auto, precision is auto, and no rounding"); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js index 48c4fa95a85..23b27b58ae9 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/order-of-operations.js @@ -27,18 +27,10 @@ const expected = [ "get options.timeZoneName", "get options.timeZoneName.toString", "call options.timeZoneName.toString", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.id", - "get this.calendar.id", ]; const actual = []; -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); instance.toString( TemporalHelpers.propertyBagObserver(actual, { @@ -71,10 +63,6 @@ const expectedForFractionalSecondDigits = [ "get options.timeZoneName", "get options.timeZoneName.toString", "call options.timeZoneName.toString", - "get this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.id", - "get this.calendar.id", ]; instance.toString( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index f32b4dccc0a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tostring -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toString()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 0aab6752397..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tostring -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.toString(), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index f6a24662709..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tostring -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.toString()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 4d8dc3812b4..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tostring -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.toString()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-id-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-id-wrong-type.js deleted file mode 100644 index c2cf7f92eca..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezone-id-wrong-type.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: TypeError thrown if time zone reports an id that is not a String -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -[ - undefined, - null, - true, - -1000, - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongId) => { - const timeZone = new CustomTimeZone(wrongId); - const zdt = Temporal.ZonedDateTime.from({ year: 1970, month: 1, day: 1, timeZone }); - assert.throws(TypeError, () => zdt.toString()); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-auto.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-auto.js index 46f1b57c3bf..7a1c8079fe2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-auto.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-auto.js @@ -10,11 +10,6 @@ features: [Temporal] const tests = [ ["UTC", "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in UTC"], ["+01:00", "1970-01-01T02:01:01.987654321+01:00[+01:00]", "built-in offset"], - [{ - getOffsetNanosecondsFor() { return 0; }, - getPossibleInstantsFor() { return []; }, - id: "Etc/Custom", - }, "1970-01-01T01:01:01.987654321+00:00[Etc/Custom]", "custom"], ]; for (const [timeZone, expected, description] of tests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-critical.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-critical.js index b20ebe5d7a7..7b277350c97 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-critical.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-critical.js @@ -12,11 +12,6 @@ features: [Temporal] const tests = [ ["UTC", "1970-01-01T01:01:01.987654321+00:00[!UTC]", "built-in UTC"], ["+01:00", "1970-01-01T02:01:01.987654321+01:00[!+01:00]", "built-in offset"], - [{ - getOffsetNanosecondsFor() { return 0; }, - getPossibleInstantsFor() { return []; }, - id: "Etc/Custom", - }, "1970-01-01T01:01:01.987654321+00:00[!Etc/Custom]", "custom"], ]; for (const [timeZone, expected, description] of tests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-never.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-never.js index 5f87ca06bb8..a4604570384 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-never.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/timezonename-never.js @@ -10,11 +10,6 @@ features: [Temporal] const tests = [ ["UTC", "1970-01-01T01:01:01.987654321+00:00", "built-in UTC"], ["+01:00", "1970-01-01T02:01:01.987654321+01:00", "built-in offset"], - [{ - getOffsetNanosecondsFor() { return 0; }, - getPossibleInstantsFor() { return []; }, - id: "Etc/Custom", - }, "1970-01-01T01:01:01.987654321+00:00", "custom"], ]; for (const [timeZone, expected, description] of tests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/year-format.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/year-format.js index 1532bf1fecd..7b4e51ac5ae 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/toString/year-format.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toString/year-format.js @@ -13,43 +13,41 @@ function epochNsInYear(year) { return (year - 1970n) * avgNsPerYear + (avgNsPerYear / 2n); } -const utc = new Temporal.TimeZone("UTC"); - -let instance = new Temporal.ZonedDateTime(epochNsInYear(-100000n), utc); +let instance = new Temporal.ZonedDateTime(epochNsInYear(-100000n), "UTC"); assert.sameValue(instance.toString(), "-100000-07-01T21:30:36+00:00[UTC]", "large negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-10000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-10000n), "UTC"); assert.sameValue(instance.toString(), "-010000-07-01T21:30:36+00:00[UTC]", "smallest 5-digit negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-9999n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-9999n), "UTC"); assert.sameValue(instance.toString(), "-009999-07-02T03:19:48+00:00[UTC]", "largest 4-digit negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-1000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-1000n), "UTC"); assert.sameValue(instance.toString(), "-001000-07-02T09:30:36+00:00[UTC]", "smallest 4-digit negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-999n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-999n), "UTC"); assert.sameValue(instance.toString(), "-000999-07-02T15:19:48+00:00[UTC]", "largest 3-digit negative year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(-1n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(-1n), "UTC"); assert.sameValue(instance.toString(), "-000001-07-02T15:41:24+00:00[UTC]", "year -1 formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(0n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(0n), "UTC"); assert.sameValue(instance.toString(), "0000-07-01T21:30:36+00:00[UTC]", "year 0 formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(1n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(1n), "UTC"); assert.sameValue(instance.toString(), "0001-07-02T03:19:48+00:00[UTC]", "year 1 formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(999n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(999n), "UTC"); assert.sameValue(instance.toString(), "0999-07-02T03:41:24+00:00[UTC]", "largest 3-digit positive year formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(1000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(1000n), "UTC"); assert.sameValue(instance.toString(), "1000-07-02T09:30:36+00:00[UTC]", "smallest 4-digit positive year formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(9999n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(9999n), "UTC"); assert.sameValue(instance.toString(), "9999-07-02T15:41:24+00:00[UTC]", "largest 4-digit positive year formatted as 4-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(10000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(10000n), "UTC"); assert.sameValue(instance.toString(), "+010000-07-01T21:30:36+00:00[UTC]", "smallest 5-digit positive year formatted as 6-digit"); -instance = new Temporal.ZonedDateTime(epochNsInYear(100000n), utc); +instance = new Temporal.ZonedDateTime(epochNsInYear(100000n), "UTC"); assert.sameValue(instance.toString(), "+100000-07-01T21:30:36+00:00[UTC]", "large positive year formatted as 6-digit"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index ff93b0eec36..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const timeZone = "UTC"; -const instance = new Temporal.ZonedDateTime(0n, timeZone); -const arg = { year: 2000, month: 5, day: 2, hour: 21, minute: 43, second: 5, timeZone, calendar: "iso8601" }; -instance.until(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-ambiguous-wall-clock-time.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-ambiguous-wall-clock-time.js deleted file mode 100644 index 16fcfab56f5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-ambiguous-wall-clock-time.js +++ /dev/null @@ -1,90 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Correct time zone calls are made when converting a ZonedDateTime-like property - bag denoting an ambiguous wall-clock time -includes: [temporalHelpers.js, compareArray.js] -features: [Temporal] ----*/ - -const actual = []; - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const dstTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor.bind(dstTimeZone), - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor.bind(dstTimeZone), -}); -const calendar = TemporalHelpers.calendarObserver(actual, "calendar"); - -const timeZone = "UTC"; -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -let arg = { year: 2000, month: 4, day: 2, hour: 2, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.until(arg); - -const expected = [ - // GetTemporalCalendarSlotValueWithISODefault - "has calendar.dateAdd", - "has calendar.dateFromFields", - "has calendar.dateUntil", - "has calendar.day", - "has calendar.dayOfWeek", - "has calendar.dayOfYear", - "has calendar.daysInMonth", - "has calendar.daysInWeek", - "has calendar.daysInYear", - "has calendar.fields", - "has calendar.id", - "has calendar.inLeapYear", - "has calendar.mergeFields", - "has calendar.month", - "has calendar.monthCode", - "has calendar.monthDayFromFields", - "has calendar.monthsInYear", - "has calendar.weekOfYear", - "has calendar.year", - "has calendar.yearMonthFromFields", - "has calendar.yearOfWeek", - // lookup in ToTemporalZonedDateTime - "get calendar.dateFromFields", - "get calendar.fields", - // CalendarFields - "call calendar.fields", - // ToTemporalTimeZoneSlotValue - "has timeZone.getOffsetNanosecondsFor", - "has timeZone.getPossibleInstantsFor", - "has timeZone.id", - // InterpretTemporalDateTimeFields - "call calendar.dateFromFields", - // lookup in ToTemporalZonedDateTime - "get timeZone.getOffsetNanosecondsFor", - "get timeZone.getPossibleInstantsFor", - // InterpretISODateTimeOffset - "call timeZone.getPossibleInstantsFor", -]; - -const expectedSpringForward = expected.concat([ - // DisambiguatePossibleInstants - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getOffsetNanosecondsFor", - "call timeZone.getPossibleInstantsFor", -]); -assert.compareArray( - actual.slice(0, expectedSpringForward.length), // ignore operations after ToTemporalZonedDateTime - expectedSpringForward, - "order of operations converting property bag at skipped wall-clock time" -); -actual.splice(0); // clear - -arg = { year: 2000, month: 10, day: 29, hour: 1, minute: 30, timeZone: dstTimeZoneObserver, calendar }; -instance.until(arg); - -assert.compareArray( - actual.slice(0, expected.length), // ignore operations after ToTemporalZonedDateTime - expected, - "order of operations converting property bag at repeated wall-clock time" -); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-case-insensitive.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-case-insensitive.js index 1dd8006d863..0ca4690f922 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-case-insensitive.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-case-insensitive.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const arg = { year: 1970, monthCode: "M01", day: 1, timeZone, calendar: "IsO8601" }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-iso-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-iso-string.js index b3dac55ef3d..4b16970970f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-iso-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-iso-string.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); for (const calendar of [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-leap-second.js index 3d98103d938..2330baf2151 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-leap-second.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const calendar = "2016-12-31T23:59:60+00:00[UTC]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-number.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-number.js index c3e14bef3f3..c3a04508179 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-number.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-number.js @@ -7,7 +7,7 @@ description: A number as calendar in a property bag is not accepted features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const numbers = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-string.js index 792f99d3e21..2236448ccfe 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-string.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const calendar = "iso8601"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-wrong-type.js index fea32897da0..79c80d3f2ca 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.zoneddatetime.prototype.until description: > Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string + be converted to a calendar ID features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const primitiveTests = [ @@ -31,10 +31,8 @@ for (const [calendar, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [calendar, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js index be524e3ecb6..34a88092685 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-calendar-year-zero.js @@ -14,7 +14,7 @@ const invalidStrings = [ "-000000-10-31T17:45+01:00", "-000000-10-31T17:45+00:00[UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((str) => { const arg = { year: 1976, month: 11, day: 18, calendar: str }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index d77faa36ff7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); -const arg = { year: 2000, month: 5, day: 2, timeZone, calendar: nonBuiltinISOCalendar }; - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.until(arg); - -assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-invalid-offset-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-invalid-offset-string.js index 65c1091f9b5..09a001384a5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-invalid-offset-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-invalid-offset-string.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset is in the w features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const badOffsets = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-offset-not-agreeing-with-timezone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-offset-not-agreeing-with-timezone.js index 1895808b8c6..692451011df 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-offset-not-agreeing-with-timezone.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-offset-not-agreeing-with-timezone.js @@ -7,7 +7,7 @@ description: Property bag with offset property is rejected if offset does not ag features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+01:00"); +const timeZone = "+01:00"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const properties = { year: 2021, month: 10, day: 28, offset: "-07:00", timeZone }; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-backward-offset-shift.js deleted file mode 100644 index c923075d16f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.until(arg), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-forward-offset-shift.js deleted file mode 100644 index a6e382f7b46..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 12n * 3600n * 1_000_000_000n; // 1970-01-01T12:00Z - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); -const arg = { year: 1970, month: 1, day: 1, hour: 12, timeZone }; - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.until(arg), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 2424fec49be..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => datetime.until(properties, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 19ee41242f6..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - timeZone.getPossibleInstantsFor = function () { - return []; - }; - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.until(properties, { largestUnit: "days" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 9d1be2ce66e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(RangeError, () => datetime.until(properties, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index fcb3495f753..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - timeZone.getPossibleInstantsFor = function () { - return []; - }; - assert.throws(TypeError, () => datetime.until(properties, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-id-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-id-wrong-type.js deleted file mode 100644 index 9ad8e073f99..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-id-wrong-type.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: TypeError thrown if time zone reports an id that is not a String -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -[ - undefined, - null, - true, - -1000, - Symbol(), - 3600_000_000_000n, - {}, - { - valueOf() { - return 3600_000_000_000; - } - } -].forEach((wrongId) => { - const timeZone = new CustomTimeZone(wrongId); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const properties = { year: 2004, month: 11, day: 9, hour: 11, minute: 33, second: 20, timeZone }; - assert.throws(TypeError, () => datetime.until(properties, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js index 3373b02be48..a649355ca7e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.until -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-year-zero.js index 3e01e23583e..90604c9d5b7 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-year-zero.js @@ -11,7 +11,7 @@ const invalidStrings = [ "-000000-10-31T17:45Z", "-000000-10-31T17:45+00:00[UTC]", ]; -const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); invalidStrings.forEach((timeZone) => { assert.throws( RangeError, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string.js index 3e6f906f491..591fd3db7dd 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string.js @@ -4,32 +4,11 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.until description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance1 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance1 = new Temporal.ZonedDateTime(0n, "UTC"); assert(instance1.until({ year: 1970, month: 1, day: 1, timeZone: "UTC" }).blank, "Time zone created from string 'UTC'"); -const instance2 = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("-01:30")); +const instance2 = new Temporal.ZonedDateTime(0n, "-01:30"); assert(instance2.until({ year: 1969, month: 12, day: 31, hour: 22, minute: 30, timeZone: "-01:30" }).blank, "Time zone created from string '-01:30'"); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-wrong-type.js index 479d405086b..e0c4414740f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.zoneddatetime.prototype.until description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const primitiveTests = [ [null, "null"], @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js index 43756371181..4a71e7829a7 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation-invalid-key.js @@ -12,7 +12,7 @@ const invalidStrings = [ ["1970-01-01T00:00[UTC][u-CA=iso8601]", "invalid partially-capitalized key"], ["1970-01-01T00:00[UTC][FOO=bar]", "invalid capitalized unrecognized key"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach(([arg, descr]) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation.js index 832a57b7c5d..8f2fda4fea5 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-calendar-annotation.js @@ -14,7 +14,7 @@ const tests = [ ["1970-01-01T00:00[UTC][u-ca=iso8601][u-ca=discord]", "second annotation ignored"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-critical-unknown-annotation.js index a29b7bc4c81..4b1fdb5b9c9 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-critical-unknown-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-critical-unknown-annotation.js @@ -13,7 +13,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][u-ca=iso8601][!foo=bar]", "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-date-with-utc-offset.js index 5e36bdaf703..2c9709e78fd 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-date-with-utc-offset.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-date-with-utc-offset.js @@ -8,7 +8,7 @@ features: [Temporal] includes: [temporalHelpers.js] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const validStrings = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-calendar.js index 1d028c54828..e79b2980c16 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-calendar.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-calendar.js @@ -14,7 +14,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][!u-ca=iso8601][u-ca=iso8601]", "1970-01-01T00:00[UTC][u-ca=iso8601][foo=bar][!u-ca=iso8601]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-time-zone.js index 5a9d0c16bcb..b9810322c3e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-time-zone.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-multiple-time-zone.js @@ -14,7 +14,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", "1970-01-01T00:00[UTC][foo=bar][UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-separators.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-separators.js index 10cf3513521..9e4cd13d99a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-separators.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-separators.js @@ -14,7 +14,7 @@ const tests = [ ["1970-01-01 00:00+00:00[UTC]", "space between date and time"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-zone-annotation.js index 37ed65f3094..8c2a81a2cff 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-zone-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-time-zone-annotation.js @@ -23,7 +23,7 @@ const tests = [ ["1970-01-01T00:00+00:00[!+00:00]", "numeric, with offset and !"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-unknown-annotation.js index 471ef894156..9b3e67b2724 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-unknown-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-string-unknown-annotation.js @@ -15,7 +15,7 @@ const tests = [ ["1970-01-01T00:00[UTC][foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-wrong-type.js index 528825459d3..d5343106358 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-wrong-type.js @@ -9,7 +9,7 @@ description: > features: [BigInt, Symbol, Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const primitiveTests = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/balance-negative-time-units.js index 2005406753c..376d45f5756 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/balance-negative-time-units.js @@ -30,25 +30,24 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); -const datetime = new Temporal.ZonedDateTime(830998861_001_001_001n, timeZone); +const datetime = new Temporal.ZonedDateTime(830998861_001_001_001n, "UTC"); const options = { largestUnit: "days" }; -const result1 = new Temporal.ZonedDateTime(830995200_000_000_002n, timeZone).until(datetime, options); +const result1 = new Temporal.ZonedDateTime(830995200_000_000_002n, "UTC").until(datetime, options); TemporalHelpers.assertDuration(result1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 999, "nanoseconds balance"); -const result2 = new Temporal.ZonedDateTime(830995200_000_002_000n, timeZone).until(datetime, options); +const result2 = new Temporal.ZonedDateTime(830995200_000_002_000n, "UTC").until(datetime, options); TemporalHelpers.assertDuration(result2, 0, 0, 0, 0, 1, 1, 1, 0, 999, 1, "microseconds balance"); -const result3 = new Temporal.ZonedDateTime(830995200_002_000_000n, timeZone).until(datetime, options); +const result3 = new Temporal.ZonedDateTime(830995200_002_000_000n, "UTC").until(datetime, options); TemporalHelpers.assertDuration(result3, 0, 0, 0, 0, 1, 1, 0, 999, 1, 1, "milliseconds balance"); -const result4 = new Temporal.ZonedDateTime(830995202_000_000_000n, timeZone).until(datetime, options); +const result4 = new Temporal.ZonedDateTime(830995202_000_000_000n, "UTC").until(datetime, options); TemporalHelpers.assertDuration(result4, 0, 0, 0, 0, 1, 0, 59, 1, 1, 1, "seconds balance"); -const result5 = new Temporal.ZonedDateTime(830995320_000_000_000n, timeZone).until(datetime, options); +const result5 = new Temporal.ZonedDateTime(830995320_000_000_000n, "UTC").until(datetime, options); TemporalHelpers.assertDuration(result5, 0, 0, 0, 0, 0, 59, 1, 1, 1, 1, "minutes balance"); // This one is different because hours are later balanced again in BalanceDuration -const result6 = new Temporal.ZonedDateTime(831002400_000_000_000n, timeZone).until(datetime, options); +const result6 = new Temporal.ZonedDateTime(831002400_000_000_000n, "UTC").until(datetime, options); TemporalHelpers.assertDuration(result6, 0, 0, 0, 0, 0, -58, -58, -998, -998, -999, "hours balance"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/branding.js index a84b29e76b6..e5cc9d80779 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/branding.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/branding.js @@ -11,7 +11,7 @@ const until = Temporal.ZonedDateTime.prototype.until; assert.sameValue(typeof until, "function"); -const args = [new Temporal.ZonedDateTime(123456n, new Temporal.TimeZone("UTC"))]; +const args = [new Temporal.ZonedDateTime(123456n, "UTC")]; assert.throws(TypeError, () => until.apply(undefined, args), "undefined"); assert.throws(TypeError, () => until.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 598a9f698b0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const dateUntilOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateUntil"); -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateUntil should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.until(new Temporal.ZonedDateTime(1_100_000_000_000_000_000n, "UTC")); - -Object.defineProperty(Temporal.Calendar.prototype, "dateUntil", dateUntilOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 369dddc4628..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.until(new Temporal.ZonedDateTime(1_100_000_000_000_000_000n, "UTC")); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js deleted file mode 100644 index 0d6d51dea3e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateadd-called-with-options-undefined.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - BuiltinTimeZoneGetInstantFor calls Calendar.dateAdd with undefined as the - options value -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarDateAddUndefinedOptions(); -const timeZone = TemporalHelpers.oneShiftTimeZone(new Temporal.Instant(0n), 3600e9); -const earlier = new Temporal.ZonedDateTime(0n, timeZone, calendar); -const later = new Temporal.ZonedDateTime(1_213_200_000_000_000n, timeZone, calendar); - -// Difference with rounding, with smallestUnit a calendar unit. -// The calls come from these paths: -// ZonedDateTime.until() -> DifferenceZonedDateTimeWithRounding -> RoundRelativeDuration -> NudgeToCalendarUnit -> -// AddDateTime -> calendar.dateAdd() (2x) - -earlier.until(later, { smallestUnit: "weeks" }); -assert.sameValue(calendar.dateAddCallCount, 2, "rounding difference with calendar smallestUnit"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-datefromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index fbffafa2419..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); -const arg = { year: 2000, month: 5, day: 2, timeZone, calendar }; -instance.until(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-copy-of-options.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-copy-of-options.js deleted file mode 100644 index 5bc1242b13a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-copy-of-options.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: The dateUntil() method on the calendar is called with a copy of the options bag -features: [Temporal] ----*/ - -const originalOptions = { - largestUnit: "year", - shouldBeCopied: {}, -}; -let called = false; - -class Calendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - - dateUntil(d1, d2, options) { - called = true; - assert.notSameValue(options, originalOptions, "options bag should be a copy"); - assert.sameValue(options.shouldBeCopied, originalOptions.shouldBeCopied, "options bag should be a shallow copy"); - return new Temporal.Duration(1); - } -} -const calendar = new Calendar(); -const earlier = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -// exactly one year later; avoids NanosecondsToDays path -const later = new Temporal.ZonedDateTime(1_031_536_000_000_000_000n, "UTC", calendar); -earlier.until(later, originalOptions); -assert(called, "calendar.dateUntil must be called"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js deleted file mode 100644 index adb200001c9..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-null-prototype-options.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Calendar.dateUntil method is called with a null-prototype object as the - options value when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckOptionsPrototypePollution(); -const instance = new Temporal.ZonedDateTime(0n, "UTC", calendar); -const argument = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -instance.until(argument, { largestUnit: "year" }); -assert.sameValue(calendar.dateUntilCallCount, 1, "dateUntil should have been called on the calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js deleted file mode 100644 index 5d472420376..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-dateuntil-called-with-singular-largestunit.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - The options object passed to calendar.dateUntil has a largestUnit property - with its value in the singular form -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); - const later = new Temporal.ZonedDateTime(1_086_403_661_988_655_322n, "UTC", calendar); - earlier.until(later, { largestUnit }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); - -// Additionally check the path that goes through AdjustRoundedDurationDays - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, largestUnit) => { - const earlier = new Temporal.ZonedDateTime(-31536000_000_000_000n /* = -365 days */, "UTC", calendar); - const later = new Temporal.ZonedDateTime(86_399_999_999_999n, "UTC", calendar); - earlier.until(later, { largestUnit, roundingIncrement: 2, roundingMode: 'ceil' }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); - -// Also check the path that goes through RoundDuration when smallestUnit is -// given - -TemporalHelpers.checkCalendarDateUntilLargestUnitSingular( - (calendar, smallestUnit) => { - const earlier = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); - const later = new Temporal.ZonedDateTime(1_086_403_661_988_655_322n, "UTC", calendar); - earlier.until(later, { smallestUnit }); - }, - { - years: ["year"], - months: ["month"], - weeks: ["week", "week"], - days: [], - hours: [], - minutes: [], - seconds: [], - milliseconds: [], - microseconds: [], - nanoseconds: [] - } -); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-fields-iterable.js deleted file mode 100644 index befb9f19624..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-fields-iterable.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.zoneddatetime.prototype.until step 3: - 3. Set _other_ to ? ToTemporalZonedDateTime(_other_). - sec-temporal-totemporalzoneddatetime step 2.c: - c. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"month"*, *"monthCode"*, *"nanosecond"*, *"second"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar1 = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar1); -const calendar2 = TemporalHelpers.calendarFieldsIterable(); -datetime.until({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: calendar2 }); - -assert.sameValue(calendar1.fieldsCallCount, 0, "fields() method not called"); -assert.sameValue(calendar2.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar2.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar2.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-temporal-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-temporal-object.js index d7ddb80b70d..256d744ad40 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-temporal-object.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/calendar-temporal-object.js @@ -21,6 +21,6 @@ features: [Temporal] ---*/ TemporalHelpers.checkToTemporalCalendarFastPath((temporalObject) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", temporalObject); + const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); datetime.until({ year: 2005, month: 6, day: 2, timeZone: "UTC", calendar: temporalObject }); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/constructor-in-calendar-fields.js deleted file mode 100644 index 7bc0a72b863..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/constructor-in-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/date-and-time-durations-opposite-signs.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/date-and-time-durations-opposite-signs.js deleted file mode 100644 index 7e46afae635..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/date-and-time-durations-opposite-signs.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Rounding calculation in difference method can result in duration date and - time components with opposite signs -info: | - DifferenceTemporalZonedDateTime ( operation, zonedDateTime, other, options ) - 17. If _roundingGranularityIsNoop_ is *false*, then - ... - e. Let _adjustResult_ be ? AdjustRoundedDurationDays(_roundResult_.[[Years]], _roundResult_.[[Months]], - _roundResult_.[[Weeks]], _days_, _daysResult_.[[NormalizedTime]], _settings_.[[RoundingIncrement]], - _settings_.[[SmallestUnit]], _settings_.[[RoundingMode]], _zonedDateTime_, _calendarRec_, _timeZoneRec_, - _precalculatedPlainDateTime_). - f. Let _balanceResult_ be ? BalanceDateDurationRelative(_adjustResult_.[[Years]], _adjustResult_.[[Months]], - _adjustResult_.[[Weeks]], _adjustResult_.[[Days]], _settings_.[[LargestUnit]], _settings_.[[SmallestUnit]], - _plainRelativeTo_, _calendarRec_). - g. Set _result_ to ? CombineDateAndNormalizedTimeDuration(_balanceResult_, _adjustResult_.[[NormalizedTime]]). -features: [Temporal] ----*/ - -// Based on a test case by André Bargull - -const calendar = new class extends Temporal.Calendar { - dateUntil(one, two, options) { - return super.dateUntil(one, two, options).negated(); - } -}("iso8601"); - -const oneDay = 86400_000_000_000; -const start = new Temporal.ZonedDateTime(0n, "UTC", calendar); -const end = new Temporal.ZonedDateTime(BigInt(500.5 * oneDay), "UTC", calendar); - -assert.throws(RangeError, () => start.until(end, { - largestUnit: "years", - smallestUnit: "hours", -})); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/differencezoneddatetime-inconsistent-custom-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/differencezoneddatetime-inconsistent-custom-calendar.js deleted file mode 100644 index de60e3c21c5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/differencezoneddatetime-inconsistent-custom-calendar.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Throws a RangeError when custom calendar method returns inconsistent result -info: | - DifferenceZonedDateTime ( ... ) - 8. Repeat 3 times: - ... - g. If _sign_ = 0, or _timeSign_ = 0, or _sign_ = _timeSign_, then - ... - viii. Return ? CreateNormalizedDurationRecord(_dateDifference_.[[Years]], - _dateDifference_.[[Months]], _dateDifference_.[[Weeks]], - _dateDifference_.[[Days]], _norm_). - h. Set _dayCorrection_ to _dayCorrection_ + 1. - 9. NOTE: This step is only reached when custom calendar or time zone methods - return inconsistent values. - 10. Throw a *RangeError* exception. -features: [Temporal] ----*/ - -// Based partly on a test case by André Bargull - -const fiftyDays12Hours = 50n * 86400_000_000_000n + 12n * 3600_000_000_000n; - -{ - const tz = new (class extends Temporal.TimeZone { - getPossibleInstantsFor(dateTime) { - return super.getPossibleInstantsFor(dateTime.add({ days: 3 })); - } - })("UTC"); - - const zdt1 = new Temporal.ZonedDateTime(0n, tz); - const zdt2 = new Temporal.ZonedDateTime(fiftyDays12Hours, tz); - - assert.throws(RangeError, () => zdt1.until(zdt2, { largestUnit: "weeks" }), - "Calendar calculation where more than 2 days correction is needed should cause RangeError"); -} - -{ - const cal = new (class extends Temporal.Calendar { - dateUntil(one, two, options) { - return super.dateUntil(one, two, options).negated(); - } - })("iso8601"); - - const zdt1 = new Temporal.ZonedDateTime(0n, "UTC", cal); - const zdt2 = new Temporal.ZonedDateTime(fiftyDays12Hours, "UTC", cal); - - assert.throws(RangeError, () => zdt1.until(zdt2, { largestUnit: "weeks" }), - "Calendar calculation causing mixed-sign values should cause RangeError"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-balancing-result.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-balancing-result.js deleted file mode 100644 index 0bdf261f09d..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-balancing-result.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Balancing the resulting duration takes the time zone's UTC offset shifts - into account -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -// Based on a test case by Adam Shaw -{ - const start = new Temporal.ZonedDateTime( - 941184000_000_000_000n /* = 1999-10-29T08Z */, - timeZone); /* = 1999-10-29T00-08 in local time */ - const end = new Temporal.ZonedDateTime( - 972889200_000_000_000n /* = 2000-10-30T07Z */, - timeZone); /* = 2000-10-29T23-08 in local time */ - - const duration = start.until(end, { largestUnit: "years" }); - TemporalHelpers.assertDuration(duration, 1, 0, 0, 0, 24, 0, 0, 0, 0, 0, - "24 hours does not balance to 1 day in 25-hour day"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-month-day-boundary.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-month-day-boundary.js deleted file mode 100644 index dcb2d20c343..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-month-day-boundary.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Difference with the endpoint being the end of a skipped hour, chooses the - smaller of two possible durations -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// Based on a test case by Adam Shaw - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -const d1 = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00-07:00 */, timeZone); -const d2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T03:00-07:00 */, timeZone); -// NOTE: nonexistent hour just before d2 - -const result = d1.until(d2, { largestUnit: "months" }); - -TemporalHelpers.assertDuration( - result, 0, 0, 0, -29, -23, 0, 0, 0, 0, 0, - "Result should not balance up to months, but pick the smaller of two possible durations" -); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-rounding-result.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-rounding-result.js deleted file mode 100644 index 86323f27f10..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/dst-rounding-result.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Rounding the resulting duration takes the time zone's UTC offset shifts - into account -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// Based on a test case by Adam Shaw - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -{ - // Month-only part of duration lands on skipped DST hour, should not cause - // disambiguation - const start = new Temporal.ZonedDateTime( - 950868000_000_000_000n /* = 2000-02-18T10Z */, - timeZone); /* = 2000-02-18T02-08 in local time */ - const end = new Temporal.ZonedDateTime( - 954709200_000_000_000n /* = 2000-04-02T21Z */, - timeZone); /* = 2000-04-02T14-07 in local time */ - - const duration = start.until(end, { largestUnit: "months" }); - TemporalHelpers.assertDuration(duration, 0, 1, 0, 15, 11, 0, 0, 0, 0, 0, - "1-month rounding window is shortened by DST"); -} - - -{ - // Month-only part of duration lands on skipped DST hour, should not cause - // disambiguation - const start = new Temporal.ZonedDateTime( - 951991200_000_000_000n /* = 2000-03-02T10Z */, - timeZone); /* = 2000-03-02T02-08 in local time */ - const end = new Temporal.ZonedDateTime( - 956005200_000_000_000n /* = 2000-04-17T21Z */, - timeZone); /* = 2000-04-17T14-07 in local time */ - - const duration = start.until(end, { largestUnit: "months" }); - TemporalHelpers.assertDuration(duration, 0, 1, 0, 15, 12, 0, 0, 0, 0, 0, - "1-month rounding window is not shortened by DST"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/duplicate-calendar-fields.js deleted file mode 100644 index a84eba429d1..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/duplicate-calendar-fields.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['monthCode'], ['nanosecond'], ['second'], ['year'], ['timeZone'], ['offset']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const timeZone = 'Europe/Paris' - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; - const instance = new Temporal.ZonedDateTime(0n, timeZone); - - assert.throws(RangeError, () => instance.until(arg)); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/find-intermediate-instant.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/find-intermediate-instant.js deleted file mode 100644 index ee751a9152e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/find-intermediate-instant.js +++ /dev/null @@ -1,82 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - Up to 3 intermediate instants may be tried when calculating ZonedDateTime - difference -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Temporal] ----*/ - -const calls = []; - -const springFallZone = TemporalHelpers.springForwardFallBackTimeZone(); -TemporalHelpers.observeMethod(calls, springFallZone, "getPossibleInstantsFor"); - -const dateLineZone = TemporalHelpers.crossDateLineTimeZone(); -TemporalHelpers.observeMethod(calls, dateLineZone, "getPossibleInstantsFor"); - -const zdt1 = new Temporal.ZonedDateTime(946722600_000_000_000n /* = 2000-01-01T02:30 local */, springFallZone); - -// Past -> future, without wall-clock overshoot -// Expects valid intermediate Instant WITHOUT day correction (computed once) -{ - const zdt2 = new Temporal.ZonedDateTime(949442400_000_000_000n /* = 2000-02-01T14:00 local */, springFallZone); - const result = zdt1.until(zdt2, { largestUnit: "years" }); - TemporalHelpers.assertDuration(result, 0, 1, 0, 0, 11, 30, 0, 0, 0, 0, "no wall-clock overshoot, no DST"); - assert.compareArray(calls, [ - "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime - ], "one intermediate should be tried"); -} - -calls.splice(0); // clear - -// Past -> future, WITH wall-clock overshoot -// Expects valid intermediate Instant with guaranteed 1-DAY correction (computed once) -{ - const zdt2 = new Temporal.ZonedDateTime(949395600_000_000_000n /* = 2000-02-01T01:00 local */, springFallZone); - const result = zdt1.until(zdt2, { largestUnit: "years" }); - TemporalHelpers.assertDuration(result, 0, 0, 0, 30, 22, 30, 0, 0, 0, 0, "wall-clock overshoot, no DST"); - assert.compareArray(calls, [ - "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime - ], "one intermediate should be tried"); -} - -calls.splice(0); // clear - -// Past -> future, WITH wall-clock overshoot -// Tries intermediate Instant with 1-DAY correction (first compute) -// Then, ANOTHER correction because updated intermediate Instant falls within spring DST gap, -// pushing it forward, causing wall-clock overshoot again -// (Not possible when going backwards) -{ - const zdt2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T02:00 local */, springFallZone); - const result = zdt1.until(zdt2, { largestUnit: "years" }); - TemporalHelpers.assertDuration(result, 0, 3, 0, 0, 23, 30, 0, 0, 0, 0, "wall-clock overshoot, small consiquential DST"); - assert.compareArray(calls, [ - "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime - "call getPossibleInstantsFor", // DisambiguatePossibleInstants on first intermediate - "call getPossibleInstantsFor", // second intermediate in DifferenceZonedDateTime - ], "two intermediates should be tried, with disambiguation"); -} - -calls.splice(0); // clear - -// Past -> future, WITH wall-clock overshoot -// Tries intermediate Instant with 1-DAY correction (first compute) -// Then, ANOTHER correction because updated intermediate Instant falls within dateline DST gap, -// pushing it forward, causing wall-clock overshoot again -// (Not possible when going backwards) -// (This test is just the same as the corresponding one in since(), but negative) -{ - const start = new Temporal.ZonedDateTime(1325102400_000_000_000n /* = 2011-12-28T10:00 local */, dateLineZone); - const end = new Temporal.ZonedDateTime(1325257200_000_000_000n /* = 2011-12-31T05:00 local */, dateLineZone); - const result = start.until(end, { largestUnit: "days" }); - TemporalHelpers.assertDuration(result, 0, 0, 0, 1, 19, 0, 0, 0, 0, 0, "wall-clock overshoot, big consiquential DST"); - assert.compareArray(calls, [ - "call getPossibleInstantsFor", // first intermediate in DifferenceZonedDateTime - "call getPossibleInstantsFor", // second intermediate in DifferenceZonedDateTime - "call getPossibleInstantsFor", // DisambiguatePossibleInstants on second intermediate - ], "two intermediates should be tried, with disambiguation"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/leap-second.js index ffa342eff00..4517b535df4 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/leap-second.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(1_483_228_799_000_000_000n, timeZone); let arg = "2016-12-31T23:59:60+00:00[UTC]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js index db70d404853..2000935c74a 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/order-of-operations.js @@ -11,30 +11,6 @@ features: [Temporal] const expected = [ // ToTemporalZonedDateTime "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.dateFromFields", - "get other.calendar.fields", - "call other.calendar.fields", "get other.day", "get other.day.valueOf", "call other.day.valueOf", @@ -69,56 +45,23 @@ const expected = [ "get other.year", "get other.year.valueOf", "call other.year.valueOf", - "has other.timeZone.getOffsetNanosecondsFor", - "has other.timeZone.getPossibleInstantsFor", - "has other.timeZone.id", - "call other.calendar.dateFromFields", - "get other.timeZone.getOffsetNanosecondsFor", - "get other.timeZone.getPossibleInstantsFor", - "call other.timeZone.getPossibleInstantsFor", - "call other.timeZone.getOffsetNanosecondsFor", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", // GetDifferenceSettings + "get options.largestUnit", "get options.largestUnit.toString", "call options.largestUnit.toString", + "get options.roundingIncrement", "get options.roundingIncrement.valueOf", "call options.roundingIncrement.valueOf", + "get options.roundingMode", "get options.roundingMode.toString", "call options.roundingMode.toString", + "get options.smallestUnit", "get options.smallestUnit.toString", "call options.smallestUnit.toString", ]; const actual = []; -const ownTimeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const ownCalendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, ownTimeZone, ownCalendar); - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const ownDstTimeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); -const otherDstTimeZone = TemporalHelpers.timeZoneObserver(actual, "other.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); -/* 2000-10-29T01:30-07:00, in the middle of the first repeated hour: */ -const fallBackInstance = new Temporal.ZonedDateTime(972808200_000_000_000n, ownDstTimeZone, ownCalendar); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { year: 2004, @@ -132,14 +75,12 @@ const otherDateTimePropertyBag = TemporalHelpers.propertyBagObserver(actual, { microsecond: 500, nanosecond: 750, offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"), -}, "other"); + calendar: "iso8601", + timeZone: "UTC", +}, "other", ["calendar", "timeZone"]); function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "auto", roundingMode = "halfExpand", roundingIncrement = 1 } = {}) { return TemporalHelpers.propertyBagObserver(actual, { - // order is significant, due to iterating through properties in order to - // copy them to an internal null-prototype object: roundingIncrement, roundingMode, largestUnit, @@ -148,220 +89,7 @@ function createOptionsObserver({ smallestUnit = "nanoseconds", largestUnit = "au }, "options"); } -// clear any observable things that happened while constructing the objects -actual.splice(0); - // basic order of observable operations, without rounding: instance.until(otherDateTimePropertyBag, createOptionsObserver()); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -// short-circuit for identical objects will still test TimeZoneEquals if -// largestUnit is a calendar unit: -const identicalPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2001, - month: 9, - monthCode: "M09", - day: 9, - hour: 1, - minute: 46, - second: 40, - millisecond: 0, - microsecond: 0, - nanosecond: 0, - offset: "+00:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: TemporalHelpers.timeZoneObserver(actual, "other.timeZone"), -}, "other"); - -instance.until(identicalPropertyBag, createOptionsObserver({ largestUnit: "years" })); -assert.compareArray(actual, expected.concat([ - "get this.timeZone.id", - "get other.timeZone.id", -]), "order of operations with identical dates and largestUnit a calendar unit"); -actual.splice(0); // clear - -// two ZonedDateTimes that denote the same wall-clock time in the time zone can -// avoid calling some calendar methods: -const fallBackPropertyBag = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 10, - monthCode: "M10", - day: 29, - hour: 1, - minute: 30, - second: 0, - millisecond: 0, - microsecond: 0, - nanosecond: 0, - offset: "-08:00", - calendar: TemporalHelpers.calendarObserver(actual, "other.calendar"), - timeZone: otherDstTimeZone, -}, "other"); -fallBackInstance.until(fallBackPropertyBag, createOptionsObserver({ largestUnit: "days" })); -assert.compareArray(actual, [ - // ToTemporalZonedDateTime - "get other.calendar", - "has other.calendar.dateAdd", - "has other.calendar.dateFromFields", - "has other.calendar.dateUntil", - "has other.calendar.day", - "has other.calendar.dayOfWeek", - "has other.calendar.dayOfYear", - "has other.calendar.daysInMonth", - "has other.calendar.daysInWeek", - "has other.calendar.daysInYear", - "has other.calendar.fields", - "has other.calendar.id", - "has other.calendar.inLeapYear", - "has other.calendar.mergeFields", - "has other.calendar.month", - "has other.calendar.monthCode", - "has other.calendar.monthDayFromFields", - "has other.calendar.monthsInYear", - "has other.calendar.weekOfYear", - "has other.calendar.year", - "has other.calendar.yearMonthFromFields", - "has other.calendar.yearOfWeek", - "get other.calendar.dateFromFields", - "get other.calendar.fields", - "call other.calendar.fields", - "get other.day", - "get other.day.valueOf", - "call other.day.valueOf", - "get other.hour", - "get other.hour.valueOf", - "call other.hour.valueOf", - "get other.microsecond", - "get other.microsecond.valueOf", - "call other.microsecond.valueOf", - "get other.millisecond", - "get other.millisecond.valueOf", - "call other.millisecond.valueOf", - "get other.minute", - "get other.minute.valueOf", - "call other.minute.valueOf", - "get other.month", - "get other.month.valueOf", - "call other.month.valueOf", - "get other.monthCode", - "get other.monthCode.toString", - "call other.monthCode.toString", - "get other.nanosecond", - "get other.nanosecond.valueOf", - "call other.nanosecond.valueOf", - "get other.offset", - "get other.offset.toString", - "call other.offset.toString", - "get other.second", - "get other.second.valueOf", - "call other.second.valueOf", - "get other.timeZone", - "get other.year", - "get other.year.valueOf", - "call other.year.valueOf", - "has other.timeZone.getOffsetNanosecondsFor", - "has other.timeZone.getPossibleInstantsFor", - "has other.timeZone.id", - "call other.calendar.dateFromFields", - "get other.timeZone.getOffsetNanosecondsFor", - "get other.timeZone.getPossibleInstantsFor", - "call other.timeZone.getPossibleInstantsFor", - "call other.timeZone.getOffsetNanosecondsFor", - // NOTE: extra because of wall-clock time ambiguity: - "call other.timeZone.getOffsetNanosecondsFor", - // CalendarEquals - "get this.calendar.id", - "get other.calendar.id", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.roundingIncrement", - "get options.roundingIncrement", - "getOwnPropertyDescriptor options.roundingMode", - "get options.roundingMode", - "getOwnPropertyDescriptor options.largestUnit", - "get options.largestUnit", - "getOwnPropertyDescriptor options.smallestUnit", - "get options.smallestUnit", - "getOwnPropertyDescriptor options.additional", - "get options.additional", - // GetDifferenceSettings - "get options.largestUnit.toString", - "call options.largestUnit.toString", - "get options.roundingIncrement.valueOf", - "call options.roundingIncrement.valueOf", - "get options.roundingMode.toString", - "call options.roundingMode.toString", - "get options.smallestUnit.toString", - "call options.smallestUnit.toString", - // TimeZoneEquals - "get this.timeZone.id", - "get other.timeZone.id", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // DifferenceZonedDateTime - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", -], "order of operations with identical wall-clock times and largestUnit a calendar unit"); -actual.splice(0); // clear - -// Making largestUnit a calendar unit adds the following observable operations: -const expectedOpsForCalendarDifference = [ - // TimeZoneEquals - "get this.timeZone.id", - "get other.timeZone.id", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - "get this.calendar.dateAdd", - "get this.calendar.dateUntil", - // precalculate PlainDateTime - "call this.timeZone.getOffsetNanosecondsFor", - // DifferenceZonedDateTime - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", - "call this.calendar.dateUntil", -]; - -const expectedOpsForCalendarRounding = expected.concat(expectedOpsForCalendarDifference, [ - // RoundRelativeDuration - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", - "call this.timeZone.getPossibleInstantsFor", - "call this.timeZone.getPossibleInstantsFor", -]); - -// code path that skips RoundRelativeDuration: -instance.until(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "years", smallestUnit: "nanoseconds", roundingIncrement: 1 })); -assert.compareArray(actual, expected.concat(expectedOpsForCalendarDifference), "order of operations with largestUnit years and no rounding"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest year: -instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "years" })); -assert.compareArray(actual, expectedOpsForCalendarRounding, "order of operations with smallestUnit = years"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest month: -instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "months" })); -assert.compareArray(actual, expectedOpsForCalendarRounding, "order of operations with smallestUnit = months"); -actual.splice(0); // clear - -// code path through RoundRelativeDuration that rounds to the nearest week: -instance.until(otherDateTimePropertyBag, createOptionsObserver({ smallestUnit: "weeks" })); -assert.compareArray(actual, expected.concat(expectedOpsForCalendarDifference, [ - // RoundRelativeDuration - "call this.calendar.dateUntil", - "call this.calendar.dateAdd", - "call this.calendar.dateAdd", - "call this.timeZone.getPossibleInstantsFor", - "call this.timeZone.getPossibleInstantsFor", -]), "order of operations with smallestUnit = weeks"); -actual.splice(0); // clear - -instance.until(otherDateTimePropertyBag, createOptionsObserver({ largestUnit: "hours" })); -assert.compareArray(actual, expected, "order of operations with largestUnit being a time unit"); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/proto-in-calendar-fields.js deleted file mode 100644 index 1ed94b4b878..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/proto-in-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const timeZone = 'Europe/Paris' -const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar, timeZone: timeZone }; -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -assert.throws(RangeError, () => instance.until(arg)); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/read-time-fields-before-datefromfields.js deleted file mode 100644 index 5a7001a01c7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.zoneddatetime.prototype.until step 3: - 3. Set _other_ to ? ToTemporalZonedDateTime(_other_). - sec-temporal-totemporalzoneddatetime step 2.e: - e. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); -const duration = datetime.until({ year: 2001, month: 9, day: 9, timeZone: "UTC", calendar }); - -TemporalHelpers.assertDuration(duration, 0, 0, 0, 0, -1, -46, -40, -987, -654, -321); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/rounding-zero-year-month-week-length.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/rounding-zero-year-month-week-length.js deleted file mode 100644 index c76ddc097b6..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/rounding-zero-year-month-week-length.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: > - A malicious calendar resulting in a year, month, or week length of zero is - handled correctly -info: | - RoundDuration - 10.z. If _oneYearDays_ = 0, throw a *RangeError* exception. - ... - 11.z. If _oneMonthDays_ = 0, throw a *RangeError* exception. - ... - 12.s. If _oneWeekDays_ = 0, throw a *RangeError* exception. -features: [Temporal] ----*/ - -const cal = new class extends Temporal.Calendar { - dateAdd(date, duration, options) { - // Called several times, last call sets oneYear/Month/WeekDays to 0 - return new Temporal.PlainDate(1970, 1, 1); - } -}("iso8601"); - -const dt1 = new Temporal.ZonedDateTime(0n, "UTC", cal); -const dt2 = new Temporal.ZonedDateTime(365n * 86400_000_000_000n + 1n, "UTC", cal); - -assert.throws(RangeError, () => dt1.until(dt2, { smallestUnit: "years" }), "zero year length handled correctly"); -assert.throws(RangeError, () => dt1.until(dt2, { smallestUnit: "months" }), "zero month length handled correctly"); -assert.throws(RangeError, () => dt1.until(dt2, { smallestUnit: "weeks" }), "zero week length handled correctly"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 5a7f0527caf..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const other = new Temporal.ZonedDateTime(1_100_000_000_123_456_789n, timeZone); - assert.throws(RangeError, () => datetime.until(other, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 2fc554149a8..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const other = new Temporal.ZonedDateTime(1_100_000_000_123_456_789n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.until(other, { largestUnit: "days" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 10ae13d6763..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const other = new Temporal.ZonedDateTime(1_100_000_000_123_456_789n, timeZone); - assert.throws(RangeError, () => datetime.until(other, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index fd51309e238..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const other = new Temporal.ZonedDateTime(1_100_000_000_123_456_789n, timeZone); - assert.throws(TypeError, () => datetime.until(other, { largestUnit: "days" })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index bed8dcd2be8..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.until -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.zoneddatetime.prototype.until step 3: - 3. Set _other_ to ? ToTemporalZonedDateTime(_other_). - sec-temporal-totemporalzoneddatetime step 7: - 7. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_result_.[[Year]], [...], _result_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, _disambiguation_, _offset_). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// Not called on the instance's time zone - -const expected1 = []; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - datetime.until({ year: 2005, month: 6, day: 2, timeZone: "UTC" }); -}, expected1); - -// Called on the argument's time zone - -const expected2 = [ - "2005-06-02T00:00:00", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); - datetime.until({ year: 2005, month: 6, day: 2, timeZone }); -}, expected2); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js index fb6e140e22a..5fcece628f0 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/year-zero.js @@ -12,7 +12,7 @@ const invalidStrings = [ "-0000000-01-01T00:02+00:00[UTC]", "-0000000-01-01T00:02:00.000000000+00:00[UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js index 6330d8710b0..988ade63ceb 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string-multiple-offsets.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("+01:35"); +const timeZone = "+01:35"; const instance = new Temporal.ZonedDateTime(0n, timeZone); let str = "1970-01-01T01:35:30+01:35:00.000000000[+01:35]"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string.js index 1cf959aa4e1..25e392b676e 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/zoneddatetime-string.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); let str = "1970-01-01T00:00"; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 6b49dbdd538..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.weekofyear -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const weekOfYearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "weekOfYear"); -Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("weekOfYear should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.weekOfYear; - -Object.defineProperty(Temporal.Calendar.prototype, "weekOfYear", weekOfYearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 249c94c771a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.weekofyear -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.weekOfYear; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js deleted file mode 100644 index ed8df20d109..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom-calendar-weekofyear.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.weekofyear -description: > - Temporal.ZonedDateTime.prototype.weekOfYear returns undefined for all - custom calendars where weekOfYear() returns undefined. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - weekOfYear() { - return undefined; - } -} - -const calendar = new CustomCalendar(); -// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); -const customCalendarDate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); -assert.sameValue(customCalendarDate.weekOfYear, undefined); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom.js deleted file mode 100644 index 6d71e760fb1..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.weekofyear -description: Custom calendar tests for weekOfYear(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - weekOfYear(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "weekOfYear arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.weekOfYear; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index da2d1a9c024..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.weekofyear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.weekOfYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index ab254032798..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.weekofyear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.weekOfYear, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index fe436c85261..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.weekofyear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.weekOfYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index cef077319eb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.weekofyear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.weekOfYear); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/validate-calendar-value.js deleted file mode 100644 index fe3ba667d7c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/validate-calendar-value.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.weekofyear -description: Validate result returned from calendar weekOfYear() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-7, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - weekOfYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.weekOfYear, `${typeof result} ${String(result)} not converted to positive integer`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/balance-negative-time-units.js deleted file mode 100644 index 7903a25e68f..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/balance-negative-time-units.js +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: Negative time fields are balanced upwards -info: | - sec-temporal-balancetime steps 3–14: - 3. Set _microsecond_ to _microsecond_ + floor(_nanosecond_ / 1000). - 4. Set _nanosecond_ to _nanosecond_ modulo 1000. - 5. Set _millisecond_ to _millisecond_ + floor(_microsecond_ / 1000). - 6. Set _microsecond_ to _microsecond_ modulo 1000. - 7. Set _second_ to _second_ + floor(_millisecond_ / 1000). - 8. Set _millisecond_ to _millisecond_ modulo 1000. - 9. Set _minute_ to _minute_ + floor(_second_ / 60). - 10. Set _second_ to _second_ modulo 60. - 11. Set _hour_ to _hour_ + floor(_minute_ / 60). - 12. Set _minute_ to _minute_ modulo 60. - 13. Let _days_ be floor(_hour_ / 24). - 14. Set _hour_ to _hour_ modulo 24. - sec-temporal-addtime step 8: - 8. Return ? BalanceTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_). - sec-temporal-adddatetime step 1: - 1. Let _timeResult_ be ? AddTime(_hour_, _minute_, _second_, _millisecond_, _microsecond_, _nanosecond_, _hours_, _minutes_, _seconds_, _milliseconds_, _microseconds_, _nanoseconds_). - sec-temporal-builtintimezonegetinstantfor step 13.a: - a. Let _earlier_ be ? AddDateTime(_dateTime_.[[ISOYear]], _dateTime_.[[ISOMonth]], _dateTime_.[[ISODay]], _dateTime_.[[ISOHour]], _dateTime_.[[ISOMinute]], _dateTime_.[[ISOSecond]], _dateTime_.[[ISOMillisecond]], _dateTime_.[[ISOMicrosecond]], _dateTime_.[[ISONanosecond]], 0, 0, 0, 0, 0, 0, 0, 0, 0, −_nanoseconds_, *"constrain"*). - sec-temporal-interpretisodatetimeoffset steps 4–10: - 4. If _offsetNanoseconds_ is *null*, or _offset_ is *"ignore"*, then - a. Let _instant_ be ? BuiltinTimeZoneGetInstantFor(_timeZone_, _dateTime_, _disambiguation_). - ... - ... - 6. Assert: _offset_ is *"prefer"* or *"reject"*. - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - ... - 9. If _offset_ is *"reject"*, throw a *RangeError* exception. - 10. Let _instant_ be ? DisambiguatePossibleInstants(_possibleInstants_, _timeZone_, _dateTime_, _disambiguation_). - sec-temporal.zoneddatetime.prototype.with step 26: - 26. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_dateTimeResult_.[[Year]], _dateTimeResult_.[[Month]], _dateTimeResult_.[[Day]], _dateTimeResult_.[[Hour]], _dateTimeResult_.[[Minute]], _dateTimeResult_.[[Second]], _dateTimeResult_.[[Millisecond]], _dateTimeResult_.[[Microsecond]], _dateTimeResult_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, _disambiguation_, _offset_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const shiftInstant = new Temporal.Instant(3661_001_001_001n); -const tz1 = TemporalHelpers.oneShiftTimeZone(shiftInstant, 2); -const datetime1 = new Temporal.ZonedDateTime(3661_001_001_000n, tz1); - -// This code path is encountered if offset is `ignore` or `prefer`, -// disambiguation is `earlier` and the shift is a spring-forward change -datetime1.with({ nanosecond: 1 }, { offset: "ignore", disambiguation: "earlier" }); - -const expected = [ - "1970-01-01T01:01:01.001001001", - "1970-01-01T01:01:01.001000999", -]; -assert.compareArray(tz1.getPossibleInstantsForCalledWith, expected); - -const tz2 = TemporalHelpers.oneShiftTimeZone(shiftInstant, 2); -const datetime2 = new Temporal.ZonedDateTime(3661_001_001_000n, tz2); - -datetime2.with({ nanosecond: 1 }, { offset: "prefer", disambiguation: "earlier" }); - -assert.compareArray(tz2.getPossibleInstantsForCalledWith, expected); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-calendar-no-array-iteration.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-calendar-no-array-iteration.js deleted file mode 100644 index 66bd9416a5c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.with({ day: 5 }); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 18558046b7a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const fieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "fields"); -Object.defineProperty(Temporal.Calendar.prototype, "fields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("fields should not be looked up"); - }, -}); -const mergeFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "mergeFields"); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("mergeFields should not be looked up"); - }, -}); -const dateFromFieldsOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "dateFromFields"); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("dateFromFields should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.with({ year: 2001 }); - -Object.defineProperty(Temporal.Calendar.prototype, "fields", fieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "mergeFields", mergeFieldsOriginal); -Object.defineProperty(Temporal.Calendar.prototype, "dateFromFields", dateFromFieldsOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-timezone-no-observable-calls.js deleted file mode 100644 index ed8075079b0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.with({ year: 2001 }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-iterable.js deleted file mode 100644 index 84d15850cf8..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-iterable.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: Verify the result of calendar.fields() is treated correctly. -info: | - sec-temporal.zoneddatetime.prototype.with step 9: - 9. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - sec-temporal-calendarfields step 4: - 4. Let _result_ be ? IterableToList(_fieldsArray_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "day", - "month", - "monthCode", - "year", -]; - -const calendar = TemporalHelpers.calendarFieldsIterable(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -datetime.with({ year: 2005 }); - -assert.sameValue(calendar.fieldsCallCount, 1, "fields() method called once"); -assert.compareArray(calendar.fieldsCalledWith[0], expected, "fields() method called with correct args"); -assert(calendar.iteratorExhausted[0], "iterated through the whole iterable"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 5189c887bc2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.ZonedDateTime(0n, "UTC", calendar); -instance.with({ day: 24 }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-merge-fields-returns-primitive.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-merge-fields-returns-primitive.js deleted file mode 100644 index c6c2879ea3c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-merge-fields-returns-primitive.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - with() should throw a TypeError if mergeFields() returns a primitive, - without passing the value on to any other calendar methods -includes: [compareArray.js, temporalHelpers.js] -features: [BigInt, Symbol, Temporal] ----*/ - -[undefined, null, true, 3.14159, "bad value", Symbol("no"), 7n].forEach((primitive) => { - const calendar = TemporalHelpers.calendarMergeFieldsReturnsPrimitive(primitive); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(TypeError, () => instance.with({ year: 2005 }), "bad return from mergeFields() throws"); - assert.sameValue(calendar.dateFromFieldsCallCount, 0, "dateFromFields() never called"); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js deleted file mode 100644 index 88192d8a166..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-mergefields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - Calendar.mergeFields method is called with null-prototype fields objects -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckMergeFieldsPrototypePollution(); -const instance = new Temporal.ZonedDateTime(0n, "UTC", calendar); -instance.with({ day: 24 }); -assert.sameValue(calendar.mergeFieldsCallCount, 1, "mergeFields should have been called on the calendar"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-options.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-options.js deleted file mode 100644 index fba8b67aa32..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-options.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - The options argument is copied and the copy is passed to - Calendar#dateFromFields. -features: [Temporal] ----*/ - -const options = { - extra: "property", -}; -let calledDateFromFields = 0; -class Calendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - dateFromFields(fields, optionsArg) { - ++calledDateFromFields; - assert.notSameValue(optionsArg, options, "should pass copied options object"); - assert.sameValue(optionsArg.extra, "property", "should copy all properties from options object"); - assert.sameValue(Object.getPrototypeOf(optionsArg), null, "Copy has null prototype"); - return super.dateFromFields(fields, optionsArg); - } -}; -const calendar = new Calendar(); -const datetime = new Temporal.ZonedDateTime(0n, "UTC", calendar); -const result = datetime.with({ year: 1971 }, options); -assert.sameValue(result.epochNanoseconds, 365n * 86400_000_000_000n, "year changed from 1970 to 1971") -assert.sameValue(calledDateFromFields, 1, "should have called overridden dateFromFields once"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/constructor-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/constructor-in-calendar-fields.js deleted file mode 100644 index 904c2fb37b2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/constructor-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); - -assert.throws(RangeError, () => zoneddatetime.with({hour: 12})); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/copies-merge-fields-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/copies-merge-fields-object.js deleted file mode 100644 index 9edb5bba208..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/copies-merge-fields-object.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.plaindatetime.prototype.with -description: The object returned from mergeFields() is copied before being passed to dateFromFields(). -info: | - sec-temporal.plaindatetime.prototype.with steps 18–19 and 23: - 18. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialDate_). - 19. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, « *"timeZone"* »). - 23. Let _dateTimeResult_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields step 2: - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get day", - "get day.valueOf", - "call day.valueOf", - "get hour", - "get hour.valueOf", - "call hour.valueOf", - "get microsecond", - "get microsecond.valueOf", - "call microsecond.valueOf", - "get millisecond", - "get millisecond.valueOf", - "call millisecond.valueOf", - "get minute", - "get minute.valueOf", - "call minute.valueOf", - "get month", - "get month.valueOf", - "call month.valueOf", - "get monthCode", - "get monthCode.toString", - "call monthCode.toString", - "get nanosecond", - "get nanosecond.valueOf", - "call nanosecond.valueOf", - "get offset", - "get offset.toString", - "call offset.toString", - "get second", - "get second.valueOf", - "call second.valueOf", - "get year", - "get year.valueOf", - "call year.valueOf", -]; - -const calendar = TemporalHelpers.calendarMergeFieldsGetters(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -datetime.with({ year: 2022 }); - -assert.compareArray(calendar.mergeFieldsReturnOperations, expected, "getters called on mergeFields return"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/disambiguation-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/disambiguation-undefined.js deleted file mode 100644 index 028c38dbf5c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/disambiguation-undefined.js +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: Fallback value for disambiguation option -info: | - sec-getoption step 3: - 3. If _value_ is *undefined*, return _fallback_. - sec-temporal-totemporaldisambiguation step 1: - 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). - sec-temporal.zoneddatetime.protoype.with step 14: - 14. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const springForwardDatetime = new Temporal.ZonedDateTime(954702001_000_000_000n, timeZone); -const fallBackDatetime = new Temporal.ZonedDateTime(972849601_000_000_000n, timeZone); -const offset = "ignore"; - -[ - [springForwardDatetime, { hour: 2, minute: 30 }, 954671401_000_000_000n], - [fallBackDatetime, { hour: 1, minute: 30 }, 972808201_000_000_000n], -].forEach(([datetime, fields, expected]) => { - const explicit = datetime.with(fields, { offset, disambiguation: undefined }); - assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); - const implicit = datetime.with(fields, { offset }); - assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/duplicate-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/duplicate-calendar-fields.js deleted file mode 100644 index e8e2f345451..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/duplicate-calendar-fields.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['monthCode'], ['day'], ['hour'], ['microsecond'], ['millisecond'], ['minute'], ['month'], ['nanosecond'], ['second'], ['year'], ['offset']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); - - assert.throws(RangeError, () => zoneddatetime.with({hour: 12})); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index ba691f7bd37..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-maximum-forward-offset-shift.js +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants can be at most 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 0n; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - calls++; - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12 })]; - } -} - -const timeZone = new Shift24Hour(); -const instance = new Temporal.ZonedDateTime(0n, timeZone); - -for (const disambiguation of ["earlier", "later", "compatible"]) { - instance.with({ day: 1 }, { disambiguation }); - - assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); - calls = 0; -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js deleted file mode 100644 index 0ed37f0829b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 0n; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -for (const disambiguation of ["earlier", "later", "compatible"]) { - assert.throws(RangeError, () => instance.with({ day: 1 }, { disambiguation }), "RangeError should be thrown"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 6d81109ec26..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); - -for (const disambiguation of ["earlier", "later", "compatible"]) { - const timeZone = new SkippedDateTime(); - const instance = new Temporal.ZonedDateTime(0n, timeZone, nonBuiltinISOCalendar); - - instance.with({ day: 1 }, { disambiguation }); - - assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index 8f3e76d2271..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-maximum-backward-offset-shift.js +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - calls++; - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12 }), - utcInstant.add({ hours: 12 }) - ]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -for (const disambiguation of ["earlier", "later", "compatible"]) { - instance.with({ day: 1 }, { disambiguation }); - - assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); - calls = 0; -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index 2c25a7deb17..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/getpossibleinstantsfor-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -for (const disambiguation of ["earlier", "later", "compatible"]) { - assert.throws(RangeError, () => instance.with({ day: 1 }, { disambiguation }), "RangeError should be thrown"); -} diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-property-invalid-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-property-invalid-string.js index 432a00c5951..8d9bdb0f3bc 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-property-invalid-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-property-invalid-string.js @@ -7,8 +7,7 @@ description: Property bag with offset property is rejected if offset is in the w features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const offsetOptions = ['use', 'prefer', 'ignore', 'reject']; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-undefined.js index f1b6b8423e3..0d96c9aacc6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-undefined.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/offset-undefined.js @@ -14,9 +14,7 @@ info: | features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("-03:30"); - -const datetime = new Temporal.ZonedDateTime(1572757201_000_000_000n, timeZone); +const datetime = new Temporal.ZonedDateTime(1572757201_000_000_000n, "-03:30"); const explicit = datetime.with({ minute: 31 }, { offset: undefined }); assert.sameValue(explicit.epochNanoseconds, 1572757261_000_000_000n, "default offset is prefer"); const implicit = datetime.with({ minute: 31 }, {}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/order-of-operations.js index ea2f9178e37..cdf1f5dda27 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/order-of-operations.js @@ -12,36 +12,6 @@ const expected = [ // RejectObjectWithCalendarOrTimeZone "get fields.calendar", "get fields.timeZone", - // CopyDataProperties - "ownKeys options", - "getOwnPropertyDescriptor options.overflow", - "get options.overflow", - "getOwnPropertyDescriptor options.disambiguation", - "get options.disambiguation", - "getOwnPropertyDescriptor options.offset", - "get options.offset", - "getOwnPropertyDescriptor options.extra", - "get options.extra", - // lookup - "get this.calendar.dateFromFields", - "get this.calendar.fields", - "get this.calendar.mergeFields", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - // GetOffsetNanosecondsFor on receiver - "call this.timeZone.getOffsetNanosecondsFor", - // CalendarFields - "call this.calendar.fields", - // PrepareTemporalFields on receiver - "get this.calendar.day", - "call this.calendar.day", - "get this.calendar.month", - "call this.calendar.month", - "get this.calendar.monthCode", - "call this.calendar.monthCode", - "get this.calendar.year", - "call this.calendar.year", // PrepareTemporalFields on argument "get fields.day", "get fields.day.valueOf", @@ -76,27 +46,22 @@ const expected = [ "get fields.year", "get fields.year.valueOf", "call fields.year.valueOf", - // CalendarMergeFields - "call this.calendar.mergeFields", - // InterpretTemporalDateTimeFields + // GetTemporalDisambiguationOption + "get options.disambiguation", "get options.disambiguation.toString", "call options.disambiguation.toString", + // GetTemporalOffsetOption + "get options.offset", "get options.offset.toString", "call options.offset.toString", + // GetTemporalOverflowOption + "get options.overflow", "get options.overflow.toString", "call options.overflow.toString", - "call this.calendar.dateFromFields", - // InterpretISODateTimeOffset - "call this.timeZone.getPossibleInstantsFor", - "call this.timeZone.getOffsetNanosecondsFor", ]; const actual = []; -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone"); -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const instance = new Temporal.ZonedDateTime(0n, timeZone, calendar); -// clear observable operations that occurred during the constructor call -actual.splice(0); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const fields = TemporalHelpers.propertyBagObserver(actual, { year: 1.7, @@ -122,53 +87,3 @@ const options = TemporalHelpers.propertyBagObserver(actual, { instance.with(fields, options); assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear - -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const dstTimeZoneObserver = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); - -const dstInstance = new Temporal.ZonedDateTime(37800_000_000_000n /* 1970-01-01T02:30-08:00 */, dstTimeZoneObserver, calendar); -actual.splice(0); // clear calls that happened in constructor - -const fallBackFields = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 10, - monthCode: "M10", - day: 29, - hour: 1, - minute: 30, - second: 0, - millisecond: 0, - microsecond: 0, - nanosecond: 0, - offset: "+00:00", // ignored -}, "fields"); -dstInstance.with(fallBackFields, options); -assert.compareArray(actual, expected.concat([ - // extra call in InterpretISODateTimeOffset - "call this.timeZone.getOffsetNanosecondsFor", -]), "order of operations at repeated wall-clock time"); -actual.splice(0); // clear - -const springForwardFields = TemporalHelpers.propertyBagObserver(actual, { - year: 2000, - month: 4, - monthCode: "M04", - day: 2, - hour: 2, - minute: 30, - second: 0, - millisecond: 0, - microsecond: 0, - nanosecond: 0, - offset: "+00:00", // ignored -}, "fields"); -dstInstance.with(springForwardFields, options); -assert.compareArray(actual, expected.concat([ - // DisambiguatePossibleInstants - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", -]), "order of operations at skipped wall-clock time"); -actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/proto-in-calendar-fields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/proto-in-calendar-fields.js deleted file mode 100644 index 7a5e30265a2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/proto-in-calendar-fields.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const zoneddatetime = new Temporal.ZonedDateTime(1682892000000000000n, 'Europe/Madrid', calendar); - -assert.throws(RangeError, () => zoneddatetime.with({hour: 12})); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/read-time-fields-before-datefromfields.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/read-time-fields-before-datefromfields.js deleted file mode 100644 index 9f20ae7fa11..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/read-time-fields-before-datefromfields.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: The time fields are read from the object before being passed to dateFromFields(). -info: | - sec-temporal.zoneddatetime.prototype.with step 23: - 23. Let _dateTimeResult_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_). - sec-temporal-interprettemporaldatetimefields steps 1–2: - 1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_). - 2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarMakeInfinityTime(); -const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", calendar); -const newDatetime = datetime.with({ year: 2022 }); - -assert.sameValue(newDatetime.hour, 1, "hour value"); -assert.sameValue(newDatetime.minute, 46, "minute value"); -assert.sameValue(newDatetime.second, 40, "second value"); -assert.sameValue(newDatetime.millisecond, 987, "millisecond value"); -assert.sameValue(newDatetime.microsecond, 654, "microsecond value"); -assert.sameValue(newDatetime.nanosecond, 321, "nanosecond value"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken.js deleted file mode 100644 index bddf9340edf..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/receiver-offset-broken.js +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.protoype.with -description: > - TypeError thrown when the offset field of the argument or the object returned - from mergeFields is broken -info: | - 7. Let _fieldNames_ be ? CalendarFields(_calendar_, « *"day"*, *"month"*, *"monthCode"*, *"year"* »). - 8. Append *"hour"*, *"microsecond"*, *"millisecond"*, *"minute"*, *"nanosecond"*, *"offset"*, and *"second"* to _fieldNames_. - 9. Let _fields_ be ? PrepareTemporalFields(_zonedDateTime_, _fieldNames_, « *"offset"* »). - 10. Let _partialZonedDateTime_ be ? PrepareTemporalFields(_temporalZonedDateTimeLike_, _fieldNames_, ~partial~). - 11. Set _fields_ to ? CalendarMergeFields(_calendar_, _fields_, _partialZonedDateTime_). - 12. Set _fields_ to ? PrepareTemporalFields(_fields_, _fieldNames_, « *"offset"* »). -features: [Temporal] ----*/ - -class ObservedCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - this.resetCalls(); - } - - toString() { - return "observed-calendar"; - } - - mergeFields(original, additional) { - this.mergeFieldsCalled++; - const result = super.mergeFields(original, additional); - result.offset = Symbol("can't convert to string"); - return result; - } - - resetCalls() { - this.mergeFieldsCalled = 0; - } -} - -const calendar = new ObservedCalendar(); -const dateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - -// Test throw in step 10 - -assert.throws(TypeError, () => dateTime.with({ offset: Symbol("can't convert to string") }), "conversion failure on ZonedDateTime-like"); -assert.sameValue(calendar.mergeFieldsCalled, 0, "calendar.mergeFields should not be called"); - -calendar.resetCalls(); - -// Test throw in step 12 (before sabotaging the ZonedDateTime instance) - -assert.throws(TypeError, () => dateTime.with({ year: 2002 }), "conversion failure on sabotaged return value from mergeFields"); -assert.sameValue(calendar.mergeFieldsCalled, 1, "calendar.mergeFields was called once"); - -calendar.resetCalls(); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 404a64aed90..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.with({ day: 27 })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index bd2f5c3799e..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.with({ day: 27 }, { offset: "prefer" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError (in offset=prefer and no disambiguation case)` - ); - - const badTimeZone = { - id: "Etc/Bad", - getPossibleInstantsFor() { return []; }, - getOffsetNanosecondsFor: notCallable, - }; - const badDateTime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, badTimeZone); - assert.throws( - TypeError, - () => badDateTime.with({ day: 27 }, { offset: "ignore" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError (in offset=ignore and no possible instants case)` - ); - assert.throws( - TypeError, - () => badDateTime.with({ day: 27 }, { offset: "prefer" }), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError (in offset=prefer and no possible instants case)` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 2668e7d719b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.with({ day: 27 })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 3dfdaf445bb..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.with({ day: 27 })); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getpossibleinstantsfor-iterable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getpossibleinstantsfor-iterable.js deleted file mode 100644 index 9c3e6900bc7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/with/timezone-getpossibleinstantsfor-iterable.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.with -description: An iterable returned from timeZone.getPossibleInstantsFor is consumed after each call -info: | - sec-temporal.zoneddatetime.prototype.with step 24: - 24. Let _epochNanoseconds_ be ? InterpretISODateTimeOffset(_dateTimeResult_.[[Year]], [...], _dateTimeResult_.[[Nanosecond]], _offsetNanoseconds_, _timeZone_, _disambiguation_, _offset_). - sec-temporal-interpretisodatetimeoffset step 7: - 7. Let _possibleInstants_ be ? GetPossibleInstantsFor(_timeZone_, _dateTime_). - sec-temporal-getpossibleinstantsfor step 2: - 2. Let _list_ be ? IterableToList(_possibleInstants_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "2005-09-09T01:46:40", -]; - -TemporalHelpers.checkTimeZonePossibleInstantsIterable((timeZone) => { - const datetime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); - datetime.with({ year: 2005 }); -}, expected); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/branding.js index 1533200c97b..b68d98bef99 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/branding.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/branding.js @@ -11,7 +11,7 @@ const withCalendar = Temporal.ZonedDateTime.prototype.withCalendar; assert.sameValue(typeof withCalendar, "function"); -const args = [new Temporal.Calendar("iso8601")]; +const args = ["iso8601"]; assert.throws(TypeError, () => withCalendar.apply(undefined, args), "undefined"); assert.throws(TypeError, () => withCalendar.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js deleted file mode 100644 index cfd2824753c..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withcalendar -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "id"); -Object.defineProperty(Temporal.Calendar.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.withCalendar("iso8601"); - -Object.defineProperty(Temporal.Calendar.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive.js index 69ae9b6229e..591dbf48be3 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive.js @@ -7,29 +7,7 @@ description: Calendar names are case-insensitive features: [Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); let arg = "iSo8601"; const result = instance.withCalendar(arg); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-iso-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-iso-string.js index 0c1fcad9ee3..a1cb08cfccf 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-iso-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-iso-string.js @@ -7,29 +7,7 @@ description: An ISO 8601 string can be converted to a calendar ID in Calendar features: [Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); for (const arg of [ "2020-01-01", @@ -42,5 +20,5 @@ for (const arg of [ "2020-01[u-ca=iso8601]", ]) { const result = instance.withCalendar(arg); - assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); + assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); } diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-number.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-number.js index 07bf8b3603b..36a4a68857f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-number.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-number.js @@ -7,29 +7,7 @@ description: A number is not allowed to be a calendar features: [Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); const numbers = [ 1, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-string-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-string-leap-second.js index 8f1dda0f141..6f7fa43f869 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-string-leap-second.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-string-leap-second.js @@ -7,29 +7,7 @@ description: Leap second is a valid ISO string for Calendar features: [Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); const arg = "2016-12-31T23:59:60"; const result = instance.withCalendar(arg); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-string.js index 7760408bc90..73cb949c318 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-string.js @@ -7,31 +7,9 @@ description: A calendar ID is valid input for Calendar features: [Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); const arg = "iso8601"; const result = instance.withCalendar(arg); -assert.sameValue(result.getISOFields().calendar, "iso8601", `Calendar created from string "${arg}"`); +assert.sameValue(result.calendarId, "iso8601", `Calendar created from string "${arg}"`); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-temporal-object.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-temporal-object.js index 8ab731918d8..9b32a99ed21 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-temporal-object.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-temporal-object.js @@ -3,7 +3,9 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.withcalendar -description: Fast path for converting other Temporal objects to Temporal.Calendar by reading internal slots +description: > + Fast path for converting other Temporal objects to calendar ID by reading + internal slots info: | sec-temporal-totemporalcalendar step 1.b: b. If _temporalCalendarLike_ has an [[InitializedTemporalDate]], [[InitializedTemporalDateTime]], [[InitializedTemporalMonthDay]], [[InitializedTemporalYearMonth]], or [[InitializedTemporalZonedDateTime]] internal slot, then @@ -22,8 +24,6 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT const actual = []; const expected = []; - const calendar = arg.getISOFields().calendar; - Object.defineProperty(arg, "calendar", { get() { actual.push("get calendar"); @@ -31,31 +31,9 @@ const zonedDateTime = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UT }, }); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); + const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); const result = instance.withCalendar(arg); - assert.sameValue(result.getISOFields().calendar, calendar, "Temporal object coerced to calendar"); + assert.sameValue(result.calendarId, "iso8601", "Temporal object coerced to calendar"); assert.compareArray(actual, expected, "calendar getter not called"); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-wrong-type.js index 382c7bdf864..b4a4f49e363 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/calendar-wrong-type.js @@ -5,33 +5,11 @@ esid: sec-temporal.zoneddatetime.prototype.withcalendar description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for Calendar + for Calendar features: [BigInt, Symbol, Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); const primitiveTests = [ [null, "null"], @@ -51,9 +29,8 @@ for (const [arg, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [arg, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/subclassing-ignored.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/subclassing-ignored.js index 1bffb6ac9d4..b32d5ec2ec2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/subclassing-ignored.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withCalendar/subclassing-ignored.js @@ -8,47 +8,22 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const customCalendar = { - year() { return 1900; }, - month() { return 2; }, - day() { return 5; }, - toString() { return "custom-calendar"; }, - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "custom-calendar", - inLeapYear() {}, - mergeFields() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; - TemporalHelpers.checkSubclassingIgnored( Temporal.ZonedDateTime, [10n, "UTC"], "withCalendar", - [customCalendar], + ["iso8601"], (result) => { assert.sameValue(result.epochNanoseconds, 10n, "epochNanoseconds result"); - assert.sameValue(result.year, 1900, "year result"); - assert.sameValue(result.month, 2, "month result"); - assert.sameValue(result.day, 5, "day result"); + assert.sameValue(result.year, 1970, "year result"); + assert.sameValue(result.month, 1, "month result"); + assert.sameValue(result.day, 1, "day result"); assert.sameValue(result.hour, 0, "hour result"); assert.sameValue(result.minute, 0, "minute result"); assert.sameValue(result.second, 0, "second result"); assert.sameValue(result.millisecond, 0, "millisecond result"); assert.sameValue(result.microsecond, 0, "microsecond result"); assert.sameValue(result.nanosecond, 10, "nanosecond result"); - assert.sameValue(result.getCalendar(), customCalendar, "calendar result"); + assert.sameValue(result.calendarId, "iso8601", "calendar result"); }, ); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js index 32b59887c07..1ff0de2d06c 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation-invalid-key.js @@ -18,7 +18,7 @@ const invalidStrings = [ ["T00:00[FOO=bar]", "invalid capitalized unrecognized key, time designator"], ["1970-01-01T00:00[FOO=bar]", "invalid capitalized unrecognized key"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach(([arg, descr]) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js index fc696e79754..073e2d7ad14 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-calendar-annotation.js @@ -26,7 +26,7 @@ const tests = [ ["1970-01-01T12:34:56.987654321[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js index 3ae28dfd0c1..cde62d40c91 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-critical-unknown-annotation.js @@ -16,7 +16,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-date-with-utc-offset.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-date-with-utc-offset.js index d50b266807b..07c1e8ebc39 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-date-with-utc-offset.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-date-with-utc-offset.js @@ -7,7 +7,7 @@ description: UTC offset not valid with format that does not include a time features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); const validStrings = [ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-calendar.js index 7b83150ee5b..ced0b5925bc 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-calendar.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-calendar.js @@ -19,7 +19,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js index 56a8c763429..5398e4c54ef 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-multiple-time-zone.js @@ -16,7 +16,7 @@ const invalidStrings = [ "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", "1970-01-01T00:00[UTC][foo=bar][UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-separators.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-separators.js index cb37471609b..5e492936ae6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-separators.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-separators.js @@ -15,7 +15,7 @@ const tests = [ ["t12:34:56.987654321", "time-only lowercase T"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js index 08abc6d058e..01b10c3f20f 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-time-zone-annotation.js @@ -34,7 +34,7 @@ const tests = [ ["1970-01-01T12:34:56.987654321+00:00[!-08:00]", "numeric, with date, offset, and !"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js index f5e4e9395c2..7eb4ef22511 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-string-unknown-annotation.js @@ -23,7 +23,7 @@ const tests = [ ["1970-01-01T12:34:56.987654321[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); tests.forEach(([arg, description]) => { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js index 8ece6fc6055..e472bef8751 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-balance-negative-time-units.js @@ -28,19 +28,16 @@ info: | ii. 1. Set _plainDateTime_ to ? BuiltinTimeZoneGetPlainDateTimeFor(_item_.[[TimeZone]], _instant_, _item_.[[Calendar]]). sec-temporal.zoneddatetime.prototype.withplaintime step 4.a: a. Let _plainTime_ be ? ToTemporalTime(_plainTimeLike_). -includes: [temporalHelpers.js] features: [Temporal] ---*/ // This code path is encountered if the time zone offset is negative and its // absolute value in nanoseconds is greater than the nanosecond field of the // exact time's epoch parts -const tz = TemporalHelpers.specificOffsetTimeZone(-2); -const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, tz); +const datetime = new Temporal.ZonedDateTime(3661_001_001_001n, "-00:02"); -const otherTimeZone = new Temporal.TimeZone("UTC"); // should not be used to convert datetime -> PlainTime -const zdt = new Temporal.ZonedDateTime(86400_000_000_000n, otherTimeZone); +const zdt = new Temporal.ZonedDateTime(86400_000_000_000n, "UTC"); // UTC should not be used to convert datetime -> PlainTime const newzdt = zdt.withPlainTime(datetime); -assert.sameValue(newzdt.microsecond, 0); -assert.sameValue(newzdt.nanosecond, 999); +assert.sameValue(newzdt.hour, 0); +assert.sameValue(newzdt.minute, 59); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 4606a4f4f01..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const other = new Temporal.ZonedDateTime(1_100_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.withPlainTime(other)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index b98be6c56a7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const other = new Temporal.ZonedDateTime(1_100_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.withPlainTime(other), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 39429beca29..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const other = new Temporal.ZonedDateTime(1_100_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.withPlainTime(other)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index db12e43dec0..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC"); - const other = new Temporal.ZonedDateTime(1_100_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.withPlainTime(other)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 47fef972769..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.withPlainTime(new Temporal.PlainTime(12, 34, 56)); - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js deleted file mode 100644 index f4a3f2f0878..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-maximum-forward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants can be at most 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 0n - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - calls++; - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12 })]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.withPlainTime(); - -assert(calls >= 2, "getOffsetNanosecondsFor should be called at least twice"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js deleted file mode 100644 index 9ae6cfc12ed..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getoffsetnanosecondsfor-out-of-range-forward-offset-shift.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: > - UTC offset shift returned by adjacent invocations of getOffsetNanosecondsFor - in DisambiguatePossibleInstants cannot be greater than 24 hours. -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 18. If abs(_nanoseconds_) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - _shiftEpochNs = 0n - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - if (instant.epochNanoseconds < this._shiftEpochNs) return -12 * 3600e9; - return 12 * 3600e9 + 1; - } - - getPossibleInstantsFor(plainDateTime) { - const [utcInstant] = super.getPossibleInstantsFor(plainDateTime); - const { year, month, day } = plainDateTime; - - if (year < 1970) return [utcInstant.subtract({ hours: 12 })]; - if (year === 1970 && month === 1 && day === 1) return []; - return [utcInstant.add({ hours: 12, nanoseconds: 1 })]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.withPlainTime(), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-called-with-iso8601-calendar.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-called-with-iso8601-calendar.js deleted file mode 100644 index 645e20385ca..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-called-with-iso8601-calendar.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: > - Time zone's getPossibleInstantsFor is called with a PlainDateTime with the - built-in ISO 8601 calendar -features: [Temporal] -info: | - DisambiguatePossibleInstants: - 2. Let _n_ be _possibleInstants_'s length. - ... - 5. Assert: _n_ = 0. - ... - 19. If _disambiguation_ is *"earlier"*, then - ... - c. Let _earlierDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - d. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _earlierDateTime_). - ... - 20. Assert: _disambiguation_ is *"compatible"* or *"later"*. - ... - 23. Let _laterDateTime_ be ! CreateTemporalDateTime(..., *"iso8601"*). - 24. Set _possibleInstants_ to ? GetPossibleInstantsFor(_timeZone_, _laterDateTime_). ----*/ - -class SkippedDateTime extends Temporal.TimeZone { - constructor() { - super("UTC"); - this.calls = 0; - } - - getPossibleInstantsFor(dateTime) { - // Calls occur in pairs. For the first one return no possible instants so - // that DisambiguatePossibleInstants will call it again - if (this.calls++ % 2 == 0) { - return []; - } - - assert.sameValue( - dateTime.getISOFields().calendar, - "iso8601", - "getPossibleInstantsFor called with dateTime with built-in ISO 8601 calendar" - ); - return super.getPossibleInstantsFor(dateTime); - } -} - -const nonBuiltinISOCalendar = new Temporal.Calendar("iso8601"); -const timeZone = new SkippedDateTime(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone, nonBuiltinISOCalendar); -instance.withPlainTime(); - -assert.sameValue(timeZone.calls, 2, "getPossibleInstantsFor should have been called 2 times"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-maximum-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-maximum-backward-offset-shift.js deleted file mode 100644 index 98879829f46..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-maximum-backward-offset-shift.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -let calls = 0; - -class Shift24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - calls++; - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12 }), - utcInstant.add({ hours: 12 }) - ]; - } -} - -const timeZone = new Shift24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -instance.withPlainTime(); - -assert(calls >= 1, "getPossibleInstantsFor should be called at least once"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js deleted file mode 100644 index 98f4d4cf680..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/getpossibleinstantsfor-out-of-range-backward-offset-shift.js +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: > - UTC offset shift returned by getPossibleInstantsFor can be at most 24 hours. -features: [Temporal] -info: | - GetPossibleInstantsFor: - 5.b.i. Let _numResults_ be _list_'s length. - ii. If _numResults_ > 1, then - 1. Let _epochNs_ be a new empty List. - 2. For each value _instant_ in list, do - a. Append _instant_.[[EpochNanoseconds]] to the end of the List _epochNs_. - 3. Let _min_ be the least element of the List _epochNs_. - 4. Let _max_ be the greatest element of the List _epochNs_. - 5. If abs(ℝ(_max_ - _min_)) > nsPerDay, throw a *RangeError* exception. ----*/ - -class ShiftLonger24Hour extends Temporal.TimeZone { - id = 'TestTimeZone'; - - constructor() { - super('UTC'); - } - - getOffsetNanosecondsFor(instant) { - return 0; - } - - getPossibleInstantsFor(plainDateTime) { - const utc = new Temporal.TimeZone("UTC"); - const [utcInstant] = utc.getPossibleInstantsFor(plainDateTime); - return [ - utcInstant.subtract({ hours: 12, nanoseconds: 1 }), - utcInstant.add({ hours: 12 }), - utcInstant, // add a third value in case the implementation doesn't sort - ]; - } -} - -const timeZone = new ShiftLonger24Hour(); - -const instance = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => instance.withPlainTime(), "RangeError should be thrown"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/order-of-operations.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/order-of-operations.js index 182d50d9b42..fd7352e94ce 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/order-of-operations.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/order-of-operations.js @@ -29,26 +29,9 @@ const expected = [ "get plainTimeLike.second", "get plainTimeLike.second.valueOf", "call plainTimeLike.second.valueOf", - // lookup - "get this.timeZone.getOffsetNanosecondsFor", - "get this.timeZone.getPossibleInstantsFor", - // GetPlainDateTimeFor - "call this.timeZone.getOffsetNanosecondsFor", - // GetInstantFor - "call this.timeZone.getPossibleInstantsFor", ]; -const calendar = TemporalHelpers.calendarObserver(actual, "this.calendar"); -const dstTimeZone = TemporalHelpers.springForwardFallBackTimeZone(); -const timeZone = TemporalHelpers.timeZoneObserver(actual, "this.timeZone", { - getOffsetNanosecondsFor: dstTimeZone.getOffsetNanosecondsFor, - getPossibleInstantsFor: dstTimeZone.getPossibleInstantsFor, -}); - -const instance = new Temporal.ZonedDateTime(946713600_000_000_000n /* 2000-01-01T00:00-08:00 */, timeZone, calendar); -const fallBackInstance = new Temporal.ZonedDateTime(972802800_000_000_000n /* 2000-10-29T00:00-07:00 */, timeZone, calendar); -const springForwardInstance = new Temporal.ZonedDateTime(954662400_000_000_000n /* 2000-04-02T00:00-08:00 */, timeZone, calendar); -actual.splice(0); // clear calls that happened in constructors +const instance = new Temporal.ZonedDateTime(946713600_000_000_000n /* 2000-01-01T00:00-08:00 */, "UTC"); const plainTimeLike = TemporalHelpers.propertyBagObserver(actual, { hour: 2, @@ -60,26 +43,5 @@ const plainTimeLike = TemporalHelpers.propertyBagObserver(actual, { }, "plainTimeLike"); instance.withPlainTime(plainTimeLike); -assert.compareArray(actual, expected, "order of operations at normal wall-clock time"); -actual.splice(0); // clear - -const plainTimeLike130 = TemporalHelpers.propertyBagObserver(actual, { - hour: 1, - minute: 30, - second: 0, - millisecond: 0, - microsecond: 0, - nanosecond: 0, -}, "plainTimeLike"); - -fallBackInstance.withPlainTime(plainTimeLike130); -assert.compareArray(actual, expected, "order of operations at repeated wall-clock time"); -actual.splice(0); // clear - -springForwardInstance.withPlainTime(plainTimeLike); -assert.compareArray(actual, expected.concat([ - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getOffsetNanosecondsFor", - "call this.timeZone.getPossibleInstantsFor", -]), "order of operations at skipped wall-clock time"); +assert.compareArray(actual, expected, "order of operations"); actual.splice(0); // clear diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 9c6016214d2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - assert.throws(RangeError, () => datetime.withPlainTime(time)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index cc39c1890a5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.withPlainTime(time), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index d91f5559771..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - assert.throws(RangeError, () => datetime.withPlainTime(time)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 175ca62a1ca..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withplaintime -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - const time = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); - assert.throws(TypeError, () => datetime.withPlainTime(time)); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero.js index f5fa8e920e0..baf1f692588 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainTime/year-zero.js @@ -12,7 +12,7 @@ const invalidStrings = [ "-000000-12-07T03:24:30+01:00", "-000000-12-07T03:24:30+00:00[UTC]", ]; -const timeZone = new Temporal.TimeZone("UTC"); +const timeZone = "UTC"; const instance = new Temporal.ZonedDateTime(0n, timeZone); invalidStrings.forEach((arg) => { assert.throws( diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/branding.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/branding.js index feecfe91b39..f5f3f4a66c9 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/branding.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/branding.js @@ -11,7 +11,7 @@ const withTimeZone = Temporal.ZonedDateTime.prototype.withTimeZone; assert.sameValue(typeof withTimeZone, "function"); -const args = [new Temporal.TimeZone("UTC")]; +const args = ["UTC"]; assert.throws(TypeError, () => withTimeZone.apply(undefined, args), "undefined"); assert.throws(TypeError, () => withTimeZone.apply(null, args), "null"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 83ef3783321..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.withtimezone -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const idOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "id"); -Object.defineProperty(Temporal.TimeZone.prototype, "id", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("id should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.withTimeZone("+01:00"); - -Object.defineProperty(Temporal.TimeZone.prototype, "id", idOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-datetime.js index c5b06f34d8f..309d6e7adc2 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-datetime.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.withtimezone -description: Conversion of ISO date-time strings to Temporal.TimeZone instances +description: Conversion of ISO date-time strings to time zone IDs features: [Temporal] ---*/ diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-year-zero.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-year-zero.js index 727174f1b29..63850e353f6 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-year-zero.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string-year-zero.js @@ -11,7 +11,7 @@ const invalidStrings = [ "-000000-10-31T17:45Z", "-000000-10-31T17:45+00:00[UTC]", ]; -const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); invalidStrings.forEach((timeZone) => { assert.throws( RangeError, diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string.js index d99aed57678..78c2d2a08e9 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-string.js @@ -4,33 +4,12 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.withtimezone description: Time zone IDs are valid input for a time zone -includes: [temporalHelpers.js] features: [Temporal] ---*/ -const getPossibleInstantsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getPossibleInstantsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getPossibleInstantsFor should not be looked up"); - }, -}); -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - const instance = new Temporal.ZonedDateTime(0n, "UTC"); ["UTC", "+01:30"].forEach((timeZone) => { const result = instance.withTimeZone(timeZone); - assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); + assert.sameValue(result.timeZoneId, timeZone, `time zone slot should store string "${timeZone}"`); }); - -Object.defineProperty(Temporal.TimeZone.prototype, "getPossibleInstantsFor", getPossibleInstantsForOriginal); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-wrong-type.js index 2f185583f54..525d6944f76 100644 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withTimeZone/timezone-wrong-type.js @@ -5,11 +5,11 @@ esid: sec-temporal.zoneddatetime.prototype.withtimezone description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(0n, new Temporal.TimeZone("UTC")); +const instance = new Temporal.ZonedDateTime(0n, "UTC"); const primitiveTests = [ [null, "null"], @@ -30,8 +30,8 @@ for (const [timeZone, description] of primitiveTests) { const typeErrorTests = [ [Symbol(), "symbol"], - [{}, "object not implementing time zone protocol"], - [new Temporal.Calendar("iso8601"), "calendar instance"], + [{}, "object"], + [new Temporal.Duration(), "duration instance"], ]; for (const [timeZone, description] of typeErrorTests) { diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 03be598d156..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/year/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.year -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const yearOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "year"); -Object.defineProperty(Temporal.Calendar.prototype, "year", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("year should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.year; - -Object.defineProperty(Temporal.Calendar.prototype, "year", yearOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/builtin-timezone-no-observable-calls.js deleted file mode 100644 index 79422e52aa1..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/year/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.year -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.year; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/custom.js deleted file mode 100644 index 753f4a3e3c7..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/year/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.year -description: Custom calendar tests for year(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - year(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "year arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.year; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index ee36fb294ba..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.year -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.year); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 4e22cebe865..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.year -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.year, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 254f18e0cf5..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.year -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.year); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index ede6e0049fa..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/year/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.year -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.year); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/year/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/year/validate-calendar-value.js deleted file mode 100644 index 73295846640..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/year/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.year -description: Validate result returned from calendar year() method -features: [Temporal] ----*/ - -const badResults = [ - [undefined, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [NaN, RangeError], - ["string", TypeError], - [{}, TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, RangeError], - [-0.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - year() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.year, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - year() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.sameValue(instance.year, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js deleted file mode 100644 index 81d9e60be87..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/builtin-calendar-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.yearofweek -description: > - Calling the method on an instance constructed with a builtin calendar causes - no observable lookups or calls to calendar methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const yearOfWeekOriginal = Object.getOwnPropertyDescriptor(Temporal.Calendar.prototype, "yearOfWeek"); -Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("yearOfWeek should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.yearOfWeek; - -Object.defineProperty(Temporal.Calendar.prototype, "yearOfWeek", yearOfWeekOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/builtin-timezone-no-observable-calls.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/builtin-timezone-no-observable-calls.js deleted file mode 100644 index dd3f512d832..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/builtin-timezone-no-observable-calls.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.yearofweek -description: > - Calling the method on an instance constructed with a builtin time zone causes - no observable lookups or calls to time zone methods. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const getOffsetNanosecondsForOriginal = Object.getOwnPropertyDescriptor(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor"); -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", { - configurable: true, - enumerable: false, - get() { - TemporalHelpers.assertUnreachable("getOffsetNanosecondsFor should not be looked up"); - }, -}); - -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", "iso8601"); -instance.yearOfWeek; - -Object.defineProperty(Temporal.TimeZone.prototype, "getOffsetNanosecondsFor", getOffsetNanosecondsForOriginal); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js deleted file mode 100644 index 0c5c3723c79..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom-calendar-weekofyear.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.yearofweek -description: > - Temporal.ZonedDateTime.prototype.yearOfWeek returns undefined for all - custom calendars where yearOfWeek() returns undefined. -features: [Temporal] ----*/ - -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearOfWeek() { - return undefined; - } -} - -const calendar = new CustomCalendar(); -// Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); -const customCalendarDate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); -assert.sameValue(customCalendarDate.yearOfWeek, undefined); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom.js deleted file mode 100644 index 936c59fb0de..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/custom.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.yearofweek -description: Custom calendar tests for yearOfWeek(). -includes: [compareArray.js] -features: [Temporal] ----*/ - -let calls = 0; -class CustomCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - yearOfWeek(...args) { - ++calls; - assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "yearOfWeek arguments"); - return 7; - } -} - -const calendar = new CustomCalendar(); -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); -const result = instance.yearOfWeek; -assert.sameValue(result, 7, "result"); -assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-non-integer.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index d5b55c1d679..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.yearofweek -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.yearOfWeek); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-not-callable.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 8b21af0260a..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.yearofweek -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.yearOfWeek, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index df1ecffaf17..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.yearofweek -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.yearOfWeek); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index da5b81356dd..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.yearofweek -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.yearOfWeek); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js b/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js deleted file mode 100644 index 6b87e8a8b25..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/prototype/yearOfWeek/validate-calendar-value.js +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.yearofweek -description: Validate result returned from calendar yearOfWeek() method -features: [Temporal] ----*/ - -const badResults = [ - [Infinity, RangeError], - [-Infinity, RangeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [NaN, RangeError], - ["string", TypeError], - [{}, TypeError], - [null, TypeError], - [true, TypeError], - [false, TypeError], - [7.1, RangeError], - [-0.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - yearOfWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.yearOfWeek, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - yearOfWeek() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.sameValue(instance.yearOfWeek, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/built-ins/Temporal/ZonedDateTime/timezone-iso-string.js b/test/built-ins/Temporal/ZonedDateTime/timezone-iso-string.js new file mode 100644 index 00000000000..27b7162edee --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/timezone-iso-string.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.constructor +description: An ISO string is not valid input for a constructor's time zone param +features: [Temporal] +---*/ + +assert.throws( + RangeError, + () => new Temporal.ZonedDateTime(0n, "1997-12-04T12:34[+01:00]", "iso8601"), + "An ISO string is not a valid calendar ID for constructor parameter" +); diff --git a/test/built-ins/Temporal/ZonedDateTime/timezone-string-datetime.js b/test/built-ins/Temporal/ZonedDateTime/timezone-string-datetime.js deleted file mode 100644 index 3c89de29a89..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/timezone-string-datetime.js +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances -features: [Temporal] ----*/ - -let timeZone = "2021-08-19T17:30"; -assert.throws(RangeError, () => new Temporal.ZonedDateTime(0n, timeZone), "bare date-time string is not a time zone"); - -[ - "2021-08-19T17:30-07:00:01", - "2021-08-19T17:30-07:00:00", - "2021-08-19T17:30-07:00:00.1", - "2021-08-19T17:30-07:00:00.0", - "2021-08-19T17:30-07:00:00.01", - "2021-08-19T17:30-07:00:00.00", - "2021-08-19T17:30-07:00:00.001", - "2021-08-19T17:30-07:00:00.000", - "2021-08-19T17:30-07:00:00.0001", - "2021-08-19T17:30-07:00:00.0000", - "2021-08-19T17:30-07:00:00.00001", - "2021-08-19T17:30-07:00:00.00000", - "2021-08-19T17:30-07:00:00.000001", - "2021-08-19T17:30-07:00:00.000000", - "2021-08-19T17:30-07:00:00.0000001", - "2021-08-19T17:30-07:00:00.0000000", - "2021-08-19T17:30-07:00:00.00000001", - "2021-08-19T17:30-07:00:00.00000000", - "2021-08-19T17:30-07:00:00.000000001", - "2021-08-19T17:30-07:00:00.000000000", -].forEach((timeZone) => { - assert.throws( - RangeError, - () => new Temporal.ZonedDateTime(0n, timeZone), - `ISO string ${timeZone} with a sub-minute offset is not a valid time zone` - ); -}); - -timeZone = "2021-08-19T17:30Z"; -const result1 = new Temporal.ZonedDateTime(0n, timeZone); -assert.sameValue(result1.timeZoneId, "UTC", "date-time + Z is UTC time zone"); - -timeZone = "2021-08-19T17:30-07:00"; -const result2 = new Temporal.ZonedDateTime(0n, timeZone); -assert.sameValue(result2.timeZoneId, "-07:00", "date-time + offset is the offset time zone"); - -timeZone = "2021-08-19T17:30[UTC]"; -const result3 = new Temporal.ZonedDateTime(0n, timeZone); -assert.sameValue(result3.timeZoneId, "UTC", "date-time + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30Z[UTC]"; -const result4 = new Temporal.ZonedDateTime(0n, timeZone); -assert.sameValue(result4.timeZoneId, "UTC", "date-time + Z + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30-07:00[UTC]"; -const result5 = new Temporal.ZonedDateTime(0n, timeZone); -assert.sameValue(result5.timeZoneId, "UTC", "date-time + offset + IANA annotation is the IANA time zone"); diff --git a/test/built-ins/Temporal/ZonedDateTime/timezone-string-leap-second.js b/test/built-ins/Temporal/ZonedDateTime/timezone-string-leap-second.js deleted file mode 100644 index b24c78060b2..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/timezone-string-leap-second.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime -description: Leap second is a valid ISO string for TimeZone -features: [Temporal] ----*/ - -let timeZone = "2016-12-31T23:59:60+00:00[UTC]"; - -const result = new Temporal.ZonedDateTime(0n, timeZone); -assert.sameValue(result.timeZoneId, "UTC", "Time zone string determined from bracket name"); - -timeZone = "2021-08-19T17:30:45.123456789+23:59[+23:59:60]"; -assert.throws(RangeError, () => new Temporal.ZonedDateTime(0n, timeZone), "leap second in time zone name not valid"); diff --git a/test/built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets.js b/test/built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets.js deleted file mode 100644 index f744d75470b..00000000000 --- a/test/built-ins/Temporal/ZonedDateTime/timezone-string-multiple-offsets.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime -description: Time zone parsing from ISO strings uses the bracketed offset, not the ISO string offset -features: [Temporal] ----*/ - -const timeZone = "2021-08-19T17:30:45.123456789-12:12[+01:46]"; - -const result = new Temporal.ZonedDateTime(0n, timeZone); -assert.sameValue(result.timeZoneId, "+01:46", "Time zone string determined from bracket name"); diff --git a/test/built-ins/Temporal/ZonedDateTime/timezone-string.js b/test/built-ins/Temporal/ZonedDateTime/timezone-string.js index d83ef4c271d..6b74615d6ed 100644 --- a/test/built-ins/Temporal/ZonedDateTime/timezone-string.js +++ b/test/built-ins/Temporal/ZonedDateTime/timezone-string.js @@ -9,5 +9,5 @@ features: [Temporal] ["UTC", "+01:30"].forEach((timeZone) => { const result = new Temporal.ZonedDateTime(0n, timeZone); - assert.sameValue(result.getISOFields().timeZone, timeZone, `time zone slot should store string "${timeZone}"`); + assert.sameValue(result.timeZoneId, timeZone, `time zone ID should be "${timeZone}"`); }); diff --git a/test/built-ins/Temporal/ZonedDateTime/timezone-wrong-type.js b/test/built-ins/Temporal/ZonedDateTime/timezone-wrong-type.js index 5399b24f0b5..ec942338656 100644 --- a/test/built-ins/Temporal/ZonedDateTime/timezone-wrong-type.js +++ b/test/built-ins/Temporal/ZonedDateTime/timezone-wrong-type.js @@ -5,7 +5,7 @@ esid: sec-temporal.zoneddatetime description: > Appropriate error thrown when argument cannot be converted to a valid string - or object for TimeZone + for time zone features: [BigInt, Symbol, Temporal] ---*/ diff --git a/test/built-ins/Temporal/getOwnPropertyNames.js b/test/built-ins/Temporal/getOwnPropertyNames.js index 783d9337651..054850ccfd0 100644 --- a/test/built-ins/Temporal/getOwnPropertyNames.js +++ b/test/built-ins/Temporal/getOwnPropertyNames.js @@ -10,7 +10,6 @@ features: [Temporal] const keys = Object.getOwnPropertyNames(Temporal); assert(keys.indexOf("Instant") > -1, "Instant"); -assert(keys.indexOf("TimeZone") > -1, "TimeZone"); assert(keys.indexOf("PlainDate") > -1, "PlainDate"); assert(keys.indexOf("PlainTime") > -1, "PlainTime"); assert(keys.indexOf("PlainDateTime") > -1, "PlainDateTime"); @@ -18,5 +17,4 @@ assert(keys.indexOf("ZonedDateTime") > -1, "ZonedDateTime"); assert(keys.indexOf("PlainYearMonth") > -1, "PlainYearMonth"); assert(keys.indexOf("PlainMonthDay") > -1, "PlainMonthDay"); assert(keys.indexOf("Duration") > -1, "Duration"); -assert(keys.indexOf("Calendar") > -1, "Calendar"); assert(keys.indexOf("Now") > -1, "Now"); diff --git a/test/intl402/Temporal/Calendar/calendar-case-insensitive.js b/test/intl402/Temporal/Calendar/calendar-case-insensitive.js deleted file mode 100644 index 71c1b270909..00000000000 --- a/test/intl402/Temporal/Calendar/calendar-case-insensitive.js +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar -description: Calendar names are case-insensitive -features: [Temporal] ----*/ - -const result = new Temporal.Calendar("jApAnEsE"); -assert.sameValue(result.toString(), "japanese", "Calendar is case-insensitive"); diff --git a/test/intl402/Temporal/Calendar/from/basic.js b/test/intl402/Temporal/Calendar/from/basic.js deleted file mode 100644 index 400a8911ed6..00000000000 --- a/test/intl402/Temporal/Calendar/from/basic.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Support for non-ISO calendars in Calendar.from(). -features: [Temporal] ----*/ - -function test(item, id = item) { - const calendar = Temporal.Calendar.from(item); - assert(calendar instanceof Temporal.Calendar, `Calendar.from(${item}) is a calendar`); - assert.sameValue(calendar.id, id, `Calendar.from(${item}) has the correct ID`); -} -test("gregory"); -test("japanese"); -test("1994-11-05T08:15:30-05:00[u-ca=gregory]", "gregory"); -test("1994-11-05T13:15:30Z[u-ca=japanese]", "japanese"); diff --git a/test/intl402/Temporal/Calendar/from/calendar-case-insensitive.js b/test/intl402/Temporal/Calendar/from/calendar-case-insensitive.js deleted file mode 100644 index 9484a2c7bda..00000000000 --- a/test/intl402/Temporal/Calendar/from/calendar-case-insensitive.js +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.from -description: Calendar names are case-insensitive -features: [Temporal] ----*/ - -const arg = "jApAnEsE"; - -const result = Temporal.Calendar.from(arg); -assert.sameValue(result.id, "japanese", "Calendar is case-insensitive"); diff --git a/test/intl402/Temporal/Calendar/prototype/dateAdd/date-infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/dateAdd/date-infinity-throws-rangeerror.js deleted file mode 100644 index 238d6845302..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/dateAdd/date-infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.dateadd -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const duration = new Temporal.Duration(1); - -[Infinity, -Infinity].forEach((inf) => { - ["constrain", "reject"].forEach((overflow) => { - assert.throws(RangeError, () => instance.dateAdd({ era: "ad", eraYear: inf, month: 5, day: 2, calendar: instance }, duration, { overflow }), `eraYear property cannot be ${inf} (overflow ${overflow}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.dateAdd({ era: "ad", eraYear: obj, month: 5, day: 2, calendar: instance }, duration, { overflow })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/dateFromFields/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/dateFromFields/infinity-throws-rangeerror.js deleted file mode 100644 index 94d8a0e6abb..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/dateFromFields/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.datefromfields -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - ["constrain", "reject"].forEach((overflow) => { - assert.throws(RangeError, () => instance.dateFromFields({ ...base, eraYear: inf }, { overflow }), `eraYear property cannot be ${inf} (overflow ${overflow}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.dateFromFields({ ...base, eraYear: obj }, { overflow })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/dateFromFields/one-of-era-erayear-undefined.js b/test/intl402/Temporal/Calendar/prototype/dateFromFields/one-of-era-erayear-undefined.js deleted file mode 100644 index 351deafdffd..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/dateFromFields/one-of-era-erayear-undefined.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Throw a TypeError if only one of era/eraYear fields is present -features: [Temporal] ----*/ - -const base = { year: 2000, month: 5, day: 2, era: 'ce' }; -const instance = new Temporal.Calendar('gregory'); -assert.throws(TypeError, () => { - instance.dateFromFields({ ...base }); -}); - -const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 }; -assert.throws(TypeError, () => { - instance.dateFromFields({ ...base2 }); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/dateFromFields/order-of-operations.js b/test/intl402/Temporal/Calendar/prototype/dateFromFields/order-of-operations.js deleted file mode 100644 index bc67df94567..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/dateFromFields/order-of-operations.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.datefromfields -description: Properties on objects passed to dateFromFields() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get fields.day", - "get fields.day.valueOf", - "call fields.day.valueOf", - "get fields.era", - "get fields.era.toString", - "call fields.era.toString", - "get fields.eraYear", - "get fields.eraYear.valueOf", - "call fields.eraYear.valueOf", - "get fields.month", - "get fields.month.valueOf", - "call fields.month.valueOf", - "get fields.monthCode", - "get fields.monthCode.toString", - "call fields.monthCode.toString", - "get fields.year", - "get fields.year.valueOf", - "call fields.year.valueOf", - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; -const actual = []; - -const instance = new Temporal.Calendar("gregory"); - -const fields = { - era: "ce", - eraYear: 1.7, - year: 1.7, - month: 1.7, - monthCode: "M01", - day: 1.7, -}; -const arg1 = new Proxy(fields, { - get(target, key) { - actual.push(`get fields.${key}`); - if (key === "calendar") return instance; - const result = target[key]; - return TemporalHelpers.toPrimitiveObserver(actual, result, `fields.${key}`); - }, - has(target, key) { - actual.push(`has fields.${key}`); - return key in target; - }, -}); - -const options = { - overflow: "reject", -}; -const arg2 = new Proxy(options, { - get(target, key) { - actual.push(`get options.${key}`); - return TemporalHelpers.toPrimitiveObserver(actual, target[key], `options.${key}`); - }, - has(target, key) { - actual.push(`has options.${key}`); - return key in target; - }, -}); - -const result = instance.dateFromFields(arg1, arg2); -TemporalHelpers.assertPlainDate(result, 1, 1, "M01", 1, "date result", "ce", 1); -assert.sameValue(result.getISOFields().calendar, "gregory", "calendar slot should store a string"); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/intl402/Temporal/Calendar/prototype/dateUntil/argument-infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/dateUntil/argument-infinity-throws-rangeerror.js deleted file mode 100644 index 5c836456b2a..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/dateUntil/argument-infinity-throws-rangeerror.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if any value in a property bag for either argument is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.dateuntil -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const other = new Temporal.PlainDate(2001, 6, 3); -const base = { era: "ad", month: 5, day: 2, calendar: instance }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.dateUntil({ ...base, eraYear: inf }, other), `eraYear property cannot be ${inf}`); - - assert.throws(RangeError, () => instance.dateUntil(other, { ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls1 = []; - const obj1 = TemporalHelpers.toPrimitiveObserver(calls1, inf, "eraYear"); - assert.throws(RangeError, () => instance.dateUntil({ ...base, eraYear: obj1 }, other)); - assert.compareArray(calls1, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); - - const calls2 = []; - const obj2 = TemporalHelpers.toPrimitiveObserver(calls2, inf, "eraYear"); - assert.throws(RangeError, () => instance.dateUntil(other, { ...base, eraYear: obj2 })); - assert.compareArray(calls2, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/dateUntil/zero-length-duration-result.js b/test/intl402/Temporal/Calendar/prototype/dateUntil/zero-length-duration-result.js deleted file mode 100644 index e852a60f4b2..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/dateUntil/zero-length-duration-result.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: The duration from a date to itself is a zero duration (PT0S) -esid: sec-temporal.calendar.prototype.dateuntil -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const date = new Temporal.PlainDate(2001, 6, 3); - -['year', 'month', 'week', 'day'].forEach((largestUnit) => { - const result = instance.dateUntil(date, date, { largestUnit }); - assert.sameValue(result.toString(), 'PT0S'); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/day/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/day/infinity-throws-rangeerror.js deleted file mode 100644 index d4ce585df76..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/day/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.day -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.day({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.day({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/dayOfWeek/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/dayOfWeek/infinity-throws-rangeerror.js deleted file mode 100644 index d85e547f052..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/dayOfWeek/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.dayofweek -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.dayOfWeek({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.dayOfWeek({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/dayOfYear/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/dayOfYear/infinity-throws-rangeerror.js deleted file mode 100644 index a8843191669..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/dayOfYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.dayofyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.dayOfYear({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.dayOfYear({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/daysInMonth/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/daysInMonth/infinity-throws-rangeerror.js deleted file mode 100644 index c39c875c41f..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/daysInMonth/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.daysinmonth -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.daysInMonth({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.daysInMonth({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/daysInWeek/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/daysInWeek/infinity-throws-rangeerror.js deleted file mode 100644 index d192101be13..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/daysInWeek/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.daysinweek -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.daysInWeek({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.daysInWeek({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/daysInYear/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/daysInYear/infinity-throws-rangeerror.js deleted file mode 100644 index 7f60f72328e..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/daysInYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.daysinyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.daysInYear({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.daysInYear({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-builtin-calendar-no-array-iteration.js b/test/intl402/Temporal/Calendar/prototype/era/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 95da8b9af22..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.era(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/intl402/Temporal/Calendar/prototype/era/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 99d309848a2..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.era(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-constructor-in-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/era/argument-constructor-in-calendar-fields.js deleted file mode 100644 index 712d00399d8..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.era -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.era(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-duplicate-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/era/argument-duplicate-calendar-fields.js deleted file mode 100644 index 2b8536da128..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.era -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.era(arg)); -} diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-leap-second.js b/test/intl402/Temporal/Calendar/prototype/era/argument-leap-second.js deleted file mode 100644 index 42cb42f55aa..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.era(arg); -assert.sameValue( - result1, - undefined, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.era(arg); -assert.sameValue( - result2, - undefined, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-number.js b/test/intl402/Temporal/Calendar/prototype/era/argument-number.js deleted file mode 100644 index e215edd320c..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.era(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-case-insensitive.js b/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index 790f6401edd..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.era(arg); -assert.sameValue(result, undefined, "Calendar is case-insensitive"); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js b/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index 76da70fa30c..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.era(arg); - assert.sameValue(result, undefined, `Calendar created from string "${calendar}"`); -} diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-leap-second.js b/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 97a5dd6298e..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.era(arg); -assert.sameValue( - result, - undefined, - "leap second is a valid ISO string for calendar" -); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-number.js b/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-number.js deleted file mode 100644 index 459fe5bf018..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.era(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-string.js b/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-string.js deleted file mode 100644 index 01f059cd64c..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.era(arg); -assert.sameValue(result, undefined, `Calendar created from string "${calendar}"`); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-wrong-type.js b/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 74c82e89edb..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.era(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.era(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js b/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index 6d22ba17196..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.era(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-proto-in-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/era/argument-proto-in-calendar-fields.js deleted file mode 100644 index c31d3171a3a..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.era -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.era(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index 8d570e5b222..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.era(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation.js deleted file mode 100644 index 86214a5587c..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.era(arg); - - assert.sameValue( - result, - undefined, - `calendar annotation (${description})` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-critical-unknown-annotation.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-critical-unknown-annotation.js deleted file mode 100644 index 94613036ae4..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.era(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-date-with-utc-offset.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-date-with-utc-offset.js deleted file mode 100644 index 11313edf849..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.era(arg); - - assert.sameValue( - result, - undefined, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.era(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-invalid.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-invalid.js deleted file mode 100644 index b7a6b5c0bc1..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.era(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-calendar.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-calendar.js deleted file mode 100644 index 6c1da80f38c..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.era(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-time-zone.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-time-zone.js deleted file mode 100644 index ac43caa1aeb..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.era(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-time-separators.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-time-separators.js deleted file mode 100644 index 0a5aa636e93..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.era(arg); - - assert.sameValue( - result, - undefined, - `variant time separators (${description})` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-time-zone-annotation.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-time-zone-annotation.js deleted file mode 100644 index 899b979f21a..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.era(arg); - - assert.sameValue( - result, - undefined, - `time zone annotation (${description})` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-unknown-annotation.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-unknown-annotation.js deleted file mode 100644 index 940ea78fa38..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.era(arg); - - assert.sameValue( - result, - undefined, - `unknown annotation (${description})` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-string-with-utc-designator.js b/test/intl402/Temporal/Calendar/prototype/era/argument-string-with-utc-designator.js deleted file mode 100644 index 4ad95a15f89..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.era(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-wrong-type.js b/test/intl402/Temporal/Calendar/prototype/era/argument-wrong-type.js deleted file mode 100644 index 161a86e0c16..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.era(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.era(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-convert.js b/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-convert.js deleted file mode 100644 index 107353320e9..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.era(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-slots.js b/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-slots.js deleted file mode 100644 index ae4ba429d26..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.era(arg); -assert.compareArray(actual, []); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index b703f7f849b..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.era(datetime)); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index 1014cc9c9b9..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.era(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index ac02e3162d9..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.era(datetime)); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 6e8179b6d7f..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.era(datetime)); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/branding.js b/test/intl402/Temporal/Calendar/prototype/era/branding.js deleted file mode 100644 index b8b5ed214c8..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const era = Temporal.Calendar.prototype.era; - -assert.sameValue(typeof era, "function"); - -assert.throws(TypeError, () => era.call(undefined), "undefined"); -assert.throws(TypeError, () => era.call(null), "null"); -assert.throws(TypeError, () => era.call(true), "true"); -assert.throws(TypeError, () => era.call(""), "empty string"); -assert.throws(TypeError, () => era.call(Symbol()), "symbol"); -assert.throws(TypeError, () => era.call(1), "1"); -assert.throws(TypeError, () => era.call({}), "plain object"); -assert.throws(TypeError, () => era.call(Temporal.Calendar), "Temporal.Calendar"); -assert.throws(TypeError, () => era.call(Temporal.Calendar.prototype), "Temporal.Calendar.prototype"); diff --git a/test/intl402/Temporal/Calendar/prototype/era/builtin.js b/test/intl402/Temporal/Calendar/prototype/era/builtin.js deleted file mode 100644 index f51e65a3970..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: > - Tests that Temporal.Calendar.prototype.era - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.era), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.era), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.era), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.era.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/intl402/Temporal/Calendar/prototype/era/calendar-datefromfields-called-with-options-undefined.js b/test/intl402/Temporal/Calendar/prototype/era/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index eb1e61d9b19..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.era({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/intl402/Temporal/Calendar/prototype/era/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/era/infinity-throws-rangeerror.js deleted file mode 100644 index a7a27dde31b..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.era -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.era({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.era({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/length.js b/test/intl402/Temporal/Calendar/prototype/era/length.js deleted file mode 100644 index 622daa6779c..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Temporal.Calendar.prototype.era.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.era, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/name.js b/test/intl402/Temporal/Calendar/prototype/era/name.js deleted file mode 100644 index a188e02d844..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Temporal.Calendar.prototype.era.name is "era". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.era, "name", { - value: "era", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/not-a-constructor.js b/test/intl402/Temporal/Calendar/prototype/era/not-a-constructor.js deleted file mode 100644 index 41c0c40829e..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: > - Temporal.Calendar.prototype.era does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.era(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.era), false, - "isConstructor(Temporal.Calendar.prototype.era)"); diff --git a/test/intl402/Temporal/Calendar/prototype/era/prop-desc.js b/test/intl402/Temporal/Calendar/prototype/era/prop-desc.js deleted file mode 100644 index 5093e9bad74..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: The "era" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.era, - "function", - "`typeof Calendar.prototype.era` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "era", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/intl402/Temporal/Calendar/prototype/era/year-zero.js b/test/intl402/Temporal/Calendar/prototype/era/year-zero.js deleted file mode 100644 index a9230724b7e..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/era/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.era -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.era(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-builtin-calendar-no-array-iteration.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-builtin-calendar-no-array-iteration.js deleted file mode 100644 index 66947a2b124..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-builtin-calendar-no-array-iteration.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: > - Calling the method with a property bag argument with a builtin calendar causes - no observable array iteration when getting the calendar fields. -features: [Temporal] ----*/ - -const arrayPrototypeSymbolIteratorOriginal = Array.prototype[Symbol.iterator]; -Array.prototype[Symbol.iterator] = function arrayIterator() { - throw new Test262Error("Array should not be iterated"); -} - -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar: "iso8601" }; -instance.eraYear(arg); - -Array.prototype[Symbol.iterator] = arrayPrototypeSymbolIteratorOriginal; diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js deleted file mode 100644 index 745c25004c0..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-calendar-datefromfields-called-with-null-prototype-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: > - Calendar.dateFromFields method is called with a null-prototype fields object -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarCheckFieldsPrototypePollution(); -const instance = new Temporal.Calendar("iso8601"); -const arg = { year: 2000, month: 5, day: 2, calendar }; -instance.eraYear(arg); -assert.sameValue(calendar.dateFromFieldsCallCount, 1, "dateFromFields should be called on the property bag's calendar"); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-constructor-in-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-constructor-in-calendar-fields.js deleted file mode 100644 index fca8011afe1..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-constructor-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: If a calendar's fields() method returns a field named 'constructor', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['constructor']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.eraYear(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-duplicate-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-duplicate-calendar-fields.js deleted file mode 100644 index 50a64c8a3b1..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-duplicate-calendar-fields.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: If a calendar's fields() method returns duplicate field names, PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -for (const extra_fields of [['foo', 'foo'], ['day'], ['month'], ['monthCode'], ['year']]) { - const calendar = TemporalHelpers.calendarWithExtraFields(extra_fields); - const arg = { year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar }; - const instance = new Temporal.Calendar("iso8601"); - - assert.throws(RangeError, () => instance.eraYear(arg)); -} diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-leap-second.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-leap-second.js deleted file mode 100644 index 3d1fabe6c2b..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-leap-second.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Leap second is a valid ISO string for PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -let arg = "2016-12-31T23:59:60"; -const result1 = instance.eraYear(arg); -assert.sameValue( - result1, - undefined, - "leap second is a valid ISO string for PlainDate" -); - -arg = { year: 2016, month: 12, day: 31, hour: 23, minute: 59, second: 60 }; -const result2 = instance.eraYear(arg); -assert.sameValue( - result2, - undefined, - "second: 60 is ignored in property bag for PlainDate" -); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-number.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-number.js deleted file mode 100644 index ec8903e125c..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-number.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: A number cannot be used in place of a Temporal.PlainDate -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19761118, - -19761118, - 1234567890, -]; - -for (const arg of numbers) { - assert.throws( - TypeError, - () => instance.eraYear(arg), - 'Numbers cannot be used in place of an ISO string for PlainDate' - ); -} diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-case-insensitive.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-case-insensitive.js deleted file mode 100644 index c25f3bf4ae5..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-case-insensitive.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: The calendar name is case-insensitive -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "IsO8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.eraYear(arg); -assert.sameValue(result, undefined, "Calendar is case-insensitive"); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js deleted file mode 100644 index f367f44a568..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-iso-string.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: An ISO 8601 string can be converted to a calendar ID in Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -for (const calendar of [ - "2020-01-01", - "2020-01-01[u-ca=iso8601]", - "2020-01-01T00:00:00.000000000", - "2020-01-01T00:00:00.000000000[u-ca=iso8601]", - "01-01", - "01-01[u-ca=iso8601]", - "2020-01", - "2020-01[u-ca=iso8601]", -]) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - const result = instance.eraYear(arg); - assert.sameValue(result, undefined, `Calendar created from string "${calendar}"`); -} diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-leap-second.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-leap-second.js deleted file mode 100644 index 9f27c8d8daa..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-leap-second.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Leap second is a valid ISO string for a calendar in a property bag -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "2016-12-31T23:59:60"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.eraYear(arg); -assert.sameValue( - result, - undefined, - "leap second is a valid ISO string for calendar" -); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-number.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-number.js deleted file mode 100644 index 190e3f6427a..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-number.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: A number as calendar in a property bag is not accepted -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const numbers = [ - 1, - 19970327, - -19970327, - 1234567890, -]; - -for (const calendar of numbers) { - const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; - assert.throws( - TypeError, - () => instance.eraYear(arg), - "Numbers cannot be used as a calendar" - ); -} diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-string.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-string.js deleted file mode 100644 index dab3adfc1c8..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-string.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: A calendar ID is valid input for Calendar -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const calendar = "iso8601"; - -const arg = { year: 1976, monthCode: "M11", day: 18, calendar }; -const result = instance.eraYear(arg); -assert.sameValue(result, undefined, `Calendar created from string "${calendar}"`); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-wrong-type.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-wrong-type.js deleted file mode 100644 index 3ca62d1d64a..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-wrong-type.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: > - Appropriate error thrown when a calendar property from a property bag cannot - be converted to a calendar object or string -features: [BigInt, Symbol, Temporal] ----*/ - -const timeZone = new Temporal.TimeZone("UTC"); -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [calendar, description] of primitiveTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws( - typeof calendar === 'string' ? RangeError : TypeError, - () => instance.eraYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object that doesn't implement the protocol"], - [new Temporal.TimeZone("UTC"), "time zone instance"], - [Temporal.Calendar, "Temporal.Calendar, object"], - [Temporal.Calendar.prototype, "Temporal.Calendar.prototype, object"], // fails brand check in dateFromFields() -]; - -for (const [calendar, description] of typeErrorTests) { - const arg = { year: 2019, monthCode: "M11", day: 1, calendar }; - assert.throws(TypeError, () => instance.eraYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js deleted file mode 100644 index d3ca806afdb..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-propertybag-calendar-year-zero.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T17:45", - "-000000-10-31T17:45Z", - "-000000-10-31T17:45+01:00", - "-000000-10-31T17:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((str) => { - const arg = { year: 1976, month: 11, day: 18, calendar: str }; - assert.throws( - RangeError, - () => instance.eraYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-proto-in-calendar-fields.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-proto-in-calendar-fields.js deleted file mode 100644 index 37e03e67d04..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-proto-in-calendar-fields.js +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: If a calendar's fields() method returns a field named '__proto__', PrepareTemporalFields should throw a RangeError. -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarWithExtraFields(['__proto__']); -const arg = {year: 2023, month: 5, monthCode: 'M05', day: 1, calendar: calendar}; -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(RangeError, () => instance.eraYear(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js deleted file mode 100644 index ac1c686e8b2..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation-invalid-key.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Annotation keys are lowercase-only -features: [Temporal] ----*/ - -const invalidStrings = [ - ["1970-01-01[U-CA=iso8601]", "invalid capitalized key"], - ["1970-01-01[u-CA=iso8601]", "invalid partially-capitalized key"], - ["1970-01-01[FOO=bar]", "invalid capitalized unrecognized key"], -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach(([arg, descr]) => { - assert.throws( - RangeError, - () => instance.eraYear(arg), - `annotation keys must be lowercase: ${arg} - ${descr}` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation.js deleted file mode 100644 index d2d6ed0a2c9..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-calendar-annotation.js +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Various forms of calendar annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[u-ca=iso8601]", "without time or time zone"], - ["2000-05-02[UTC][u-ca=iso8601]", "with time zone and no time"], - ["2000-05-02T15:23[u-ca=iso8601]", "without time zone"], - ["2000-05-02T15:23[UTC][u-ca=iso8601]", "with time zone"], - ["2000-05-02T15:23[!u-ca=iso8601]", "with ! and no time zone"], - ["2000-05-02T15:23[UTC][!u-ca=iso8601]", "with ! and time zone"], - ["2000-05-02T15:23[u-ca=iso8601][u-ca=discord]", "second annotation ignored"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.eraYear(arg); - - assert.sameValue( - result, - undefined, - `calendar annotation (${description})` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-critical-unknown-annotation.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-critical-unknown-annotation.js deleted file mode 100644 index c1af895dc21..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-critical-unknown-annotation.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Unknown annotations with critical flag are rejected -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[!foo=bar]", - "1970-01-01T00:00[!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar]", - "1970-01-01T00:00[u-ca=iso8601][!foo=bar]", - "1970-01-01T00:00[UTC][!foo=bar][u-ca=iso8601]", - "1970-01-01T00:00[foo=bar][!_foo-bar0=Dont-Ignore-This-99999999999]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.eraYear(arg), - `reject unknown annotation with critical flag: ${arg}` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-date-with-utc-offset.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-date-with-utc-offset.js deleted file mode 100644 index fa453e180c8..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-date-with-utc-offset.js +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: UTC offset not valid with format that does not include a time -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const validStrings = [ - "2000-05-02T00+00:00", - "2000-05-02T00+00:00[UTC]", - "2000-05-02T00+00:00[!UTC]", - "2000-05-02T00-02:30[America/St_Johns]", -]; - -for (const arg of validStrings) { - const result = instance.eraYear(arg); - - assert.sameValue( - result, - undefined, - `"${arg}" is a valid UTC offset with time for PlainDate` - ); -} - -const invalidStrings = [ - "2022-09-15Z", - "2022-09-15Z[UTC]", - "2022-09-15Z[Europe/Vienna]", - "2022-09-15+00:00", - "2022-09-15+00:00[UTC]", - "2022-09-15-02:30", - "2022-09-15-02:30[America/St_Johns]", -]; - -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.eraYear(arg), - `"${arg}" UTC offset without time is not valid for PlainDate` - ); -} diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-invalid.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-invalid.js deleted file mode 100644 index 6b3f65b9ea4..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-invalid.js +++ /dev/null @@ -1,61 +0,0 @@ -// Copyright (C) 2022 Igalia S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: > - RangeError thrown if an invalid ISO string (or syntactically valid ISO string - that is not supported) is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - // invalid ISO strings: - "", - "invalid iso8601", - "2020-01-00", - "2020-01-32", - "2020-02-30", - "2021-02-29", - "2020-00-01", - "2020-13-01", - "2020-01-01T", - "2020-01-01T25:00:00", - "2020-01-01T01:60:00", - "2020-01-01T01:60:61", - "2020-01-01junk", - "2020-01-01T00:00:00junk", - "2020-01-01T00:00:00+00:00junk", - "2020-01-01T00:00:00+00:00[UTC]junk", - "2020-01-01T00:00:00+00:00[UTC][u-ca=iso8601]junk", - "02020-01-01", - "2020-001-01", - "2020-01-001", - "2020-01-01T001", - "2020-01-01T01:001", - "2020-01-01T01:01:001", - // valid, but forms not supported in Temporal: - "2020-W01-1", - "2020-001", - "+0002020-01-01", - // valid, but this calendar must not exist: - "2020-01-01[u-ca=notexist]", - // may be valid in other contexts, but insufficient information for PlainDate: - "2020-01", - "+002020-01", - "01-01", - "2020-W01", - "P1Y", - "-P12Y", - // valid, but outside the supported range: - "-999999-01-01", - "+999999-01-01", -]; -const instance = new Temporal.Calendar("iso8601"); -for (const arg of invalidStrings) { - assert.throws( - RangeError, - () => instance.eraYear(arg), - `"${arg}" should not be a valid ISO string for a PlainDate` - ); -} diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-calendar.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-calendar.js deleted file mode 100644 index 7886e01eb05..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-calendar.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: > - More than one calendar annotation is not syntactical if any have the criical - flag -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01[u-ca=iso8601][foo=bar][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[!u-ca=iso8601][u-ca=iso8601]", - "1970-01-01T00:00[UTC][u-ca=iso8601][!u-ca=iso8601]", - "1970-01-01T00:00[u-ca=iso8601][foo=bar][!u-ca=iso8601]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.eraYear(arg), - `reject more than one calendar annotation if any critical: ${arg}` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-time-zone.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-time-zone.js deleted file mode 100644 index a0ad58f7a9b..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-multiple-time-zone.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: More than one time zone annotation is not syntactical -features: [Temporal] ----*/ - -const invalidStrings = [ - "1970-01-01[UTC][UTC]", - "1970-01-01T00:00[UTC][UTC]", - "1970-01-01T00:00[!UTC][UTC]", - "1970-01-01T00:00[UTC][!UTC]", - "1970-01-01T00:00[UTC][u-ca=iso8601][UTC]", - "1970-01-01T00:00[UTC][foo=bar][UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.eraYear(arg), - `reject more than one time zone annotation: ${arg}` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-separators.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-separators.js deleted file mode 100644 index 3ff00ff98b1..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-separators.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Time separator in string argument can vary -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02T15:23", "uppercase T"], - ["2000-05-02t15:23", "lowercase T"], - ["2000-05-02 15:23", "space between date and time"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.eraYear(arg); - - assert.sameValue( - result, - undefined, - `variant time separators (${description})` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-zone-annotation.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-zone-annotation.js deleted file mode 100644 index 14a71d5268d..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-time-zone-annotation.js +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Various forms of time zone annotation; critical flag has no effect -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[Asia/Kolkata]", "named, with no time"], - ["2000-05-02[!Europe/Vienna]", "named, with ! and no time"], - ["2000-05-02[+00:00]", "numeric, with no time"], - ["2000-05-02[!-02:30]", "numeric, with ! and no time"], - ["2000-05-02T15:23[America/Sao_Paulo]", "named, with no offset"], - ["2000-05-02T15:23[!Asia/Tokyo]", "named, with ! and no offset"], - ["2000-05-02T15:23[-02:30]", "numeric, with no offset"], - ["2000-05-02T15:23[!+00:00]", "numeric, with ! and no offset"], - ["2000-05-02T15:23+00:00[America/New_York]", "named, with offset"], - ["2000-05-02T15:23+00:00[!UTC]", "named, with offset and !"], - ["2000-05-02T15:23+00:00[+01:00]", "numeric, with offset"], - ["2000-05-02T15:23+00:00[!-08:00]", "numeric, with offset and !"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.eraYear(arg); - - assert.sameValue( - result, - undefined, - `time zone annotation (${description})` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-unknown-annotation.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-unknown-annotation.js deleted file mode 100644 index d98a8537b09..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-unknown-annotation.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Various forms of unknown annotation -features: [Temporal] ----*/ - -const tests = [ - ["2000-05-02[foo=bar]", "without time"], - ["2000-05-02T15:23[foo=bar]", "alone"], - ["2000-05-02T15:23[UTC][foo=bar]", "with time zone"], - ["2000-05-02T15:23[u-ca=iso8601][foo=bar]", "with calendar"], - ["2000-05-02T15:23[UTC][foo=bar][u-ca=iso8601]", "with time zone and calendar"], - ["2000-05-02T15:23[foo=bar][_foo-bar0=Ignore-This-999999999999]", "with another unknown annotation"], -]; - -const instance = new Temporal.Calendar("iso8601"); - -tests.forEach(([arg, description]) => { - const result = instance.eraYear(arg); - - assert.sameValue( - result, - undefined, - `unknown annotation (${description})` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-with-utc-designator.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-with-utc-designator.js deleted file mode 100644 index a02303876a9..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-string-with-utc-designator.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: RangeError thrown if a string with UTC designator is used as a PlainDate -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "2019-10-01T09:00:00Z", - "2019-10-01T09:00:00Z[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.eraYear(arg), - "String with UTC designator should not be valid as a PlainDate" - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-wrong-type.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-wrong-type.js deleted file mode 100644 index 8cff13438a6..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-wrong-type.js +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: > - Appropriate error thrown when argument cannot be converted to a valid string - or property bag for PlainDate -features: [BigInt, Symbol, Temporal] ----*/ - -const instance = new Temporal.Calendar("iso8601"); - -const primitiveTests = [ - [undefined, "undefined"], - [null, "null"], - [true, "boolean"], - ["", "empty string"], - [1, "number that doesn't convert to a valid ISO string"], - [1n, "bigint"], -]; - -for (const [arg, description] of primitiveTests) { - assert.throws( - typeof arg === 'string' ? RangeError : TypeError, - () => instance.eraYear(arg), - `${description} does not convert to a valid ISO string` - ); -} - -const typeErrorTests = [ - [Symbol(), "symbol"], - [{}, "plain object"], - [Temporal.PlainDate, "Temporal.PlainDate, object"], - [Temporal.PlainDate.prototype, "Temporal.PlainDate.prototype, object"], -]; - -for (const [arg, description] of typeErrorTests) { - assert.throws(TypeError, () => instance.eraYear(arg), `${description} is not a valid property bag and does not convert to a string`); -} diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-convert.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-convert.js deleted file mode 100644 index 5fad6b75198..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-convert.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: An exception from TimeZone#getOffsetNanosecondsFor() is propagated. -features: [Temporal] ----*/ - -class TZ extends Temporal.TimeZone { - constructor() { super("UTC") } - getOffsetNanosecondsFor() { throw new Test262Error() } -} - -const tz = new TZ(); -const arg = new Temporal.ZonedDateTime(0n, tz); -const instance = new Temporal.Calendar("iso8601"); - -assert.throws(Test262Error, () => instance.eraYear(arg)); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-slots.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-slots.js deleted file mode 100644 index 341cdf1db41..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-slots.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Getters are not called when converting a ZonedDateTime to a PlainDate. -includes: [compareArray.js] -features: [Temporal] ----*/ - -const actual = []; -const prototypeDescrs = Object.getOwnPropertyDescriptors(Temporal.ZonedDateTime.prototype); -const getters = ["year", "month", "monthCode", "day", "hour", "minute", "second", "millisecond", "microsecond", "nanosecond", "calendar"]; - -for (const property of getters) { - Object.defineProperty(Temporal.ZonedDateTime.prototype, property, { - get() { - actual.push(`get ${property}`); - const value = prototypeDescrs[property].get.call(this); - return { - toString() { - actual.push(`toString ${property}`); - return value.toString(); - }, - valueOf() { - actual.push(`valueOf ${property}`); - return value; - }, - }; - }, - }); -} - -const arg = new Temporal.ZonedDateTime(0n, "UTC"); -const instance = new Temporal.Calendar("iso8601"); -instance.eraYear(arg); -assert.compareArray(actual, []); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index c2bdc64b613..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.eraYear(datetime)); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index db61eef965b..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => calendar.eraYear(datetime), - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index e7475b285b0..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => calendar.eraYear(datetime)); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index f741a91206d..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-zoneddatetime-timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const calendar = new Temporal.Calendar("iso8601"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => calendar.eraYear(datetime)); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/branding.js b/test/intl402/Temporal/Calendar/prototype/eraYear/branding.js deleted file mode 100644 index 8bd9c313ff6..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/branding.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Throw a TypeError if the receiver is invalid -features: [Symbol, Temporal] ----*/ - -const eraYear = Temporal.Calendar.prototype.eraYear; - -assert.sameValue(typeof eraYear, "function"); - -assert.throws(TypeError, () => eraYear.call(undefined), "undefined"); -assert.throws(TypeError, () => eraYear.call(null), "null"); -assert.throws(TypeError, () => eraYear.call(true), "true"); -assert.throws(TypeError, () => eraYear.call(""), "empty string"); -assert.throws(TypeError, () => eraYear.call(Symbol()), "symbol"); -assert.throws(TypeError, () => eraYear.call(1), "1"); -assert.throws(TypeError, () => eraYear.call({}), "plain object"); -assert.throws(TypeError, () => eraYear.call(Temporal.Calendar), "Temporal.Calendar"); -assert.throws(TypeError, () => eraYear.call(Temporal.Calendar.prototype), "Temporal.Calendar.prototype"); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/builtin.js b/test/intl402/Temporal/Calendar/prototype/eraYear/builtin.js deleted file mode 100644 index 234fe88aea9..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/builtin.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: > - Tests that Temporal.Calendar.prototype.eraYear - meets the requirements for built-in objects defined by the - introduction of chapter 17 of the ECMAScript Language Specification. -info: | - Built-in functions that are not constructors do not have a "prototype" property unless - otherwise specified in the description of a particular function. - - Unless specified otherwise, a built-in object that is callable as a function is a built-in - function object with the characteristics described in 10.3. Unless specified otherwise, the - [[Extensible]] internal slot of a built-in object initially has the value true. - - Unless otherwise specified every built-in function and every built-in constructor has the - Function prototype object [...] as the value of its [[Prototype]] internal slot. -features: [Temporal] ----*/ - -assert.sameValue(Object.isExtensible(Temporal.Calendar.prototype.eraYear), - true, "Built-in objects must be extensible."); - -assert.sameValue(Object.prototype.toString.call(Temporal.Calendar.prototype.eraYear), - "[object Function]", "Object.prototype.toString"); - -assert.sameValue(Object.getPrototypeOf(Temporal.Calendar.prototype.eraYear), - Function.prototype, "prototype"); - -assert.sameValue(Temporal.Calendar.prototype.eraYear.hasOwnProperty("prototype"), - false, "prototype property"); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/calendar-datefromfields-called-with-options-undefined.js b/test/intl402/Temporal/Calendar/prototype/eraYear/calendar-datefromfields-called-with-options-undefined.js deleted file mode 100644 index a2c9fa6645e..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/calendar-datefromfields-called-with-options-undefined.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: > - Calendar.dateFromFields method is called with undefined as the options value - when call originates internally -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const calendar = TemporalHelpers.calendarFromFieldsUndefinedOptions(); -calendar.eraYear({ year: 2000, month: 5, day: 3, calendar }); -assert.sameValue(calendar.dateFromFieldsCallCount, 1); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/eraYear/infinity-throws-rangeerror.js deleted file mode 100644 index 1d20c67e7ba..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.erayear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.eraYear({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.eraYear({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/length.js b/test/intl402/Temporal/Calendar/prototype/eraYear/length.js deleted file mode 100644 index b65243ef4ba..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/length.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Temporal.Calendar.prototype.eraYear.length is 1 -info: | - Every built-in function object, including constructors, has a "length" property whose value is - an integer. Unless otherwise specified, this value is equal to the largest number of named - arguments shown in the subclause headings for the function description. Optional parameters - (which are indicated with brackets: [ ]) or rest parameters (which are shown using the form - «...name») are not included in the default argument count. - - Unless otherwise specified, the "length" property of a built-in function object has the - attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.eraYear, "length", { - value: 1, - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/name.js b/test/intl402/Temporal/Calendar/prototype/eraYear/name.js deleted file mode 100644 index dc9c0ffde5c..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/name.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Temporal.Calendar.prototype.eraYear.name is "eraYear". -info: | - Every built-in function object, including constructors, that is not identified as an anonymous - function has a "name" property whose value is a String. Unless otherwise specified, this value - is the name that is given to the function in this specification. - - Unless otherwise specified, the "name" property of a built-in function object, if it exists, - has the attributes { [[Writable]]: false, [[Enumerable]]: false, [[Configurable]]: true }. -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -verifyProperty(Temporal.Calendar.prototype.eraYear, "name", { - value: "eraYear", - writable: false, - enumerable: false, - configurable: true, -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/not-a-constructor.js b/test/intl402/Temporal/Calendar/prototype/eraYear/not-a-constructor.js deleted file mode 100644 index a227a177d11..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/not-a-constructor.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: > - Temporal.Calendar.prototype.eraYear does not implement [[Construct]], is not new-able -info: | - Built-in function objects that are not identified as constructors do not implement the - [[Construct]] internal method unless otherwise specified in the description of a particular - function. -includes: [isConstructor.js] -features: [Reflect.construct, Temporal] ----*/ - -assert.throws(TypeError, () => { - new Temporal.Calendar.prototype.eraYear(); -}, "Calling as constructor"); - -assert.sameValue(isConstructor(Temporal.Calendar.prototype.eraYear), false, - "isConstructor(Temporal.Calendar.prototype.eraYear)"); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/prop-desc.js b/test/intl402/Temporal/Calendar/prototype/eraYear/prop-desc.js deleted file mode 100644 index 9d857298554..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/prop-desc.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: The "eraYear" property of Temporal.Calendar.prototype -includes: [propertyHelper.js] -features: [Temporal] ----*/ - -assert.sameValue( - typeof Temporal.Calendar.prototype.eraYear, - "function", - "`typeof Calendar.prototype.eraYear` is `function`" -); - -verifyProperty(Temporal.Calendar.prototype, "eraYear", { - writable: true, - enumerable: false, - configurable: true, -}); diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/year-zero.js b/test/intl402/Temporal/Calendar/prototype/eraYear/year-zero.js deleted file mode 100644 index 52cb511a15d..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/eraYear/year-zero.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.erayear -description: Negative zero, as an extended year, is rejected -features: [Temporal, arrow-function] ----*/ - -const invalidStrings = [ - "-000000-10-31", - "-000000-10-31T00:45", - "-000000-10-31T00:45+01:00", - "-000000-10-31T00:45+00:00[UTC]", -]; -const instance = new Temporal.Calendar("iso8601"); -invalidStrings.forEach((arg) => { - assert.throws( - RangeError, - () => instance.eraYear(arg), - "reject minus zero as extended year" - ); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/inLeapYear/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/inLeapYear/infinity-throws-rangeerror.js deleted file mode 100644 index 7b35c962818..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/inLeapYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.inleapyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.inLeapYear({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.inLeapYear({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/mergeFields/gregorian-mutually-exclusive-fields.js b/test/intl402/Temporal/Calendar/prototype/mergeFields/gregorian-mutually-exclusive-fields.js deleted file mode 100644 index ffb5e1c0679..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/mergeFields/gregorian-mutually-exclusive-fields.js +++ /dev/null @@ -1,105 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: Calendar-specific mutually exclusive keys in mergeFields -features: [Temporal] ----*/ - -function assertEntriesEqual(actual, expectedEntries, message) { - const names = Object.getOwnPropertyNames(actual); - const symbols = Object.getOwnPropertySymbols(actual); - const actualKeys = names.concat(symbols); - assert.sameValue( - actualKeys.length, - expectedEntries.length, - `${message}: expected object to have ${expectedEntries.length} properties, not ${actualKeys.length}:` - ); - for (var index = 0; index < actualKeys.length; index++) { - const actualKey = actualKeys[index]; - const expectedKey = expectedEntries[index][0]; - const expectedValue = expectedEntries[index][1]; - assert.sameValue(actualKey, expectedKey, `${message}: key ${index}:`); - assert.sameValue(actual[actualKey], expectedValue, `${message}: value ${index}:`); - } -} - -const instance = new Temporal.Calendar("gregory"); - -const fullFields = { - era: "ce", - eraYear: 1981, - year: 1981, - month: 12, - monthCode: "M12", - day: 15, -}; - -assertEntriesEqual(instance.mergeFields(fullFields, { era: "bce", eraYear: 1 }), [ - ["era", "bce"], - ["eraYear", 1], - ["month", 12], - ["monthCode", "M12"], - ["day", 15], -], "era and eraYear together exclude year"); - -assertEntriesEqual(instance.mergeFields(fullFields, { year: -2 }), [ - ["year", -2], - ["month", 12], - ["monthCode", "M12"], - ["day", 15], -], "year excludes era and eraYear"); - -assertEntriesEqual(instance.mergeFields(fullFields, { month: 5 }), [ - ["era", "ce"], - ["eraYear", 1981], - ["year", 1981], - ["month", 5], - ["day", 15], -], "month excludes monthCode"); - -assertEntriesEqual(instance.mergeFields(fullFields, { monthCode: "M05" }), [ - ["era", "ce"], - ["eraYear", 1981], - ["year", 1981], - ["monthCode", "M05"], - ["day", 15], -], "monthCode excludes month"); - -// Specific test cases, of mergeFields on information that is not complete -// enough to construct a PlainDate from, as discussed in -// https://github.com/tc39/proposal-temporal/issues/2407: - -assertEntriesEqual(instance.mergeFields({ day: 25, monthCode: "M12", year: 1997, era: "bce" }, { eraYear: 1 }), [ - ["day", 25], - ["monthCode", "M12"], - ["eraYear", 1], -], "eraYear excludes year and era"); - -assertEntriesEqual(instance.mergeFields({ day: 25, monthCode: "M12", era: "bce" }, { eraYear: 1, year: 1997 }), [ - ["day", 25], - ["monthCode", "M12"], - ["eraYear", 1], - ["year", 1997], -], "eraYear and year both exclude era"); - -assertEntriesEqual(instance.mergeFields({ day: 25, monthCode: "M12", eraYear: 1 }, { era: "bce", year: 1997 }), [ - ["day", 25], - ["monthCode", "M12"], - ["era", "bce"], - ["year", 1997], -], "era and year both exclude eraYear"); - -assertEntriesEqual(instance.mergeFields({ day: 25, monthCode: "M12", year: 1997, eraYear: 1 }, { era: "bce" }), [ - ["day", 25], - ["monthCode", "M12"], - ["era", "bce"], -], "era excludes year and eraYear"); - -assertEntriesEqual(instance.mergeFields({ day: 25, monthCode: "M12", year: 1997 }, { eraYear: 1, year: 2 }), [ - ["day", 25], - ["monthCode", "M12"], - ["year", 2], - ["eraYear", 1], -], "eraYear excludes year and era, year overwritten"); diff --git a/test/intl402/Temporal/Calendar/prototype/mergeFields/japanese-mutually-exclusive-fields.js b/test/intl402/Temporal/Calendar/prototype/mergeFields/japanese-mutually-exclusive-fields.js deleted file mode 100644 index 4dcb0a30e2e..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/mergeFields/japanese-mutually-exclusive-fields.js +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.mergefields -description: Calendar-specific mutually exclusive keys in mergeFields -features: [Temporal] ----*/ - -function assertEntriesEqual(actual, expectedEntries, message) { - const names = Object.getOwnPropertyNames(actual); - const symbols = Object.getOwnPropertySymbols(actual); - const actualKeys = names.concat(symbols); - assert.sameValue( - actualKeys.length, - expectedEntries.length, - `${message}: expected object to have ${expectedEntries.length} properties, not ${actualKeys.length}:` - ); - for (var index = 0; index < actualKeys.length; index++) { - const actualKey = actualKeys[index]; - const expectedKey = expectedEntries[index][0]; - const expectedValue = expectedEntries[index][1]; - assert.sameValue(actualKey, expectedKey, `${message}: key ${index}:`); - assert.sameValue(actual[actualKey], expectedValue, `${message}: value ${index}:`); - } -} - -const instance = new Temporal.Calendar("japanese"); - -const lastDayOfShowaFields = { era: "showa", eraYear: 64, year: 1989, month: 1, monthCode: "M01", day: 7 }; - -assertEntriesEqual(instance.mergeFields(lastDayOfShowaFields, { day: 10 }), [ - ["year", 1989], - ["month", 1], - ["monthCode", "M01"], - ["day", 10], -], "day excludes era and eraYear"); - -assertEntriesEqual(instance.mergeFields(lastDayOfShowaFields, { month: 2 }), [ - ["year", 1989], - ["month", 2], - ["day", 7], -], "month excludes monthCode, era, and eraYear"); - -assertEntriesEqual(instance.mergeFields(lastDayOfShowaFields, { monthCode: "M03" }), [ - ["year", 1989], - ["monthCode", "M03"], - ["day", 7], -], "monthCode excludes month, era, and eraYear"); - -assertEntriesEqual(instance.mergeFields(lastDayOfShowaFields, { year: 1988 }), [ - ["year", 1988], - ["month", 1], - ["monthCode", "M01"], - ["day", 7], -], "year excludes era and eraYear (within same era)"); - -assertEntriesEqual(instance.mergeFields(lastDayOfShowaFields, { year: 1990 }), [ - ["year", 1990], - ["month", 1], - ["monthCode", "M01"], - ["day", 7], -], "year excludes era and eraYear (in a different era)"); - -assertEntriesEqual(instance.mergeFields(lastDayOfShowaFields, { eraYear: 1 }), [ - ["eraYear", 1], - ["month", 1], - ["monthCode", "M01"], - ["day", 7], -], "eraYear excludes year and era"); - -assertEntriesEqual(instance.mergeFields(lastDayOfShowaFields, { era: "heisei" }), [ - ["era", "heisei"], - ["month", 1], - ["monthCode", "M01"], - ["day", 7], -], "era excludes year and eraYear"); diff --git a/test/intl402/Temporal/Calendar/prototype/month/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/month/infinity-throws-rangeerror.js deleted file mode 100644 index 6303b19aa81..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/month/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.month -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.month({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.month({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/monthCode/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/monthCode/infinity-throws-rangeerror.js deleted file mode 100644 index 0723a48a3be..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/monthCode/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.monthcode -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.monthCode({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.monthCode({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/infinity-throws-rangeerror.js deleted file mode 100644 index d25aed49656..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.monthdayfromfields -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - ["constrain", "reject"].forEach((overflow) => { - assert.throws(RangeError, () => instance.monthDayFromFields({ ...base, eraYear: inf }, { overflow }), `eraYear property cannot be ${inf} (overflow ${overflow}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.monthDayFromFields({ ...base, eraYear: obj }, { overflow })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/order-of-operations.js b/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/order-of-operations.js deleted file mode 100644 index 1dd4fe9eaa5..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/order-of-operations.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Properties on objects passed to monthDayFromFields() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get fields.day", - "get fields.day.valueOf", - "call fields.day.valueOf", - "get fields.era", - "get fields.era.toString", - "call fields.era.toString", - "get fields.eraYear", - "get fields.eraYear.valueOf", - "call fields.eraYear.valueOf", - "get fields.month", - "get fields.month.valueOf", - "call fields.month.valueOf", - "get fields.monthCode", - "get fields.monthCode.toString", - "call fields.monthCode.toString", - "get fields.year", - "get fields.year.valueOf", - "call fields.year.valueOf", - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; -const actual = []; - -const instance = new Temporal.Calendar("gregory"); - -const fields = { - era: "ce", - eraYear: 1.7, - year: 1.7, - month: 1.7, - monthCode: "M01", - day: 1.7, -}; -const arg1 = new Proxy(fields, { - get(target, key) { - actual.push(`get fields.${key}`); - if (key === "calendar") return instance; - const result = target[key]; - return TemporalHelpers.toPrimitiveObserver(actual, result, `fields.${key}`); - }, - has(target, key) { - actual.push(`has fields.${key}`); - return key in target; - }, -}); - -const options = { - overflow: "reject", -}; -const arg2 = new Proxy(options, { - get(target, key) { - actual.push(`get options.${key}`); - return TemporalHelpers.toPrimitiveObserver(actual, target[key], `options.${key}`); - }, - has(target, key) { - actual.push(`has options.${key}`); - return key in target; - }, -}); - -const result = instance.monthDayFromFields(arg1, arg2); -TemporalHelpers.assertPlainMonthDay(result, "M01", 1, "monthDay result"); -assert.sameValue(result.getISOFields().calendar, "gregory", "calendar slot should store a string"); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/reference-year-1972.js b/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/reference-year-1972.js deleted file mode 100644 index 4e2ac6532dd..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/reference-year-1972.js +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields -description: Deterministic choosing of the reference year -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const gregory = new Temporal.Calendar("gregory"); - -const result1 = gregory.monthDayFromFields({ year: 2021, monthCode: "M02", day: 29 }); -TemporalHelpers.assertPlainMonthDay( - result1, "M02", 29, - "year is ignored and reference year should be 1972 if monthCode is given", - 1972 -); - -const result2 = gregory.monthDayFromFields({ year: 2021, month: 2, day: 29 }, { overflow: "constrain" }); -TemporalHelpers.assertPlainMonthDay( - result2, "M02", 28, - "if monthCode is not given, year is used to determine if calendar date exists, but reference year should still be 1972", - 1972 -); - -assert.throws( - RangeError, - () => gregory.monthDayFromFields({ year: 2021, month: 2, day: 29 }, { overflow: "reject" }), - "RangeError thrown if calendar date does not exist in given year and overflow is reject" -); - -const hebrew = new Temporal.Calendar("hebrew"); - -const result3 = hebrew.monthDayFromFields({ monthCode: "M01", day: 1 }); -TemporalHelpers.assertPlainMonthDay( - result3, "M01", 1, - "reference year should be 1972 if date exists in 1972", - 1972 -); - -const result4 = hebrew.monthDayFromFields({ monthCode: "M05L", day: 1 }); -TemporalHelpers.assertPlainMonthDay( - result4, "M05L", 1, - "reference year should be the latest ISO year before 1972 if date does not exist in 1972", - 1970 -); - -const result5 = hebrew.monthDayFromFields({ year: 5781, monthCode: "M02", day: 30 }); -TemporalHelpers.assertPlainMonthDay( - result5, "M02", 30, - "year is ignored if monthCode is given (Cheshvan 5781 has 29 days)", - 1971 -); - -const result6 = hebrew.monthDayFromFields({ year: 5781, month: 2, day: 30 }, { overflow: "constrain" }); -TemporalHelpers.assertPlainMonthDay( - result6, "M02", 29, - "if monthCode is not given, year is used to determine if calendar date exists, but reference year still correct", - 1972 -); - -assert.throws( - RangeError, - () => hebrew.monthDayFromFields({ year: 5781, month: 2, day: 30 }, { overflow: "reject" }), - "RangeError thrown if calendar date does not exist in given year and overflow is reject" -); - -const result7 = hebrew.monthDayFromFields({ monthCode: "M04", day: 26 }); -TemporalHelpers.assertPlainMonthDay( - result7, "M04", 26, - "reference date should be the later one, if two options exist in ISO year 1972", - 1972 -); -assert.sameValue(result7.getISOFields().isoMonth, 12, "reference date should be 1972-12-31"); -assert.sameValue(result7.getISOFields().isoDay, 31, "reference date should be 1972-12-31"); diff --git a/test/intl402/Temporal/Calendar/prototype/monthsInYear/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/monthsInYear/infinity-throws-rangeerror.js deleted file mode 100644 index 20f63ef9dc3..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/monthsInYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.monthsinyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.monthsInYear({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.monthsInYear({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js b/test/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js deleted file mode 100644 index 1b2d2d3d4b9..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/weekOfYear/gregory-iso-weekofyear.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - In the ISO 8601 week calendar, calendar week number 1 of a calendar year is - the week including the first Thursday of that year (based on the principle - that a week belongs to the same calendar year as the majority of its calendar - days). Because of this, some calendar days of the first calendar week of a - calendar year may be part of the preceding date calendar year, and some - calendar days of the last calendar week of a calendar year may be part of - the next calendar year. -features: [Temporal] ----*/ - -// - -let calendar = new Temporal.Calendar("gregory"); -const date = { month: 1, day: 1, year: 2021, calendar}; - -assert.sameValue(calendar.weekOfYear({...date}), 1); - -calendar = new Temporal.Calendar("iso8601"); -const isodate = { month: 1, day: 1, year: 2021, calendar}; - -assert.sameValue(calendar.weekOfYear({...isodate}), 53); diff --git a/test/intl402/Temporal/Calendar/prototype/weekOfYear/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/weekOfYear/infinity-throws-rangeerror.js deleted file mode 100644 index 63b892aa862..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/weekOfYear/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.weekofyear -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.weekOfYear({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.weekOfYear({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js b/test/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js deleted file mode 100644 index f36305b29a2..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/weekOfYear/non-iso-week-of-year.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.weekofyear -description: > - Temporal.Calendar.prototype.weekOfYear returns undefined for all - non-ISO calendars without a well-defined week numbering system. -features: [Temporal] ----*/ - -// Gregorian calendar has a well defined week-numbering system. - -let calendar = new Temporal.Calendar("gregory"); -const date = { month: 1, day: 1, year: 2024, calendar}; - -assert.sameValue(calendar.weekOfYear({...date}), 1); - -calendar = new Temporal.Calendar("hebrew"); -const nonisodate = { month: 1, day: 1, year: 2024, calendar}; - -assert.sameValue(calendar.weekOfYear({...nonisodate}), undefined); diff --git a/test/intl402/Temporal/Calendar/prototype/year/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/year/infinity-throws-rangeerror.js deleted file mode 100644 index 0993a4ec332..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/year/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.year -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.year({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.year({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/infinity-throws-rangeerror.js deleted file mode 100644 index d883bb2b9a6..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/infinity-throws-rangeerror.js +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.yearmonthfromfields -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - ["constrain", "reject"].forEach((overflow) => { - assert.throws(RangeError, () => instance.yearMonthFromFields({ ...base, eraYear: inf }, { overflow }), `eraYear property cannot be ${inf} (overflow ${overflow}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.yearMonthFromFields({ ...base, eraYear: obj }, { overflow })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); - }); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/one-of-era-erayear-undefined.js b/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/one-of-era-erayear-undefined.js deleted file mode 100644 index 8d8be9bbd7f..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/one-of-era-erayear-undefined.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Throw a TypeError if only one of era/eraYear fields is present -features: [Temporal] ----*/ - -const base = { year: 2000, month: 5, day: 2, era: 'ce' }; -const instance = new Temporal.Calendar('gregory'); -assert.throws(TypeError, () => { - instance.yearMonthFromFields({ ...base }); -}); - -const base2 = { year: 2000, month: 5, day: 2, eraYear: 1 }; -assert.throws(TypeError, () => { - instance.yearMonthFromFields({ ...base2 }); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/order-of-operations.js b/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/order-of-operations.js deleted file mode 100644 index 48d7390b2eb..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/order-of-operations.js +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Properties on objects passed to yearMonthFromFields() are accessed in the correct order -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const expected = [ - "get fields.era", - "get fields.era.toString", - "call fields.era.toString", - "get fields.eraYear", - "get fields.eraYear.valueOf", - "call fields.eraYear.valueOf", - "get fields.month", - "get fields.month.valueOf", - "call fields.month.valueOf", - "get fields.monthCode", - "get fields.monthCode.toString", - "call fields.monthCode.toString", - "get fields.year", - "get fields.year.valueOf", - "call fields.year.valueOf", - "get options.overflow", - "get options.overflow.toString", - "call options.overflow.toString", -]; -const actual = []; - -const instance = new Temporal.Calendar("gregory"); - -const fields = { - era: "ce", - eraYear: 1.7, - year: 1.7, - month: 1.7, - monthCode: "M01", -}; -const arg1 = new Proxy(fields, { - get(target, key) { - actual.push(`get fields.${key}`); - if (key === "calendar") return instance; - const result = target[key]; - return TemporalHelpers.toPrimitiveObserver(actual, result, `fields.${key}`); - }, - has(target, key) { - actual.push(`has fields.${key}`); - return key in target; - }, -}); - -const options = { - overflow: "reject", -}; -const arg2 = new Proxy(options, { - get(target, key) { - actual.push(`get options.${key}`); - return TemporalHelpers.toPrimitiveObserver(actual, target[key], `options.${key}`); - }, - has(target, key) { - actual.push(`has options.${key}`); - return key in target; - }, -}); - -const result = instance.yearMonthFromFields(arg1, arg2); -TemporalHelpers.assertPlainYearMonth(result, 1, 1, "M01", "yearMonth result", "ce", 1); -assert.sameValue(result.getISOFields().calendar, "gregory", "calendar slot should store a string"); -assert.compareArray(actual, expected, "order of operations"); diff --git a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-gregory.js b/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-gregory.js deleted file mode 100644 index 37ca10172c9..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-gregory.js +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Reference ISO day is chosen to be the first of the calendar month -info: | - 6.d. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, *1*𝔽). - e. Let _result_ be ? CalendarDateToISO(_calendar_.[[Identifier]], _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const gregory = new Temporal.Calendar("gregory"); - -const result1 = gregory.yearMonthFromFields({ year: 2023, monthCode: "M01", day: 13 }); -TemporalHelpers.assertPlainYearMonth( - result1, - 2023, 1, "M01", - "reference day is 1 even if day is given", - "ce", 2023, /* reference day = */ 1 -); - -const result2 = gregory.yearMonthFromFields({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "constrain" }); -TemporalHelpers.assertPlainYearMonth( - result2, - 2021, 2, "M02", - "reference day is set correctly even if day is out of range (overflow constrain)", - "ce", 2021, /* reference day = */ 1 -); - -const result3 = gregory.yearMonthFromFields({ year: 2021, monthCode: "M02", day: 50 }, { overflow: "reject" }); -TemporalHelpers.assertPlainYearMonth( - result3, - 2021, 2, "M02", - "reference day is set correctly even if day is out of range (overflow reject)", - "ce", 2021, /* reference day = */ 1 -); diff --git a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-hebrew.js b/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-hebrew.js deleted file mode 100644 index a8e78d9855d..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-hebrew.js +++ /dev/null @@ -1,69 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearmonthfromfields -description: Reference ISO day is chosen to be the first of the calendar month -info: | - 6.d. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, *1*𝔽). - e. Let _result_ be ? CalendarDateToISO(_calendar_.[[Identifier]], _fields_, _options_). -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const hebrew = new Temporal.Calendar("hebrew"); - -const result4 = hebrew.yearMonthFromFields({ year: 5782, monthCode: "M04", day: 20 }); -TemporalHelpers.assertPlainYearMonth( - result4, - 5782, 4, "M04", - "reference day is the first of the calendar month even if day is given", - /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 5 -); -const isoFields = result4.getISOFields(); -assert.sameValue(isoFields.isoYear, 2021, "Tevet 5782 begins in ISO year 2021"); -assert.sameValue(isoFields.isoMonth, 12, "Tevet 5782 begins in ISO month 12"); - -const result5 = hebrew.yearMonthFromFields({ year: 5783, monthCode: "M05L" }, { overflow: "constrain" }); -TemporalHelpers.assertPlainYearMonth( - result5, - 5783, 6, "M06", - "month code M05L does not exist in year 5783 (overflow constrain); Hebrew calendar constrains Adar I to Adar", - /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 22 -); - -assert.throws( - RangeError, - () => hebrew.yearMonthFromFields({ year: 5783, monthCode: "M05L" }, { overflow: "reject" }), - "month code M05L does not exist in year 5783 (overflow reject)", -); - -const result6 = hebrew.yearMonthFromFields({ year: 5783, month: 13 }, { overflow: "constrain" }); -TemporalHelpers.assertPlainYearMonth( - result6, - 5783, 12, "M12", - "month 13 does not exist in year 5783 (overflow constrain)", - /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 18 -); - -assert.throws( - RangeError, - () => hebrew.yearMonthFromFields({ year: 5783, month: 13 }, { overflow: "reject" }), - "month 13 does not exist in year 5783 (overflow reject)", -); - -const result7 = hebrew.yearMonthFromFields({ year: 5782, monthCode: "M04", day: 50 }, { overflow: "constrain" }); -TemporalHelpers.assertPlainYearMonth( - result7, - 5782, 4, "M04", - "reference day is set correctly even if day is out of range (overflow constrain)", - /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 5 -); - -const result8 = hebrew.yearMonthFromFields({ year: 5782, monthCode: "M04", day: 50 }, { overflow: "reject" }); -TemporalHelpers.assertPlainYearMonth( - result8, - 5782, 4, "M04", - "reference day is set correctly even if day is out of range (overflow reject)", - /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 5 -); diff --git a/test/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js b/test/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js deleted file mode 100644 index 65f73d7a2bc..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/yearOfWeek/gregory-iso-weekofyear.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - In the ISO 8601 week calendar, calendar week number 1 of a calendar year is - the week including the first Thursday of that year (based on the principle - that a week belongs to the same calendar year as the majority of its calendar - days). Because of this, some calendar days of the first calendar week of a - calendar year may be part of the preceding date calendar year, and some - calendar days of the last calendar week of a calendar year may be part of - the next calendar year. -features: [Temporal] ----*/ - -// - -let calendar = new Temporal.Calendar("gregory"); -const date = { month: 1, day: 1, year: 2021, calendar}; - -assert.sameValue(calendar.yearOfWeek({...date}), 2021); - -calendar = new Temporal.Calendar("iso8601"); -const isodate = { month: 1, day: 1, year: 2021, calendar}; - -assert.sameValue(calendar.yearOfWeek({...isodate}), 2020); diff --git a/test/intl402/Temporal/Calendar/prototype/yearOfWeek/infinity-throws-rangeerror.js b/test/intl402/Temporal/Calendar/prototype/yearOfWeek/infinity-throws-rangeerror.js deleted file mode 100644 index a30e76e74c7..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/yearOfWeek/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.calendar.prototype.yearofweek -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.Calendar("gregory"); -const base = { era: "ad", month: 5, day: 2, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.yearOfWeek({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.yearOfWeek({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js b/test/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js deleted file mode 100644 index 4337ed0918e..00000000000 --- a/test/intl402/Temporal/Calendar/prototype/yearOfWeek/non-iso-week-of-year.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2024 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.calendar.prototype.yearofweek -description: > - Temporal.Calendar.prototype.yearOfWeek returns undefined for all - non-ISO calendars without a well-defined week numbering system. -features: [Temporal] ----*/ - -// Gregorian calendar has a well defined week-numbering system. - -let calendar = new Temporal.Calendar("gregory"); -const date = { month: 1, day: 1, year: 2024, calendar}; - -assert.sameValue(calendar.yearOfWeek({...date}), 2024); - -calendar = new Temporal.Calendar("hebrew"); -const nonisodate = { month: 1, day: 1, year: 2024, calendar}; - -assert.sameValue(calendar.yearOfWeek({...nonisodate}), undefined); diff --git a/test/intl402/Temporal/Duration/compare/relativeto-sub-minute-offset.js b/test/intl402/Temporal/Duration/compare/relativeto-sub-minute-offset.js index 67e842da798..b7fc245bdaa 100644 --- a/test/intl402/Temporal/Duration/compare/relativeto-sub-minute-offset.js +++ b/test/intl402/Temporal/Duration/compare/relativeto-sub-minute-offset.js @@ -23,6 +23,5 @@ relativeTo = "1970-01-01T00:00:00-00:44:30[Africa/Monrovia]"; result = action(relativeTo); assert.sameValue(result, 0, "unrounded HH:MM:SS is accepted in string offset"); -const timeZone = Temporal.TimeZone.from("Africa/Monrovia"); -relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone }; +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone: "Africa/Monrovia" }; assert.throws(RangeError, () => action(relativeTo), "rounded HH:MM not accepted as offset in property bag"); diff --git a/test/built-ins/Temporal/Duration/compare/twenty-five-hour-day.js b/test/intl402/Temporal/Duration/compare/twenty-five-hour-day.js similarity index 75% rename from test/built-ins/Temporal/Duration/compare/twenty-five-hour-day.js rename to test/intl402/Temporal/Duration/compare/twenty-five-hour-day.js index 9aeee2d44b5..d52e388b0a8 100644 --- a/test/built-ins/Temporal/Duration/compare/twenty-five-hour-day.js +++ b/test/intl402/Temporal/Duration/compare/twenty-five-hour-day.js @@ -5,17 +5,14 @@ esid: sec-temporal.duration.compare description: Unbalancing handles DST days with more than 24 hours features: [Temporal] -includes: [temporalHelpers.js] ---*/ -const tz = TemporalHelpers.springForwardFallBackTimeZone(); - // 2000-10-29 is a 25-hour day according to this time zone... -const relativeTo = new Temporal.ZonedDateTime(941187600_000_000_000n, tz); +const relativeTo = new Temporal.ZonedDateTime(941184000_000_000_000n, "America/Vancouver"); // confirm that we have rewound one year and one day: -assert.sameValue('1999-10-29T01:00:00-08:00[Custom/Spring_Fall]', relativeTo.toString()); +assert.sameValue('1999-10-29T01:00:00-07:00[America/Vancouver]', relativeTo.toString()); const d1 = new Temporal.Duration(1, 0, 0, 1); const d2 = new Temporal.Duration(1, 0, 0, 0, 25); diff --git a/test/intl402/Temporal/Duration/prototype/round/dst-balancing-result.js b/test/intl402/Temporal/Duration/prototype/round/dst-balancing-result.js new file mode 100644 index 00000000000..d2799eb87ad --- /dev/null +++ b/test/intl402/Temporal/Duration/prototype/round/dst-balancing-result.js @@ -0,0 +1,39 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.duration.prototype.round +description: > + Balancing the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw +{ + const duration = new Temporal.Duration(1, 0, 0, 0, 24); + const relativeTo = new Temporal.ZonedDateTime( + 941184000_000_000_000n /* = 1999-10-29T08Z */, + "America/Vancouver"); /* = 1999-10-29T00-08 in local time */ + + const result = duration.round({ largestUnit: "years", relativeTo }); + TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 24, 0, 0, 0, 0, 0, + "24 hours does not balance to 1 day in 25-hour day"); +} + +{ + const duration = new Temporal.Duration(0, 0, 0, 0, /* hours = */ 24, 0, 0, 0, 0, /* ns = */ 5); + const relativeTo = new Temporal.ZonedDateTime( + 972802800_000_000_000n /* = 2000-10-29T07Z */, + "America/Vancouver"); /* = 2000-10-29T00-07 in local time */ + + const result = duration.round({ + largestUnit: "days", + smallestUnit: "minutes", + roundingMode: "expand", + roundingIncrement: 30, + relativeTo + }); + TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 24, 30, 0, 0, 0, 0, + "24 hours does not balance after rounding to 1 day in 25-hour day"); +} diff --git a/test/intl402/Temporal/Duration/prototype/round/dst-rounding-result.js b/test/intl402/Temporal/Duration/prototype/round/dst-rounding-result.js new file mode 100644 index 00000000000..9de8162ef70 --- /dev/null +++ b/test/intl402/Temporal/Duration/prototype/round/dst-rounding-result.js @@ -0,0 +1,60 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.duration.prototype.round +description: > + Rounding the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +{ + // Date part of duration lands on skipped DST hour, causing disambiguation + const duration = new Temporal.Duration(0, 1, 0, 15, 11, 30); + const relativeTo = new Temporal.ZonedDateTime( + 950868000_000_000_000n /* = 2000-02-18T10Z */, + "America/Vancouver"); /* = 2000-02-18T02-08 in local time */ + + TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", relativeTo }), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + "1 month 15 days 12 hours should be exactly 1.5 months, which rounds up to 2 months"); + TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", roundingMode: 'halfTrunc', relativeTo }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "1 month 15 days 12 hours should be exactly 1.5 months, which rounds down to 1 month"); +} + +{ + // Month-only part of duration lands on skipped DST hour + const duration = new Temporal.Duration(0, 1, 0, 15, 0, 30); + const relativeTo = new Temporal.ZonedDateTime( + 951991200_000_000_000n /* = 2000-03-02T10Z */, + "America/Vancouver"); /* = 2000-03-02T02-08 in local time */ + + TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", relativeTo }), + 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, + "1 month 15 days 00:30 should be exactly 1.5 months, which rounds up to 2 months"); + TemporalHelpers.assertDuration(duration.round({ smallestUnit: "months", roundingMode: 'halfTrunc', relativeTo }), + 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + "1 month 15 days 00:30 should be exactly 1.5 months, which rounds down to 1 month"); +} + +{ + // Day rounding + // DST spring-forward hour skipped at 2000-04-02T02:00 (23 hour day) + // 11.5 hours is 0.5 + const duration = new Temporal.Duration(0, 0, 0, 0, 11, 30); + const relativeTo = new Temporal.PlainDateTime(2000, 4, 2).toZonedDateTime("America/Vancouver"); + + TemporalHelpers.assertDuration( + duration.round({ relativeTo, smallestUnit: "days" }), + 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, + ); + + TemporalHelpers.assertDuration( + duration.round({ relativeTo, smallestUnit: "days", roundingMode: "halfTrunc" }), + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + ); +} diff --git a/test/intl402/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js b/test/intl402/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js index aa0c86ce82f..5ffe35e2a31 100644 --- a/test/intl402/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js +++ b/test/intl402/Temporal/Duration/prototype/round/relativeto-sub-minute-offset.js @@ -34,6 +34,5 @@ TemporalHelpers.assertDateDuration(result, 1, 0, 0, 1, "unrounded HH:MM:SS is ac relativeTo = "1970-01-01T00:00+00:44:30.123456789[+00:45]"; assert.throws(RangeError, () => action(relativeTo), "rounding is not accepted between ISO offset and time zone"); -const timeZone = Temporal.TimeZone.from("Africa/Monrovia"); -relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone }; +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone: "Africa/Monrovia" }; assert.throws(RangeError, () => action(relativeTo), "rounded HH:MM not accepted as offset in property bag"); diff --git a/test/intl402/Temporal/Duration/prototype/total/dst-balancing-result.js b/test/intl402/Temporal/Duration/prototype/total/dst-balancing-result.js new file mode 100644 index 00000000000..843e4417c73 --- /dev/null +++ b/test/intl402/Temporal/Duration/prototype/total/dst-balancing-result.js @@ -0,0 +1,19 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.duration.prototype.total +description: > + Balancing the resulting duration takes the time zone's UTC offset shifts + into account +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +const duration = new Temporal.Duration(1, 0, 0, 0, 24); +const relativeTo = new Temporal.ZonedDateTime( + 941184000_000_000_000n /* = 1999-10-29T08Z */, + "America/Vancouver"); /* = 1999-10-29T00-08 in local time */ + +const result = duration.total({ unit: "days", relativeTo }); +assert.sameValue(result, 366.96, "24 hours does not balance to 1 day in 25-hour day"); diff --git a/test/built-ins/Temporal/Duration/prototype/total/dst-day-length.js b/test/intl402/Temporal/Duration/prototype/total/dst-day-length.js similarity index 88% rename from test/built-ins/Temporal/Duration/prototype/total/dst-day-length.js rename to test/intl402/Temporal/Duration/prototype/total/dst-day-length.js index 7644c940751..1f3ee5c799a 100644 --- a/test/built-ins/Temporal/Duration/prototype/total/dst-day-length.js +++ b/test/intl402/Temporal/Duration/prototype/total/dst-day-length.js @@ -5,7 +5,6 @@ esid: sec-temporal.duration.prototype.total description: > ZonedDateTime relativeTo affects day length when the duration encompasses a DST change -includes: [temporalHelpers.js] features: [Temporal] ---*/ @@ -17,38 +16,36 @@ const hours25 = new Temporal.Duration(0, 0, 0, 0, 25); const hours25Neg = new Temporal.Duration(0, 0, 0, 0, -25); const hours48 = new Temporal.Duration(0, 0, 0, 0, 48); -const timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - const skippedHourDay = new Temporal.ZonedDateTime( 954662400_000_000_000n /* = 2000-04-02T08Z */, - timeZone); /* = 2000-04-02T00-08 in local time */ + "America/Vancouver"); /* = 2000-04-02T00-08 in local time */ const repeatedHourDay = new Temporal.ZonedDateTime( 972802800_000_000_000n /* = 2000-10-29T07Z */, - timeZone); /* = 2000-10-29T00-07 in local time */ + "America/Vancouver"); /* = 2000-10-29T00-07 in local time */ const inRepeatedHour = new Temporal.ZonedDateTime( 972806400_000_000_000n /* = 2000-10-29T08Z */, - timeZone); /* = 2000-10-29T01-07 in local time */ + "America/Vancouver"); /* = 2000-10-29T01-07 in local time */ const oneDayAfterRepeatedHour = new Temporal.ZonedDateTime( 972896400_000_000_000n /* = 2000-10-30T09Z */, - timeZone); /* = 2000-10-30T01-08 in local time */ + "America/Vancouver"); /* = 2000-10-30T01-08 in local time */ const beforeSkippedHour = new Temporal.ZonedDateTime( 954585000_000_000_000n /* = 2000-04-01T10:30Z */, - timeZone); /* = 2000-04-01T02:30-08 in local time */ + "America/Vancouver"); /* = 2000-04-01T02:30-08 in local time */ const dayAfterSkippedHour = new Temporal.ZonedDateTime( 954745200_000_000_000n /* = 2000-04-03T07Z */, - timeZone); /* = 2000-04-03T00-07 in local time */ + "America/Vancouver"); /* = 2000-04-03T00-07 in local time */ const afterSkippedHour = new Temporal.ZonedDateTime( 954702000_000_000_000n /* = 2000-04-02T19Z */, - timeZone); /* = 2000-04-02T12-07 in local time */ + "America/Vancouver"); /* = 2000-04-02T12-07 in local time */ const afterRepeatedHour = new Temporal.ZonedDateTime( 972892800_000_000_000n /* = 2000-10-30T08Z */, - timeZone); /* = 2000-10-30T00-08 in local time */ + "America/Vancouver"); /* = 2000-10-30T00-08 in local time */ const afterRepeatedHourSameDay = new Temporal.ZonedDateTime( 972849600_000_000_000n /* = 2000-10-29T20Z */, - timeZone); /* = 2000-10-29T12-08 in local time */ + "America/Vancouver"); /* = 2000-10-29T12-08 in local time */ const beforeRepeatedHour = new Temporal.ZonedDateTime( 972716400_000_000_000n /* = 2000-10-28T07Z */, - timeZone); /* = 2000-10-28T00-07 in local time */ + "America/Vancouver"); /* = 2000-10-28T00-07 in local time */ assert.sameValue(hours25.total({ unit: "days", diff --git a/test/intl402/Temporal/Duration/prototype/total/dst-rounding-result.js b/test/intl402/Temporal/Duration/prototype/total/dst-rounding-result.js new file mode 100644 index 00000000000..bfc94362569 --- /dev/null +++ b/test/intl402/Temporal/Duration/prototype/total/dst-rounding-result.js @@ -0,0 +1,34 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.duration.prototype.total +description: > + Rounding the resulting duration takes the time zone's UTC offset shifts + into account +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +{ + // Date part of duration lands on skipped DST hour, causing disambiguation + const duration = new Temporal.Duration(0, 1, 0, 15, 11, 30); + const relativeTo = new Temporal.ZonedDateTime( + 950868000_000_000_000n /* = 2000-02-18T10Z */, + "America/Vancouver"); /* = 2000-02-18T02-08 in local time */ + + assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5, + "1 month 15 days 11:30 should be exactly 1.5 months"); +} + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const duration = new Temporal.Duration(0, 1, 0, 15, 0, 30); + const relativeTo = new Temporal.ZonedDateTime( + 951991200_000_000_000n /* = 2000-03-02T10Z */, + "America/Vancouver"); /* = 2000-03-02T02-08 in local time */ + + assert.sameValue(duration.total({ unit: "months", relativeTo }), 1.5, + "1 month 15 days 00:30 should be exactly 1.5 months"); +} diff --git a/test/intl402/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js b/test/intl402/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js index a3e664ca31a..e878ce90c57 100644 --- a/test/intl402/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js +++ b/test/intl402/Temporal/Duration/prototype/total/relativeto-sub-minute-offset.js @@ -33,6 +33,5 @@ assert.sameValue(result, 366, "unrounded HH:MM:SS is accepted in string offset") relativeTo = "1970-01-01T00:00+00:44:30.123456789[+00:45]"; assert.throws(RangeError, () => action(relativeTo), "rounding is not accepted between ISO offset and time zone"); -const timeZone = Temporal.TimeZone.from("Africa/Monrovia"); -relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone }; +relativeTo = { year: 1970, month: 1, day: 1, offset: "+00:45", timeZone: "Africa/Monrovia" }; assert.throws(RangeError, () => action(relativeTo), "rounded HH:MM not accepted as offset in property bag"); diff --git a/test/intl402/Temporal/Instant/prototype/toString/timezone-offset.js b/test/intl402/Temporal/Instant/prototype/toString/timezone-offset.js index 7016baa59d5..167a21ad169 100644 --- a/test/intl402/Temporal/Instant/prototype/toString/timezone-offset.js +++ b/test/intl402/Temporal/Instant/prototype/toString/timezone-offset.js @@ -9,8 +9,7 @@ features: [BigInt, Temporal] const instant = new Temporal.Instant(0n); -function test(timeZoneIdentifier, expected, description) { - const timeZone = new Temporal.TimeZone(timeZoneIdentifier); +function test(timeZone, expected, description) { assert.sameValue(instant.toString({ timeZone }), expected, description); } diff --git a/test/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js b/test/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js index 12a12c39d1e..d6b6440cd15 100644 --- a/test/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js +++ b/test/intl402/Temporal/Instant/prototype/toZonedDateTimeISO/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.instant.prototype.tozoneddatetimeiso -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) +description: Conversion of ISO date-time strings to time zone IDs (with IANA time zones) features: [Temporal] ---*/ diff --git a/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js b/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js index 44a258664f0..1ed893bffa9 100644 --- a/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js +++ b/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.now.zoneddatetimeiso -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) +description: Conversion of ISO date-time strings to time zone IDs (with IANA time zones) features: [Temporal] ---*/ diff --git a/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string.js b/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string.js index 79a59151e39..edb7cec3db7 100644 --- a/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string.js +++ b/test/intl402/Temporal/Now/zonedDateTimeISO/timezone-string.js @@ -9,7 +9,5 @@ features: [Temporal] const zdt = Temporal.Now.zonedDateTimeISO("America/Los_Angeles"); assert(zdt instanceof Temporal.ZonedDateTime); -assert.sameValue(typeof zdt.getISOFields().calendar, "string", "calendar slot should store a string"); assert.sameValue(zdt.calendarId, "iso8601"); -assert.sameValue(typeof zdt.getISOFields().timeZone, "string", "time zone slot should store a string"); assert.sameValue(zdt.timeZoneId, "America/Los_Angeles"); diff --git a/test/intl402/Temporal/PlainDate/compare/exhaustive.js b/test/intl402/Temporal/PlainDate/compare/exhaustive.js new file mode 100644 index 00000000000..9a0eab177af --- /dev/null +++ b/test/intl402/Temporal/PlainDate/compare/exhaustive.js @@ -0,0 +1,68 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.compare +description: Tests for compare() with each possible outcome +features: [Temporal] +---*/ + +const cal1 = "iso8601"; +const cal2 = "gregory"; + +assert.sameValue( + Temporal.PlainDate.compare( + new Temporal.PlainDate(2000, 5, 31, cal1), + new Temporal.PlainDate(1987, 5, 31, cal2) + ), + 1, + "year >" +); +assert.sameValue( + Temporal.PlainDate.compare( + new Temporal.PlainDate(1981, 12, 15, cal1), + new Temporal.PlainDate(2048, 12, 15, cal2) + ), + -1, + "year <" +); +assert.sameValue( + Temporal.PlainDate.compare( + new Temporal.PlainDate(2000, 5, 31, cal1), + new Temporal.PlainDate(2000, 3, 31, cal2) + ), + 1, + "month >" +); +assert.sameValue( + Temporal.PlainDate.compare( + new Temporal.PlainDate(1981, 4, 15, cal1), + new Temporal.PlainDate(1981, 12, 15, cal2) + ), + -1, + "month <" +); +assert.sameValue( + Temporal.PlainDate.compare( + new Temporal.PlainDate(2000, 5, 31, cal1), + new Temporal.PlainDate(2000, 5, 14, cal2) + ), + 1, + "day >" +); +assert.sameValue( + Temporal.PlainDate.compare( + new Temporal.PlainDate(1981, 4, 15, cal1), + new Temporal.PlainDate(1981, 4, 21, cal2) + ), + -1, + "day <" +); +assert.sameValue( + Temporal.PlainDate.compare( + new Temporal.PlainDate(2000, 5, 31, cal1), + new Temporal.PlainDate(2000, 5, 31, cal2) + ), + 0, + "=" +); diff --git a/test/intl402/Temporal/PlainDate/from/one-of-era-erayear-undefined.js b/test/intl402/Temporal/PlainDate/from/one-of-era-erayear-undefined.js new file mode 100644 index 00000000000..acf325779ec --- /dev/null +++ b/test/intl402/Temporal/PlainDate/from/one-of-era-erayear-undefined.js @@ -0,0 +1,16 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.from +description: > + Throw a TypeError if only one of era/eraYear fields is present (for calendar + using eras) +features: [Temporal] +---*/ + +const base = { year: 2000, month: 5, day: 2, era: "ce", calendar: "gregory" }; +assert.throws(TypeError, () => Temporal.PlainDate.from(base)); + +const base2 = { year: 2000, month: 5, day: 2, eraYear: 1, calendar: "gregory" }; +assert.throws(TypeError, () => Temporal.PlainDate.from(base2)); diff --git a/test/intl402/Temporal/PlainDate/prototype/equals/argument-object-valid.js b/test/intl402/Temporal/PlainDate/prototype/equals/argument-object-valid.js new file mode 100644 index 00000000000..d60ace9d2e5 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/equals/argument-object-valid.js @@ -0,0 +1,14 @@ +// Copyright (C) 2020 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.equals +description: equals with a valid property bag +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); +assert.sameValue(instance.equals({ year: 2000, month: 5, day: 2 }), true, "same date"); +assert.sameValue(instance.equals({ year: 2000, month: 5, day: 4 }), false, "different date"); +assert.sameValue(instance.equals({ year: 2000, month: 5, day: 2, calendar: "gregory" }), + false, "different calendar"); diff --git a/test/intl402/Temporal/PlainDate/prototype/equals/argument-string.js b/test/intl402/Temporal/PlainDate/prototype/equals/argument-string.js new file mode 100644 index 00000000000..70bcd4a5b1a --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/equals/argument-string.js @@ -0,0 +1,11 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.equals +description: equals with a valid string (non-ISO calendar) +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(2000, 5, 2); +assert.sameValue(instance.equals("2000-05-02[u-ca=gregory]"), false, "different calendar"); diff --git a/test/intl402/Temporal/PlainDate/prototype/equals/calendar-is-compared.js b/test/intl402/Temporal/PlainDate/prototype/equals/calendar-is-compared.js new file mode 100644 index 00000000000..03525b7cd4a --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/equals/calendar-is-compared.js @@ -0,0 +1,12 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.protoype.equals +description: test if the calendar is compared +features: [Temporal] +---*/ + +const date1 = new Temporal.PlainDate(1914, 2, 23, "iso8601"); +const date2 = new Temporal.PlainDate(1914, 2, 22, "gregory"); +assert.sameValue(date1.equals(date2), false, "different ISO dates"); diff --git a/test/intl402/Temporal/PlainDate/prototype/era/validate-calendar-value.js b/test/intl402/Temporal/PlainDate/prototype/era/validate-calendar-value.js deleted file mode 100644 index 1ecbb8b6723..00000000000 --- a/test/intl402/Temporal/PlainDate/prototype/era/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2023 Richard Gibson. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.era -description: Validate result returned from calendar era() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, TypeError], - [-Infinity, TypeError], - [NaN, TypeError], - [-7, TypeError], - [-0.1, TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, TypeError], - [{valueOf() { return "7"; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - era() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.era, `${typeof result} ${String(result)} not converted to string`); -}); - -const preservedResults = [ - undefined, - "string", - "7", - "7.5", -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - era() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.sameValue(instance.era, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/intl402/Temporal/PlainDate/prototype/eraYear/validate-calendar-value.js b/test/intl402/Temporal/PlainDate/prototype/eraYear/validate-calendar-value.js deleted file mode 100644 index b6b45b1e464..00000000000 --- a/test/intl402/Temporal/PlainDate/prototype/eraYear/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2023 Richard Gibson. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindate.prototype.erayear -description: Validate result returned from calendar eraYear() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - eraYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.throws(error, () => instance.eraYear, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - undefined, - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - eraYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDate(1981, 12, 15, calendar); - assert.sameValue(instance.eraYear, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/intl402/Temporal/PlainDate/prototype/since/calendar-mismatch.js b/test/intl402/Temporal/PlainDate/prototype/since/calendar-mismatch.js new file mode 100644 index 00000000000..f0291e45ead --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/since/calendar-mismatch.js @@ -0,0 +1,12 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.since +description: RangeError thrown if calendars' IDs do not match +features: [Temporal] +---*/ + +const plainDate1 = new Temporal.PlainDate(2000, 1, 1, "gregory"); +const plainDate2 = new Temporal.PlainDate(2000, 1, 1, "japanese"); +assert.throws(RangeError, () => plainDate1.since(plainDate2)); diff --git a/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-always.js b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-always.js new file mode 100644 index 00000000000..52643926661 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-always.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tostring +description: If calendarName is "always", the calendar ID should be included. +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05-02[u-ca=iso8601]", "built-in ISO"], + [["gregory"], "2000-05-02[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDate(2000, 5, 2, ...args); + const result = date.toString({ calendarName: "always" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); +} diff --git a/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-auto.js b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-auto.js new file mode 100644 index 00000000000..a0e655ae414 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-auto.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tostring +description: If calendarName is "auto", "iso8601" should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05-02", "built-in ISO"], + [["gregory"], "2000-05-02[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDate(2000, 5, 2, ...args); + const result = date.toString({ calendarName: "auto" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); +} diff --git a/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-critical.js b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..ee480960eec --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-critical.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tostring +description: > + If calendarName is "calendar", the calendar ID should be included and prefixed + with "!". +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05-02[!u-ca=iso8601]", "built-in ISO"], + [["gregory"], "2000-05-02[!u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDate(2000, 5, 2, ...args); + const result = date.toString({ calendarName: "critical" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); +} diff --git a/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-never.js b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-never.js new file mode 100644 index 00000000000..94d094bc442 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-never.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tostring +description: If calendarName is "never", the calendar ID should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05-02", "built-in ISO"], + [["gregory"], "2000-05-02", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDate(2000, 5, 2, ...args); + const result = date.toString({ calendarName: "never" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); +} diff --git a/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-undefined.js b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-undefined.js new file mode 100644 index 00000000000..b538529ce64 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.protoype.tostring +description: Fallback value for calendarName option +info: | + sec-getoption step 3: + 3. If _value_ is *undefined*, return _fallback_. + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.plaindate.protoype.tostring step 4: + 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05-02", "built-in ISO"], + [["gregory"], "2000-05-02[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDate(2000, 5, 2, ...args); + const result = date.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg +} diff --git a/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js new file mode 100644 index 00000000000..dbc7116f605 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/toString/calendarname-wrong-type.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.protoype.tostring +description: Type conversions for calendarName option +info: | + sec-getoption step 9.a: + a. Set _value_ to ? ToString(_value_). + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.plaindate.protoype.tostring step 4: + 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const date = new Temporal.PlainDate(2000, 5, 2, "gregory"); + +TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", + (calendarName) => date.toString({ calendarName }), + (result, descr) => assert.sameValue(result, "2000-05-02[u-ca=gregory]", descr), +); diff --git a/test/intl402/Temporal/PlainDate/prototype/toString/options-undefined.js b/test/intl402/Temporal/PlainDate/prototype/toString/options-undefined.js new file mode 100644 index 00000000000..a311d02267d --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/toString/options-undefined.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tostring +description: Verify that undefined options are handled correctly. +features: [Temporal] +---*/ + +const date1 = new Temporal.PlainDate(2000, 5, 2); +const date2 = new Temporal.PlainDate(2000, 5, 2, "gregory"); + +[ + [date1, "2000-05-02"], + [date2, "2000-05-02[u-ca=gregory]"], +].forEach(([date, expected]) => { + const explicit = date.toString(undefined); + assert.sameValue(explicit, expected, "default calendarName option is auto"); + + const implicit = date.toString(); + assert.sameValue(implicit, expected, "default calendarName option is auto"); +}); diff --git a/test/intl402/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js b/test/intl402/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js index c64ab68f078..b8bc148e3d1 100644 --- a/test/intl402/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js +++ b/test/intl402/Temporal/PlainDate/prototype/toZonedDateTime/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.plaindate.prototype.tozoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) +description: Conversion of ISO date-time strings to time zone IDs (with IANA time zones) features: [Temporal] ---*/ diff --git a/test/intl402/Temporal/PlainDate/prototype/until/calendar-mismatch.js b/test/intl402/Temporal/PlainDate/prototype/until/calendar-mismatch.js new file mode 100644 index 00000000000..dfd871d8d1b --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/until/calendar-mismatch.js @@ -0,0 +1,12 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.until +description: RangeError thrown if calendars' IDs do not match +features: [Temporal] +---*/ + +const plainDate1 = new Temporal.PlainDate(2000, 1, 1, "gregory"); +const plainDate2 = new Temporal.PlainDate(2000, 1, 1, "japanese"); +assert.throws(RangeError, () => plainDate1.until(plainDate2)); diff --git a/test/intl402/Temporal/Calendar/prototype/dateUntil/until-across-lunisolar-leap-months.js b/test/intl402/Temporal/PlainDate/prototype/until/until-across-lunisolar-leap-months.js similarity index 82% rename from test/intl402/Temporal/Calendar/prototype/dateUntil/until-across-lunisolar-leap-months.js rename to test/intl402/Temporal/PlainDate/prototype/until/until-across-lunisolar-leap-months.js index f35f6332a8c..7a50d895f5d 100644 --- a/test/intl402/Temporal/Calendar/prototype/dateUntil/until-across-lunisolar-leap-months.js +++ b/test/intl402/Temporal/PlainDate/prototype/until/until-across-lunisolar-leap-months.js @@ -3,12 +3,10 @@ /*--- description: dateUntil works as expected after a leap month in a lunisolar calendar -esid: sec-temporal.calendar.prototype.dateuntil +esid: sec-temporal.plaindate.prototype.until features: [Temporal] ---*/ -const instance = new Temporal.Calendar("chinese"); - // 2001 is a leap year in the Chinese calendar with a M04L leap month. // Therefore, month: 6 is M05 in 2001 but M06 in 2000 which is not a leap year. const one = Temporal.PlainDate.from({ year: 2000, month: 6, day: 1, calendar: 'chinese' }); @@ -17,6 +15,6 @@ const two = Temporal.PlainDate.from({ year: 2001, month: 6, day: 1, calendar: 'c const expected = { years: 'P12M', months: 'P12M', weeks: 'P50W4D', days: 'P354D' }; Object.entries(expected).forEach(([largestUnit, expectedResult]) => { - const actualResult = instance.dateUntil(one, two, { largestUnit }); + const actualResult = one.until(two, { largestUnit }); assert.sameValue(actualResult.toString(), expectedResult); }); diff --git a/test/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js b/test/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js index 4d023823352..65d04659e46 100644 --- a/test/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js +++ b/test/intl402/Temporal/PlainDate/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -16,12 +16,12 @@ features: [Temporal] // -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.PlainDate(2021, 1, 1, calendar); assert.sameValue(date.weekOfYear, 1); -calendar = new Temporal.Calendar("iso8601"); +calendar = "iso8601"; const isodate = new Temporal.PlainDate(2021, 1, 1, calendar); assert.sameValue(isodate.weekOfYear, 53); diff --git a/test/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js b/test/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js index 86c46b497d7..88e9e593142 100644 --- a/test/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js +++ b/test/intl402/Temporal/PlainDate/prototype/weekOfYear/non-iso-week-of-year.js @@ -11,12 +11,12 @@ features: [Temporal] // Gregorian calendar has a well defined week-numbering system. -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.PlainDate(2024, 1, 1, calendar); assert.sameValue(date.weekOfYear, 1); -calendar = new Temporal.Calendar("hebrew"); +calendar = "hebrew"; const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar); assert.sameValue(nonisodate.weekOfYear, undefined); diff --git a/test/intl402/Temporal/PlainDate/prototype/with/gregorian-mutually-exclusive-fields.js b/test/intl402/Temporal/PlainDate/prototype/with/gregorian-mutually-exclusive-fields.js new file mode 100644 index 00000000000..8baa19b594a --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/with/gregorian-mutually-exclusive-fields.js @@ -0,0 +1,44 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.with +description: Calendar-specific mutually exclusive keys in mergeFields +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const instance = new Temporal.PlainDate(1981, 12, 15, "gregory"); + +TemporalHelpers.assertPlainDate(instance, 1981, 12, "M12", 15, + "check that all fields are as expected", + /* era = */ "ce", /* eraYear = */ 1981 +); + +TemporalHelpers.assertPlainDate( + instance.with({ era: "bce", eraYear: 1 }), + 0, 12, "M12", 15, + "era and eraYear together exclude year", + "bce", 1 +); + +TemporalHelpers.assertPlainDate( + instance.with({ year: -2 }), + -2, 12, "M12", 15, + "year excludes era and eraYear", + "bce", 3 +); + +TemporalHelpers.assertPlainDate( + instance.with({ month: 5 }), + 1981, 5, "M05", 15, + "month excludes monthCode", + "ce", 1981 +); + +TemporalHelpers.assertPlainDate( + instance.with({ monthCode: "M05" }), + 1981, 5, "M05", 15, + "monthCode excludes month", + "ce", 1981 +); diff --git a/test/intl402/Temporal/PlainDate/prototype/with/japanese-mutually-exclusive-fields.js b/test/intl402/Temporal/PlainDate/prototype/with/japanese-mutually-exclusive-fields.js new file mode 100644 index 00000000000..5d9426bffc2 --- /dev/null +++ b/test/intl402/Temporal/PlainDate/prototype/with/japanese-mutually-exclusive-fields.js @@ -0,0 +1,63 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.with +description: Calendar-specific mutually exclusive keys in mergeFields +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const lastDayOfShowa = Temporal.PlainDate.from({ era: "showa", eraYear: 64, year: 1989, month: 1, monthCode: "M01", day: 7, calendar: "japanese" }); + +TemporalHelpers.assertPlainDate(lastDayOfShowa, 1989, 1, "M01", 7, + "check expected fields", + /* era = */ "showa", /* eraYear = */ 64 +); + +TemporalHelpers.assertPlainDate( + lastDayOfShowa.with({ day: 10 }), + 1989, 1, "M01", 10, + "day excludes era and eraYear", + /* era = */ "heisei", /* eraYear = */ 1 +); + +TemporalHelpers.assertPlainDate( + lastDayOfShowa.with({ month: 2 }), + 1989, 2, "M02", 7, + "month excludes monthCode, era, and eraYear", + "heisei", 1 +); + +TemporalHelpers.assertPlainDate( + lastDayOfShowa.with({ monthCode: "M03" }), + 1989, 3, "M03", 7, + "monthCode excludes month, era, and eraYear", + "heisei", 1 +); + +TemporalHelpers.assertPlainDate( + lastDayOfShowa.with({ year: 1988 }), + 1988, 1, "M01", 7, + "year excludes era and eraYear (within same era)", + "showa", 63 +); + +TemporalHelpers.assertPlainDate( + lastDayOfShowa.with({ year: 1990 }), + 1990, 1, "M01", 7, + "year excludes era and eraYear (in a different era)", + "heisei", 2 +); + +assert.throws( + TypeError, + () => lastDayOfShowa.with({ eraYear: 1 }), + "eraYear excludes year and era, and cannot be provided without era", +); + +assert.throws( + TypeError, + () => lastDayOfShowa.with({ era: "heisei" }), + "era excludes year and eraYear, and cannot be provided without eraYear", +); diff --git a/test/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js b/test/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js index 70252942e90..8de9cc6f342 100644 --- a/test/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js +++ b/test/intl402/Temporal/PlainDate/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -16,12 +16,12 @@ features: [Temporal] // -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.PlainDate(2021, 1, 1, calendar); assert.sameValue(date.yearOfWeek, 2021); -calendar = new Temporal.Calendar("iso8601"); +calendar = "iso8601"; const isodate = new Temporal.PlainDate(2021, 1, 1, calendar); assert.sameValue(isodate.yearOfWeek, 2020); diff --git a/test/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js b/test/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js index e378c0884c4..5d0190e2594 100644 --- a/test/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js +++ b/test/intl402/Temporal/PlainDate/prototype/yearOfWeek/non-iso-week-of-year.js @@ -11,12 +11,12 @@ features: [Temporal] // Gregorian calendar has a well defined week-numbering system. -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.PlainDate(2024, 1, 1, calendar); assert.sameValue(date.yearOfWeek, 2024); -calendar = new Temporal.Calendar("hebrew"); +calendar = "hebrew"; const nonisodate = new Temporal.PlainDate(2024, 1, 1, calendar); assert.sameValue(nonisodate.yearOfWeek, undefined); diff --git a/test/intl402/Temporal/PlainDateTime/compare/calendar-ignored.js b/test/intl402/Temporal/PlainDateTime/compare/calendar-ignored.js new file mode 100644 index 00000000000..c89c9ed3420 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/compare/calendar-ignored.js @@ -0,0 +1,17 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.compare +description: Calendar is not taken into account for the comparison. +features: [Temporal] +---*/ + +const dt1 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); +const dt2 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, "iso8601"); +const dt3 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, "iso8601"); +const dt4 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, "gregory"); + +assert.sameValue(Temporal.PlainDateTime.compare(dt1, dt2), -1, "smaller"); +assert.sameValue(Temporal.PlainDateTime.compare(dt2, dt3), 0, "equal with same calendar"); +assert.sameValue(Temporal.PlainDateTime.compare(dt2, dt4), 0, "equal with different calendar"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/equals/calendar-checked.js b/test/intl402/Temporal/PlainDateTime/prototype/equals/calendar-checked.js new file mode 100644 index 00000000000..3017b458efb --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/equals/calendar-checked.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.equals +description: Calendar is taken into account if the ISO data is equal +features: [Temporal] +---*/ + +const dt1 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); +const dt2 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); +const dt3 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "gregory"); + +assert.sameValue(dt1.equals(dt2), true, "same calendar string"); +assert.sameValue(dt1.equals(dt3), false, "different calendar string"); + +const dt4 = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "iso8601"); +const dt5 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, "iso8601"); +const dt6 = new Temporal.PlainDateTime(2019, 10, 29, 10, 46, 38, 271, 986, 102, "gregory"); +assert.sameValue(dt4.equals(dt5), false, "not equal same calendar"); +assert.sameValue(dt4.equals(dt6), false, "not equal different calendar"); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/era/validate-calendar-value.js b/test/intl402/Temporal/PlainDateTime/prototype/era/validate-calendar-value.js deleted file mode 100644 index 8c950384f41..00000000000 --- a/test/intl402/Temporal/PlainDateTime/prototype/era/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2023 Richard Gibson. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.era -description: Validate result returned from calendar era() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, TypeError], - [-Infinity, TypeError], - [NaN, TypeError], - [-7, TypeError], - [-0.1, TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, TypeError], - [{valueOf() { return "7"; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - era() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.era, `${typeof result} ${String(result)} not converted to string`); -}); - -const preservedResults = [ - undefined, - "string", - "7", - "7.5", -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - era() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.sameValue(instance.era, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/eraYear/validate-calendar-value.js b/test/intl402/Temporal/PlainDateTime/prototype/eraYear/validate-calendar-value.js deleted file mode 100644 index 8f61fbf31bc..00000000000 --- a/test/intl402/Temporal/PlainDateTime/prototype/eraYear/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2023 Richard Gibson. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plaindatetime.prototype.erayear -description: Validate result returned from calendar eraYear() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - eraYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.throws(error, () => instance.eraYear, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - undefined, - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - eraYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); - assert.sameValue(instance.eraYear, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js b/test/intl402/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js new file mode 100644 index 00000000000..837da7f242a --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/since/different-calendars-throws.js @@ -0,0 +1,17 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.since +description: Fail if the argument is a PlainDateTime with a different calendar +features: [Temporal] +---*/ + +const dt1 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0); +const dt2 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, "gregory"); + +assert.throws( + RangeError, + () => dt1.since(dt2), + "different calendars not allowed" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-always.js b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-always.js index 727b24ce90c..b862fd15980 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-always.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-always.js @@ -3,14 +3,17 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tostring -description: Show calendar when calendarName is "always" +description: If calendarName is "always", the calendar ID should be included. features: [Temporal] ---*/ -const dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, "gregory"); +const tests = [ + [[], "1976-11-18T15:23:00[u-ca=iso8601]", "built-in ISO"], + [["gregory"], "1976-11-18T15:23:00[u-ca=gregory]", "built-in Gregorian"], +]; -assert.sameValue( - dt.toString({ calendarName: "always" }), - "1976-11-18T15:23:00[u-ca=gregory]", - "shows non-ISO calendar if calendarName = always" -); +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); + const result = date.toString({ calendarName: "always" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); +} diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js index 2f9586a83d0..218495e3007 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-auto.js @@ -3,12 +3,17 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tostring -description: Possibly display calendar when calendarName is "auto" +description: If calendarName is "auto", "iso8601" should be omitted. features: [Temporal] ---*/ -const dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, "gregory"); -const expected = "1976-11-18T15:23:00[u-ca=gregory]"; +const tests = [ + [[], "1976-11-18T15:23:00", "built-in ISO"], + [["gregory"], "1976-11-18T15:23:00[u-ca=gregory]", "built-in Gregorian"], +]; -assert.sameValue(dt.toString(), expected, "shows non-ISO calendar by default (no arguments)"); -assert.sameValue(dt.toString({ calendarName: "auto" }), expected, "shows only non-ISO calendar if calendarName = auto"); +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); + const result = date.toString({ calendarName: "auto" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); +} diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..05f3af26348 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-critical.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tostring +description: > + If calendarName is "calendar", the calendar ID should be included and prefixed + with "!". +features: [Temporal] +---*/ + +const tests = [ + [[], "1976-11-18T15:23:00[!u-ca=iso8601]", "built-in ISO"], + [["gregory"], "1976-11-18T15:23:00[!u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); + const result = date.toString({ calendarName: "critical" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); +} diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-never.js b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-never.js index 1bd9018a213..5b739a82d8e 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-never.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-never.js @@ -3,14 +3,17 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tostring -description: Do not show calendar (even non-ISO calendars) if calendarName = "never" +description: If calendarName is "never", the calendar ID should be omitted. features: [Temporal] ---*/ -const dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23); +const tests = [ + [[], "1976-11-18T15:23:00", "built-in ISO"], + [["gregory"], "1976-11-18T15:23:00", "built-in Gregorian"], +]; -assert.sameValue( - dt.withCalendar("gregory").toString({ calendarName: "never" }), - "1976-11-18T15:23:00", - "omits non-ISO calendar if calendarName = never" -); +for (const [args, expected, description] of tests) { + const date = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); + const result = date.toString({ calendarName: "never" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); +} diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js new file mode 100644 index 00000000000..a3ccfec0727 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.protoype.tostring +description: Fallback value for calendarName option +info: | + sec-getoption step 3: + 3. If _value_ is *undefined*, return _fallback_. + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.plaindatetime.protoype.tostring step 6: + 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +features: [Temporal] +---*/ + +const tests = [ + [[], "1976-11-18T15:23:00", "built-in ISO"], + [["gregory"], "1976-11-18T15:23:00[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const datetime = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 0, 0, 0, 0, ...args); + const result = datetime.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg +} diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js new file mode 100644 index 00000000000..9ed20a78249 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toString/calendarname-wrong-type.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.protoype.tostring +description: Type conversions for calendarName option +info: | + sec-getoption step 9.a: + a. Set _value_ to ? ToString(_value_). + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.plaindatetime.protoype.tostring step 6: + 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const datetime = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321, "gregory"); + +TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", + (calendarName) => datetime.toString({ calendarName }), + (result, descr) => assert.sameValue(result, "2000-05-02T12:34:56.987654321[u-ca=gregory]", descr), +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toString/options-undefined.js b/test/intl402/Temporal/PlainDateTime/prototype/toString/options-undefined.js new file mode 100644 index 00000000000..5f78ee5cfe2 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toString/options-undefined.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tostring +description: Verify that undefined options are handled correctly. +features: [Temporal] +---*/ + +const datetime1 = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 650, 0); +const datetime2 = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 650, 0, "gregory"); + +[ + [datetime1, "2000-05-02T12:34:56.98765"], + [datetime2, "2000-05-02T12:34:56.98765[u-ca=gregory]"], +].forEach(([datetime, expected]) => { + const explicit = datetime.toString(undefined); + assert.sameValue(explicit, expected, "default calendarName option is auto, precision is auto, and no rounding"); + + const propertyImplicit = datetime.toString({}); + assert.sameValue(propertyImplicit, expected, "default calendarName option is auto, precision is auto, and no rounding"); + + const implicit = datetime.toString(); + assert.sameValue(implicit, expected, "default calendarName option is auto, precision is auto, and no rounding"); +}); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-undefined.js b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-undefined.js new file mode 100644 index 00000000000..d95ec257ac7 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/disambiguation-undefined.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: Fallback value for disambiguation option +info: | + sec-getoption step 3: + 3. If _value_ is *undefined*, return _fallback_. + sec-temporal-totemporaldisambiguation step 1: + 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). + sec-temporal.plaindatetime.prototype.tozoneddatetime step 5: + 5. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). +features: [Temporal] +---*/ + +const timeZone = "America/Vancouver"; +const springForwardDatetime = new Temporal.PlainDateTime(2000, 4, 2, 2, 30); +const fallBackDatetime = new Temporal.PlainDateTime(2000, 10, 29, 1, 30); + +[ + [springForwardDatetime, 954671400_000_000_000n], + [fallBackDatetime, 972808200_000_000_000n], +].forEach(([datetime, expected]) => { + const explicit = datetime.toZonedDateTime(timeZone, { disambiguation: undefined }); + assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); + const implicit = datetime.toZonedDateTime(timeZone, {}); + assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); +}); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/dst-disambiguation.js b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/dst-disambiguation.js new file mode 100644 index 00000000000..5d8f7132e31 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/dst-disambiguation.js @@ -0,0 +1,72 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: Basic tests for disambiguation option, with DST time zone +features: [Temporal] +---*/ + +const dtmFall = new Temporal.PlainDateTime(2000, 10, 29, 1, 45); + +assert.sameValue( + dtmFall.toZonedDateTime("America/Los_Angeles").epochNanoseconds, + 972809100_000_000_000n, // 2000-10-29T08:45:00Z + "epoch nanoseconds in fall back - no disambiguation" +); + +assert.sameValue( + dtmFall.toZonedDateTime("America/Los_Angeles", { disambiguation: "earlier" }).epochNanoseconds, + 972809100_000_000_000n, // 2000-10-29T08:45:00Z + "epoch nanoseconds in fall back - earlier" +); + +assert.sameValue( + dtmFall.toZonedDateTime("America/Los_Angeles", { disambiguation: "later" }).epochNanoseconds, + 972812700_000_000_000n, // 2000-10-29T09:45:00Z + "epoch nanoseconds in fall back - later" +); + +assert.sameValue( + dtmFall.toZonedDateTime("America/Los_Angeles", { disambiguation: "compatible" }).epochNanoseconds, + 972809100_000_000_000n, // 2000-10-29T08:45:00Z + "epoch nanoseconds in fall back - compatible" +); + +assert.throws( + RangeError, + () => dtmFall.toZonedDateTime("America/Los_Angeles", { disambiguation: "reject" }), + "fall back - reject" +); + +var dtmSpring = new Temporal.PlainDateTime(2000, 4, 2, 2, 30); + +assert.sameValue( + dtmSpring.toZonedDateTime("America/Los_Angeles").epochNanoseconds, + 954671400_000_000_000n, // 2000-04-02T10:30:00Z + "epoch nanoseconds in spring forward - no disambiguation" +); + +assert.sameValue( + dtmSpring.toZonedDateTime("America/Los_Angeles", { disambiguation: "earlier" }).epochNanoseconds, + 954667800_000_000_000n, // 2000-04-02T09:30:00Z + "epoch nanoseconds in spring forward - earlier" +); + +assert.sameValue( + dtmSpring.toZonedDateTime("America/Los_Angeles", { disambiguation: "later" }).epochNanoseconds, + 954671400_000_000_000n, // 2000-04-02T10:30:00Z + "epoch nanoseconds in spring forward - later" +); + +assert.sameValue( + dtmSpring.toZonedDateTime("America/Los_Angeles", { disambiguation: "compatible" }).epochNanoseconds, + 954671400_000_000_000n, // 2000-04-02T10:30:00Z + "epoch nanoseconds in spring forward - compatible" +); + +assert.throws( + RangeError, + () => dtmSpring.toZonedDateTime("America/Los_Angeles", { disambiguation: "reject" }), + "spring forward - reject" +); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/multiple-instants.js b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/multiple-instants.js similarity index 95% rename from test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/multiple-instants.js rename to test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/multiple-instants.js index 5863513091c..1ac1cad2167 100644 --- a/test/built-ins/Temporal/PlainDateTime/prototype/toZonedDateTime/multiple-instants.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/multiple-instants.js @@ -5,10 +5,9 @@ esid: sec-temporal.plaindatetime.prototype.tozoneddatetime description: Checking disambiguation options for daylight savings time changes features: [Temporal] -includes: [temporalHelpers.js] ---*/ -const tz = TemporalHelpers.springForwardFallBackTimeZone(); +const tz = "America/Vancouver"; const dt1 = new Temporal.PlainDateTime(2000, 4, 2, 2); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/options-undefined.js b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/options-undefined.js new file mode 100644 index 00000000000..feca82e6afc --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/options-undefined.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindate.prototype.tozoneddatetime +description: Verify that undefined options are handled correctly. +features: [BigInt, Temporal] +---*/ + +const datetimeEarlier = new Temporal.PlainDateTime(2000, 10, 29, 1, 34, 56, 987, 654, 321); +const datetimeLater = new Temporal.PlainDateTime(2000, 4, 2, 2, 34, 56, 987, 654, 321); +const timeZone = "America/Vancouver"; + +[ + [datetimeEarlier, 972808496987654321n], + [datetimeLater, 954671696987654321n], +].forEach(([datetime, expected]) => { + const explicit = datetime.toZonedDateTime(timeZone, undefined); + assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); + + const implicit = datetime.toZonedDateTime(timeZone); + assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); +}); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/order-of-operations.js b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/order-of-operations.js new file mode 100644 index 00000000000..cb37ee82d41 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/order-of-operations.js @@ -0,0 +1,25 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.tozoneddatetime +description: > + Properties on an object passed to toZonedDateTime() are accessed in the + correct order (with disambiguation=reject) +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const expected = [ + // ToTemporalDisambiguation + "get options.disambiguation", + "get options.disambiguation.toString", + "call options.disambiguation.toString", +]; +const actual = []; + +const instance = new Temporal.PlainDateTime(2000, 4, 2, 2, 30); +const options = TemporalHelpers.propertyBagObserver(actual, { disambiguation: "reject" }, "options"); +assert.throws(RangeError, () => instance.toZonedDateTime("America/Vancouver", options)); +assert.compareArray(actual, expected, "order of operations with disambiguation: reject"); +actual.splice(0); // clear diff --git a/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js index be582d08255..09036eaab50 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/toZonedDateTime/timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.plaindatetime.prototype.tozoneddatetime -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) +description: Conversion of ISO date-time strings to time zone IDs (with IANA time zones) features: [Temporal] ---*/ diff --git a/test/intl402/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js b/test/intl402/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js new file mode 100644 index 00000000000..9dc29685403 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/until/different-calendars-throws.js @@ -0,0 +1,17 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.until +description: Using different calendars is not acceptable +features: [Temporal] +---*/ + +const dt1 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0); +const dt2 = new Temporal.PlainDateTime(2000, 1, 1, 0, 0, 0, 0, 0, 0, "gregory"); + +assert.throws( + RangeError, + () => dt1.until(dt2), + "cannot use until with PDTs having different calendars" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js b/test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js index 6f79fd1c117..65f75d4a644 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -16,12 +16,12 @@ features: [Temporal] // -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); assert.sameValue(date.weekOfYear, 1); -calendar = new Temporal.Calendar("iso8601"); +calendar = "iso8601"; const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); assert.sameValue(isodate.weekOfYear, 53); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js b/test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js index 1eb4e566bb6..56077f2e76c 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/weekOfYear/non-iso-week-of-year.js @@ -11,12 +11,12 @@ features: [Temporal] // Gregorian calendar has a well defined week-numbering system. -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); assert.sameValue(date.weekOfYear, 1); -calendar = new Temporal.Calendar("hebrew"); +calendar = "hebrew"; const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); assert.sameValue(nonisodate.weekOfYear, undefined); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js b/test/intl402/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js new file mode 100644 index 00000000000..b250c1cc444 --- /dev/null +++ b/test/intl402/Temporal/PlainDateTime/prototype/withCalendar/argument-string.js @@ -0,0 +1,26 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plaindatetime.prototype.withcalendar +description: String argument, if it names a recognizable calendar, gets cast +features: [Temporal] +includes: [temporalHelpers.js] +---*/ + +const dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789, "gregory"); +const result = dt.withCalendar("iso8601"); + +TemporalHelpers.assertPlainDateTime( + result, + 1976, 11, "M11", 18, 15, 23, 30, 123, 456, 789, + "'iso8601' is a recognizable calendar" +); + +assert.sameValue(result.calendarId, "iso8601", "underlying calendar has changed"); + +assert.throws( + RangeError, + () => dt.withCalendar("this will fail"), + "unknown calendar throws" +); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js b/test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js index 63bd715a1b2..20034007f9c 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -16,12 +16,12 @@ features: [Temporal] // -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); assert.sameValue(date.yearOfWeek, 2021); -calendar = new Temporal.Calendar("iso8601"); +calendar = "iso8601"; const isodate = new Temporal.PlainDateTime(2021, 1, 1, 12, 34, 56, 987, 654, 321, calendar); assert.sameValue(isodate.yearOfWeek, 2020); diff --git a/test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js b/test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js index 35c1b13f18d..8157aa1414a 100644 --- a/test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js +++ b/test/intl402/Temporal/PlainDateTime/prototype/yearOfWeek/non-iso-week-of-year.js @@ -11,12 +11,12 @@ features: [Temporal] // Gregorian calendar has a well defined week-numbering system. -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); assert.sameValue(date.yearOfWeek, 2024); -calendar = new Temporal.Calendar("hebrew"); +calendar = "hebrew"; const nonisodate = new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); assert.sameValue(nonisodate.yearOfWeek, undefined); diff --git a/test/intl402/Temporal/PlainMonthDay/from/fields-object.js b/test/intl402/Temporal/PlainMonthDay/from/fields-object.js index 09aaf918da0..aa2a4b97ea9 100644 --- a/test/intl402/Temporal/PlainMonthDay/from/fields-object.js +++ b/test/intl402/Temporal/PlainMonthDay/from/fields-object.js @@ -11,8 +11,6 @@ features: [Temporal] const okTests = [ [{ monthCode: "M08", day: 1, calendar: "gregory" }, "gregory", "monthCode and non-ISO Gregorian string calendar"], [{ monthCode: "M08", day: 1, calendar: "hebrew" }, "hebrew", "monthCode and non-ISO non-Gregorian string calendar"], - [{ monthCode: "M08", day: 1, calendar: Temporal.Calendar.from("gregory") }, "gregory", "monthCode and non-ISO Gregorian object calendar"], - [{ monthCode: "M08", day: 1, calendar: Temporal.Calendar.from("hebrew") }, "hebrew", "monthCode and non-ISO non-Gregorian object calendar"], ]; for (const [argument, expectedCalendar, description] of okTests) { @@ -24,8 +22,6 @@ for (const [argument, expectedCalendar, description] of okTests) { const notOkTests = [ [{ month: 8, day: 1, calendar: "gregory" }, "month and non-ISO string calendar"], [{ month: 8, day: 1, calendar: "hebrew" }, "month and non-ISO non-Gregorian string calendar"], - [{ month: 8, day: 1, calendar: Temporal.Calendar.from("gregory") }, "month and non-ISO Gregorian object calendar"], - [{ month: 8, day: 1, calendar: Temporal.Calendar.from("hebrew") }, "month and non-ISO non-Gregorian object calendar"], ]; for (const [argument, description] of notOkTests) { diff --git a/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/fields-underspecified.js b/test/intl402/Temporal/PlainMonthDay/from/fields-underspecified.js similarity index 78% rename from test/intl402/Temporal/Calendar/prototype/monthDayFromFields/fields-underspecified.js rename to test/intl402/Temporal/PlainMonthDay/from/fields-underspecified.js index 712eb8f89ad..7a067b57814 100644 --- a/test/intl402/Temporal/Calendar/prototype/monthDayFromFields/fields-underspecified.js +++ b/test/intl402/Temporal/PlainMonthDay/from/fields-underspecified.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.calendar.prototype.monthdayfromfields +esid: sec-temporal.plainmonthday.from description: Throw a RangeError if only one of era/eraYear fields is present features: [Temporal] ---*/ @@ -15,6 +15,5 @@ const tests = [ ]; for (const [calendarId, arg, description] of tests) { - const instance = new Temporal.Calendar(calendarId); - assert.throws(TypeError, () => instance.monthDayFromFields(arg), description); + assert.throws(TypeError, () => Temporal.PlainMonthDay.from({ ...arg, calendar: calendarId }), description); } diff --git a/test/intl402/Temporal/PlainMonthDay/from/reference-year-1972.js b/test/intl402/Temporal/PlainMonthDay/from/reference-year-1972.js new file mode 100644 index 00000000000..e0a5b6cad4a --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/from/reference-year-1972.js @@ -0,0 +1,71 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.from +description: Deterministic choosing of the reference year +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const result1 = Temporal.PlainMonthDay.from({ year: 2021, monthCode: "M02", day: 29, calendar: "gregory" }); +TemporalHelpers.assertPlainMonthDay( + result1, "M02", 29, + "year is ignored and reference year should be 1972 if monthCode is given", + 1972 +); + +const result2 = Temporal.PlainMonthDay.from({ year: 2021, month: 2, day: 29, calendar: "gregory" }, { overflow: "constrain" }); +TemporalHelpers.assertPlainMonthDay( + result2, "M02", 28, + "if monthCode is not given, year is used to determine if calendar date exists, but reference year should still be 1972", + 1972 +); + +assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from({ year: 2021, month: 2, day: 29, calendar: "gregory" }, { overflow: "reject" }), + "RangeError thrown if calendar date does not exist in given year and overflow is reject" +); + +const result3 = Temporal.PlainMonthDay.from({ monthCode: "M01", day: 1, calendar: "hebrew" }); +TemporalHelpers.assertPlainMonthDay( + result3, "M01", 1, + "reference year should be 1972 if date exists in 1972", + 1972 +); + +const result4 = Temporal.PlainMonthDay.from({ monthCode: "M05L", day: 1, calendar: "hebrew" }); +TemporalHelpers.assertPlainMonthDay( + result4, "M05L", 1, + "reference year should be the latest ISO year before 1972 if date does not exist in 1972", + 1970 +); + +const result5 = Temporal.PlainMonthDay.from({ year: 5781, monthCode: "M02", day: 30, calendar: "hebrew" }); +TemporalHelpers.assertPlainMonthDay( + result5, "M02", 30, + "year is ignored if monthCode is given (Cheshvan 5781 has 29 days)", + 1971 +); + +const result6 = Temporal.PlainMonthDay.from({ year: 5781, month: 2, day: 30, calendar: "hebrew" }, { overflow: "constrain" }); +TemporalHelpers.assertPlainMonthDay( + result6, "M02", 29, + "if monthCode is not given, year is used to determine if calendar date exists, but reference year still correct", + 1972 +); + +assert.throws( + RangeError, + () => Temporal.PlainMonthDay.from({ year: 5781, month: 2, day: 30, calendar: "hebrew" }, { overflow: "reject" }), + "RangeError thrown if calendar date does not exist in given year and overflow is reject" +); + +const result7 = Temporal.PlainMonthDay.from({ monthCode: "M04", day: 26, calendar: "hebrew" }); +TemporalHelpers.assertPlainMonthDay( + result7, "M04", 26, + "reference date should be the later one, if two options exist in ISO year 1972", + 1972 +); +assert.sameValue(result7.toString(), "1972-12-31[u-ca=hebrew]", "reference date"); diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/equals/calendars.js b/test/intl402/Temporal/PlainMonthDay/prototype/equals/calendars.js new file mode 100644 index 00000000000..aabbf103873 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/equals/calendars.js @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.equals +description: Basic tests for equals() calendar handling +features: [Temporal] +---*/ + +const mdA = new Temporal.PlainMonthDay(2, 7, "iso8601"); +const mdB = new Temporal.PlainMonthDay(2, 7, "gregory"); +const mdC = new Temporal.PlainMonthDay(2, 7, "iso8601", 1974); +assert.sameValue(mdA.equals(mdC), false, "different year"); +assert.sameValue(mdA.equals(mdB), false, "different calendar"); diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js b/test/intl402/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js new file mode 100644 index 00000000000..27e70db2926 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toJSON/calendarname.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.protoype.tojson +description: toJSON doesn't take calendarName into account. +features: [Temporal] +---*/ + +const tests = [ + [[], "05-02"], + [["gregory"], "1972-05-02[u-ca=gregory]"], +]; +const options = { + get calendarName() { + TemporalHelpers.assertUnreachable("calendarName should not be accessed"); + return ""; + } +}; + +for (const [args, expected] of tests) { + const monthday = new Temporal.PlainMonthDay(5, 2, ...args); + const result = monthday.toJSON(options); + assert.sameValue(result, expected); +} diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toJSON/year-format.js b/test/intl402/Temporal/PlainMonthDay/prototype/toJSON/year-format.js new file mode 100644 index 00000000000..6ac57221df4 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toJSON/year-format.js @@ -0,0 +1,51 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tojson +description: Verify that the year is appropriately formatted as 4 or 6 digits +features: [Temporal] +---*/ + +// For PlainMonthDay, the ISO reference year is only present in the string if +// the calendar is not ISO 8601 +const calendar = "gregory"; + +let instance = new Temporal.PlainMonthDay(12, 3, calendar, -100000); +assert.sameValue(instance.toJSON(), "-100000-12-03[u-ca=gregory]", "large negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(4, 5, calendar, -10000); +assert.sameValue(instance.toJSON(), "-010000-04-05[u-ca=gregory]", "smallest 5-digit negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(6, 7, calendar, -9999); +assert.sameValue(instance.toJSON(), "-009999-06-07[u-ca=gregory]", "largest 4-digit negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(8, 9, calendar, -1000); +assert.sameValue(instance.toJSON(), "-001000-08-09[u-ca=gregory]", "smallest 4-digit negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(10, 9, calendar, -999); +assert.sameValue(instance.toJSON(), "-000999-10-09[u-ca=gregory]", "largest 3-digit negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(8, 7, calendar, -1); +assert.sameValue(instance.toJSON(), "-000001-08-07[u-ca=gregory]", "year -1 formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(6, 5, calendar, 0); +assert.sameValue(instance.toJSON(), "0000-06-05[u-ca=gregory]", "year 0 formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(4, 3, calendar, 1); +assert.sameValue(instance.toJSON(), "0001-04-03[u-ca=gregory]", "year 1 formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(2, 10, calendar, 999); +assert.sameValue(instance.toJSON(), "0999-02-10[u-ca=gregory]", "largest 3-digit positive year formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(1, 23, calendar, 1000); +assert.sameValue(instance.toJSON(), "1000-01-23[u-ca=gregory]", "smallest 4-digit positive year formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(4, 5, calendar, 9999); +assert.sameValue(instance.toJSON(), "9999-04-05[u-ca=gregory]", "largest 4-digit positive year formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(6, 7, calendar, 10000); +assert.sameValue(instance.toJSON(), "+010000-06-07[u-ca=gregory]", "smallest 5-digit positive year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(8, 9, calendar, 100000); +assert.sameValue(instance.toJSON(), "+100000-08-09[u-ca=gregory]", "large positive year formatted as 6-digit"); diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js new file mode 100644 index 00000000000..0dca04e70cc --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-always.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tostring +description: If calendarName is "always", the calendar ID should be included. +features: [Temporal] +---*/ + +const tests = [ + [[], "1972-05-02[u-ca=iso8601]", "built-in ISO"], + [["gregory"], "1972-05-02[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const monthday = new Temporal.PlainMonthDay(5, 2, ...args); + const result = monthday.toString({ calendarName: "always" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); +} diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js new file mode 100644 index 00000000000..3acb78b84f6 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-auto.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tostring +description: If calendarName is "auto", "iso8601" should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "05-02", "built-in ISO"], + [["gregory"], "1972-05-02[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const monthday = new Temporal.PlainMonthDay(5, 2, ...args); + const result = monthday.toString({ calendarName: "auto" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); +} diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..a3998621b37 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-critical.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tostring +description: > + If calendarName is "calendar", the calendar ID should be included and prefixed + with "!". +features: [Temporal] +---*/ + +const tests = [ + [[], "1972-05-02[!u-ca=iso8601]", "built-in ISO"], + [["gregory"], "1972-05-02[!u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const monthday = new Temporal.PlainMonthDay(5, 2, ...args); + const result = monthday.toString({ calendarName: "critical" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); +} diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js new file mode 100644 index 00000000000..2f13967f772 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-never.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tostring +description: If calendarName is "never", the calendar ID should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "05-02", "built-in ISO"], + [["gregory"], "1972-05-02", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const monthday = new Temporal.PlainMonthDay(5, 2, ...args); + const result = monthday.toString({ calendarName: "never" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); +} diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js new file mode 100644 index 00000000000..e378d998573 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.protoype.tostring +description: Fallback value for calendarName option +info: | + sec-getoption step 3: + 3. If _value_ is *undefined*, return _fallback_. + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.plainmonthday.protoype.tostring step 4: + 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +features: [Temporal] +---*/ + +const tests = [ + [[], "05-02", "built-in ISO"], + [["gregory"], "1972-05-02[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const monthday = new Temporal.PlainMonthDay(5, 2, ...args); + const result = monthday.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg +} diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js new file mode 100644 index 00000000000..35d25ccc4c6 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toString/calendarname-wrong-type.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.protoype.tostring +description: Type conversions for calendarName option +info: | + sec-getoption step 9.a: + a. Set _value_ to ? ToString(_value_). + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.plainmonthday.protoype.tostring step 4: + 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const monthday = new Temporal.PlainMonthDay(5, 2, "gregory"); + +TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", + (calendarName) => monthday.toString({ calendarName }), + (result, descr) => assert.sameValue(result, "1972-05-02[u-ca=gregory]", descr), +); diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toString/options-undefined.js b/test/intl402/Temporal/PlainMonthDay/prototype/toString/options-undefined.js new file mode 100644 index 00000000000..906740b3c59 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toString/options-undefined.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tostring +description: Verify that undefined options are handled correctly. +features: [Temporal] +---*/ + +const tests = [ + [[], "05-02"], + [["gregory"], "1972-05-02[u-ca=gregory]"], +]; + +for (const [args, expected] of tests) { + const monthday = new Temporal.PlainMonthDay(5, 2, ...args); + const explicit = monthday.toString(undefined); + assert.sameValue(explicit, expected, "default calendarName option is auto"); + + const implicit = monthday.toString(); + assert.sameValue(implicit, expected, "default calendarName option is auto"); +} diff --git a/test/intl402/Temporal/PlainMonthDay/prototype/toString/year-format.js b/test/intl402/Temporal/PlainMonthDay/prototype/toString/year-format.js new file mode 100644 index 00000000000..ae3f43542d3 --- /dev/null +++ b/test/intl402/Temporal/PlainMonthDay/prototype/toString/year-format.js @@ -0,0 +1,51 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainmonthday.prototype.tostring +description: Verify that the year is appropriately formatted as 4 or 6 digits +features: [Temporal] +---*/ + +// For PlainMonthDay, the ISO reference year is only present in the string if +// the calendar is not ISO 8601 +const calendar = "gregory"; + +let instance = new Temporal.PlainMonthDay(12, 3, calendar, -100000); +assert.sameValue(instance.toString(), "-100000-12-03[u-ca=gregory]", "large negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(4, 5, calendar, -10000); +assert.sameValue(instance.toString(), "-010000-04-05[u-ca=gregory]", "smallest 5-digit negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(6, 7, calendar, -9999); +assert.sameValue(instance.toString(), "-009999-06-07[u-ca=gregory]", "largest 4-digit negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(8, 9, calendar, -1000); +assert.sameValue(instance.toString(), "-001000-08-09[u-ca=gregory]", "smallest 4-digit negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(10, 9, calendar, -999); +assert.sameValue(instance.toString(), "-000999-10-09[u-ca=gregory]", "largest 3-digit negative year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(8, 7, calendar, -1); +assert.sameValue(instance.toString(), "-000001-08-07[u-ca=gregory]", "year -1 formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(6, 5, calendar, 0); +assert.sameValue(instance.toString(), "0000-06-05[u-ca=gregory]", "year 0 formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(4, 3, calendar, 1); +assert.sameValue(instance.toString(), "0001-04-03[u-ca=gregory]", "year 1 formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(2, 10, calendar, 999); +assert.sameValue(instance.toString(), "0999-02-10[u-ca=gregory]", "largest 3-digit positive year formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(1, 23, calendar, 1000); +assert.sameValue(instance.toString(), "1000-01-23[u-ca=gregory]", "smallest 4-digit positive year formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(4, 5, calendar, 9999); +assert.sameValue(instance.toString(), "9999-04-05[u-ca=gregory]", "largest 4-digit positive year formatted as 4-digit"); + +instance = new Temporal.PlainMonthDay(6, 7, calendar, 10000); +assert.sameValue(instance.toString(), "+010000-06-07[u-ca=gregory]", "smallest 5-digit positive year formatted as 6-digit"); + +instance = new Temporal.PlainMonthDay(8, 9, calendar, 100000); +assert.sameValue(instance.toString(), "+100000-08-09[u-ca=gregory]", "large positive year formatted as 6-digit"); diff --git a/test/intl402/Temporal/PlainYearMonth/compare/compare-calendar.js b/test/intl402/Temporal/PlainYearMonth/compare/compare-calendar.js new file mode 100644 index 00000000000..90eac9a39d8 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/compare/compare-calendar.js @@ -0,0 +1,12 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.compare +description: compare() does not take the calendar into account +features: [Temporal] +---*/ + +const ym1 = new Temporal.PlainYearMonth(2000, 1, "iso8601", 1); +const ym2 = new Temporal.PlainYearMonth(2000, 1, "gregory", 1); +assert.sameValue(Temporal.PlainYearMonth.compare(ym1, ym2), 0); diff --git a/test/intl402/Temporal/PlainYearMonth/compare/exhaustive.js b/test/intl402/Temporal/PlainYearMonth/compare/exhaustive.js new file mode 100644 index 00000000000..ee203d1afdf --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/compare/exhaustive.js @@ -0,0 +1,47 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.compare +description: Tests for compare() with each possible outcome +features: [Temporal] +---*/ + +const cal1 = "iso8601"; +const cal2 = "gregory"; + +assert.sameValue( + Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(1987, 5, cal2)), + 1, + "year >" +); +assert.sameValue( + Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 12, cal1), new Temporal.PlainYearMonth(2048, 12, cal2)), + -1, + "year <" +); +assert.sameValue( + Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(2000, 3, cal2)), + 1, + "month >" +); +assert.sameValue( + Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 4, cal1), new Temporal.PlainYearMonth(1981, 12, cal2)), + -1, + "month <" +); +assert.sameValue( + Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1, 30), new Temporal.PlainYearMonth(2000, 5, cal2, 14)), + 1, + "reference day >" +); +assert.sameValue( + Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(1981, 4, cal1, 1), new Temporal.PlainYearMonth(1981, 4, cal2, 12)), + -1, + "reference day <" +); +assert.sameValue( + Temporal.PlainYearMonth.compare(new Temporal.PlainYearMonth(2000, 5, cal1), new Temporal.PlainYearMonth(2000, 5, cal2)), + 0, + "=" +); diff --git a/test/intl402/Temporal/PlainYearMonth/from/one-of-era-erayear-undefined.js b/test/intl402/Temporal/PlainYearMonth/from/one-of-era-erayear-undefined.js new file mode 100644 index 00000000000..917e322f073 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/from/one-of-era-erayear-undefined.js @@ -0,0 +1,14 @@ +// Copyright (C) 2023 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: Throw a TypeError if only one of era/eraYear fields is present +features: [Temporal] +---*/ + +const base = { year: 2000, month: 5, day: 2, era: "ce", calendar: "gregory" }; +assert.throws(TypeError, () => Temporal.PlainYearMonth.from(base)); + +const base2 = { year: 2000, month: 5, day: 2, eraYear: 1, calendar: "gregory" }; +assert.throws(TypeError, () => Temporal.PlainYearMonth.from(base2)); diff --git a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-chinese.js b/test/intl402/Temporal/PlainYearMonth/from/reference-day-chinese.js similarity index 79% rename from test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-chinese.js rename to test/intl402/Temporal/PlainYearMonth/from/reference-day-chinese.js index 4d319c7a498..0a8e3581bf5 100644 --- a/test/intl402/Temporal/Calendar/prototype/yearMonthFromFields/reference-day-chinese.js +++ b/test/intl402/Temporal/PlainYearMonth/from/reference-day-chinese.js @@ -11,8 +11,6 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const chinese = new Temporal.Calendar("chinese"); - // Month codes, month indices, and the ISO reference days of the months in 2022 const months2022TestData = [ // TODO: Sources conflict over whether M01L and M12L exist in _any_ year. @@ -37,11 +35,11 @@ const months2022TestData = [ ]; for (const [nonLeapMonthCode, month, referenceISODay] of months2022TestData) { // Allow implementation-defined "epoch year" for the Chinese calendar. - const year = new Temporal.PlainDate(2022, 3, 1).withCalendar(chinese).year; + const year = new Temporal.PlainDate(2022, 3, 1).withCalendar("chinese").year; const leapMonthCode = nonLeapMonthCode + "L"; - const fields = { year, monthCode: leapMonthCode }; + const fields = { year, monthCode: leapMonthCode, calendar: "chinese" }; - const result = chinese.yearMonthFromFields(fields, { overflow: "constrain" }); + const result = Temporal.PlainYearMonth.from(fields, { overflow: "constrain" }); TemporalHelpers.assertPlainYearMonth( result, year, month, nonLeapMonthCode, @@ -51,7 +49,7 @@ for (const [nonLeapMonthCode, month, referenceISODay] of months2022TestData) { assert.throws( RangeError, - () => chinese.yearMonthFromFields(fields, { overflow: "reject" }), + () => Temporal.PlainYearMonth.from(fields, { overflow: "reject" }), `Chinese intercalary month ${leapMonthCode} does not exist in year 2022 (overflow reject)` ); } @@ -72,15 +70,14 @@ const leapMonthsTestData = [ ]; for (const [monthCode, relatedYear, month, referenceISODay, isoYear = relatedYear, isoMonth = month] of leapMonthsTestData) { // Allow implementation-defined "epoch year" for the Chinese calendar. - const year = new Temporal.PlainDate(relatedYear, 3, 1).withCalendar(chinese).year; - const result = chinese.yearMonthFromFields({ year, monthCode }); + const year = new Temporal.PlainDate(relatedYear, 3, 1).withCalendar("chinese").year; + const result = Temporal.PlainYearMonth.from({ year, monthCode, calendar: "chinese" }); TemporalHelpers.assertPlainYearMonth( result, year, month, monthCode, `Date of sample Chinese intercalary month ${monthCode}`, /* era = */ undefined, /* era year = */ undefined, referenceISODay ); - const isoFields = result.getISOFields(); - assert.sameValue(isoFields.isoYear, isoYear, `${year}-${monthCode} starts in ISO year ${isoYear}`); - assert.sameValue(isoFields.isoMonth, isoMonth, `${year}-${monthCode} starts in ISO month ${isoMonth}`); + const isoYearMonth = result.toString().slice(0, 7); + assert.sameValue(isoYearMonth, `${isoYear}-${String(isoMonth).padStart(2, '0')}`, `${year}-${monthCode} starts in ISO month ${isoYear}-${isoMonth}`); } diff --git a/test/intl402/Temporal/PlainYearMonth/from/reference-day-gregory.js b/test/intl402/Temporal/PlainYearMonth/from/reference-day-gregory.js new file mode 100644 index 00000000000..03231f65eb6 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/from/reference-day-gregory.js @@ -0,0 +1,36 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearmonthfromfields +description: Reference ISO day is chosen to be the first of the calendar month +info: | + 6.d. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, *1*𝔽). + e. Let _result_ be ? CalendarDateToISO(_calendar_.[[Identifier]], _fields_, _options_). +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const result1 = Temporal.PlainYearMonth.from({ year: 2023, monthCode: "M01", day: 13, calendar: "gregory" }); +TemporalHelpers.assertPlainYearMonth( + result1, + 2023, 1, "M01", + "reference day is 1 even if day is given", + "ce", 2023, /* reference day = */ 1 +); + +const result2 = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M02", day: 50, calendar: "gregory" }, { overflow: "constrain" }); +TemporalHelpers.assertPlainYearMonth( + result2, + 2021, 2, "M02", + "reference day is set correctly even if day is out of range (overflow constrain)", + "ce", 2021, /* reference day = */ 1 +); + +const result3 = Temporal.PlainYearMonth.from({ year: 2021, monthCode: "M02", day: 50, calendar: "gregory" }, { overflow: "reject" }); +TemporalHelpers.assertPlainYearMonth( + result3, + 2021, 2, "M02", + "reference day is set correctly even if day is out of range (overflow reject)", + "ce", 2021, /* reference day = */ 1 +); diff --git a/test/intl402/Temporal/PlainYearMonth/from/reference-day-hebrew.js b/test/intl402/Temporal/PlainYearMonth/from/reference-day-hebrew.js new file mode 100644 index 00000000000..e1847d46196 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/from/reference-day-hebrew.js @@ -0,0 +1,66 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.yearmonthfromfields +description: Reference ISO day is chosen to be the first of the calendar month +info: | + 6.d. Perform ! CreateDataPropertyOrThrow(_fields_, *"day"*, *1*𝔽). + e. Let _result_ be ? CalendarDateToISO(_calendar_.[[Identifier]], _fields_, _options_). +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +const result4 = Temporal.PlainYearMonth.from({ year: 5782, monthCode: "M04", day: 20, calendar: "hebrew" }); +TemporalHelpers.assertPlainYearMonth( + result4, + 5782, 4, "M04", + "reference day is the first of the calendar month even if day is given", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 5 +); +const isoYearMonth = result4.toString().slice(0, 7); +assert.sameValue(isoYearMonth, "2021-12", "Tevet 5782 begins in ISO 2021-12"); + +const result5 = Temporal.PlainYearMonth.from({ year: 5783, monthCode: "M05L", calendar: "hebrew" }, { overflow: "constrain" }); +TemporalHelpers.assertPlainYearMonth( + result5, + 5783, 6, "M06", + "month code M05L does not exist in year 5783 (overflow constrain); Hebrew calendar constrains Adar I to Adar", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 22 +); + +assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from({ year: 5783, monthCode: "M05L", calendar: "hebrew" }, { overflow: "reject" }), + "month code M05L does not exist in year 5783 (overflow reject)", +); + +const result6 = Temporal.PlainYearMonth.from({ year: 5783, month: 13, calendar: "hebrew" }, { overflow: "constrain" }); +TemporalHelpers.assertPlainYearMonth( + result6, + 5783, 12, "M12", + "month 13 does not exist in year 5783 (overflow constrain)", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 18 +); + +assert.throws( + RangeError, + () => Temporal.PlainYearMonth.from({ year: 5783, month: 13, calendar: "hebrew" }, { overflow: "reject" }), + "month 13 does not exist in year 5783 (overflow reject)", +); + +const result7 = Temporal.PlainYearMonth.from({ year: 5782, monthCode: "M04", day: 50, calendar: "hebrew" }, { overflow: "constrain" }); +TemporalHelpers.assertPlainYearMonth( + result7, + 5782, 4, "M04", + "reference day is set correctly even if day is out of range (overflow constrain)", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 5 +); + +const result8 = Temporal.PlainYearMonth.from({ year: 5782, monthCode: "M04", day: 50, calendar: "hebrew" }, { overflow: "reject" }); +TemporalHelpers.assertPlainYearMonth( + result8, + 5782, 4, "M04", + "reference day is set correctly even if day is out of range (overflow reject)", + /* era = */ undefined, /* era year = */ undefined, /* reference day = */ 5 +); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/add/options-undefined.js b/test/intl402/Temporal/PlainYearMonth/prototype/add/options-undefined.js new file mode 100644 index 00000000000..999aaaef7c7 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/add/options-undefined.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.add +description: Verify that undefined options are handled correctly. +features: [Temporal] +---*/ + +// overflow option has no effect on addition in the ISO calendar, so verify this +// with a lunisolar calendar. Default overflow is "constrain" so this should not +// throw. + +const yearmonth = Temporal.PlainYearMonth.from({ + year: 5779, + monthCode: "M05L", + calendar: "hebrew" +}); +const duration = { years: 1 }; + +yearmonth.add(duration, undefined); + +yearmonth.add(duration); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js b/test/intl402/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js new file mode 100644 index 00000000000..f3a82da2511 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/equals/compare-calendar.js @@ -0,0 +1,16 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.equals +description: equals() takes the calendar into account +features: [Temporal] +---*/ + +const ym1 = new Temporal.PlainYearMonth(2000, 1, "iso8601", 1); +const ym2 = new Temporal.PlainYearMonth(2000, 1, "iso8601", 1); +assert(ym1.equals(ym2), "Equal if calendars and ISO dates are equal"); + +const ym3 = new Temporal.PlainYearMonth(2000, 1, "iso8601", 1); +const ym4 = new Temporal.PlainYearMonth(2000, 1, "gregory", 1); +assert(!ym3.equals(ym4), "Unequal if ISO dates are equal but calendars are not"); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/era/validate-calendar-value.js b/test/intl402/Temporal/PlainYearMonth/prototype/era/validate-calendar-value.js deleted file mode 100644 index 00b2c483704..00000000000 --- a/test/intl402/Temporal/PlainYearMonth/prototype/era/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2023 Richard Gibson. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.era -description: Validate result returned from calendar era() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, TypeError], - [-Infinity, TypeError], - [NaN, TypeError], - [-7, TypeError], - [-0.1, TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, TypeError], - [{valueOf() { return "7"; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - era() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.throws(error, () => instance.era, `${typeof result} ${String(result)} not converted to string`); -}); - -const preservedResults = [ - undefined, - "string", - "7", - "7.5", -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - era() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.sameValue(instance.era, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/eraYear/validate-calendar-value.js b/test/intl402/Temporal/PlainYearMonth/prototype/eraYear/validate-calendar-value.js deleted file mode 100644 index ef56886f850..00000000000 --- a/test/intl402/Temporal/PlainYearMonth/prototype/eraYear/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2023 Richard Gibson. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.plainyearmonth.prototype.erayear -description: Validate result returned from calendar eraYear() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - eraYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.throws(error, () => instance.eraYear, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - undefined, - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - eraYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.PlainYearMonth(1981, 12, calendar); - assert.sameValue(instance.eraYear, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js b/test/intl402/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js new file mode 100644 index 00000000000..614f38cb2b6 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/since/mixed-calendar-invalid.js @@ -0,0 +1,13 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.since +description: Mixed calendars throw as invalid +features: [Temporal] +---*/ + +const ym1 = new Temporal.PlainYearMonth(2000, 1); +const ym2 = new Temporal.PlainYearMonth(2000, 1, "gregory"); + +assert.throws(RangeError, () => ym1.since(ym2), 'since throws with different calendars'); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/subtract/options-undefined.js b/test/intl402/Temporal/PlainYearMonth/prototype/subtract/options-undefined.js new file mode 100644 index 00000000000..0e17b531780 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/subtract/options-undefined.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.subtract +description: Verify that undefined options are handled correctly. +features: [Temporal] +---*/ + +// overflow option has no effect on addition in the ISO calendar, so verify this +// with a lunisolar calendar. Default overflow is "constrain" so this should not +// throw. + +const yearmonth = Temporal.PlainYearMonth.from({ + year: 5779, + monthCode: "M05L", + calendar: "hebrew" +}); +const duration = { years: 1 }; + +yearmonth.subtract(duration, undefined); + +yearmonth.subtract(duration); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js new file mode 100644 index 00000000000..49227c54ceb --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-always.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.tostring +description: If calendarName is "always", the calendar ID should be included. +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05-01[u-ca=iso8601]", "built-in ISO"], + [["gregory"], "2000-05-01[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); + const result = yearmonth.toString({ calendarName: "always" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); +} diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js new file mode 100644 index 00000000000..b5f77cdf1a5 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-auto.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.tostring +description: If calendarName is "auto", "iso8601" should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05", "built-in ISO"], + [["gregory"], "2000-05-01[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); + const result = yearmonth.toString({ calendarName: "auto" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); +} diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..e5ee9de94b5 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-critical.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.tostring +description: > + If calendarName is "calendar", the calendar ID should be included and prefixed + with "!". +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05-01[!u-ca=iso8601]", "built-in ISO"], + [["gregory"], "2000-05-01[!u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); + const result = yearmonth.toString({ calendarName: "critical" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); +} diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js new file mode 100644 index 00000000000..84d01b04a1e --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-never.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.tostring +description: If calendarName is "never", the calendar ID should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05", "built-in ISO"], + [["gregory"], "2000-05-01", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); + const result = yearmonth.toString({ calendarName: "never" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); +} diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js new file mode 100644 index 00000000000..b45ccfef780 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.protoype.tostring +description: Fallback value for calendarName option +info: | + sec-getoption step 3: + 3. If _value_ is *undefined*, return _fallback_. + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.plainyearmonth.protoype.tostring step 4: + 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +features: [Temporal] +---*/ + +const tests = [ + [[], "2000-05", "built-in ISO"], + [["gregory"], "2000-05-01[u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const yearmonth = new Temporal.PlainYearMonth(2000, 5, ...args); + const result = yearmonth.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg +} diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js new file mode 100644 index 00000000000..a7c0b49cf22 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/toString/calendarname-wrong-type.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.protoype.tostring +description: Type conversions for calendarName option +info: | + sec-getoption step 9.a: + a. Set _value_ to ? ToString(_value_). + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.plainyearmonth.protoype.tostring step 4: + 4. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const yearmonth = new Temporal.PlainYearMonth(2000, 5, "gregory"); + +TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", + (calendarName) => yearmonth.toString({ calendarName }), + (result, descr) => assert.sameValue(result, "2000-05-01[u-ca=gregory]", descr), +); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/toString/options-undefined.js b/test/intl402/Temporal/PlainYearMonth/prototype/toString/options-undefined.js new file mode 100644 index 00000000000..59ccdc737d1 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/toString/options-undefined.js @@ -0,0 +1,22 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.tostring +description: Verify that undefined options are handled correctly. +features: [Temporal] +---*/ + +const yearmonth1 = new Temporal.PlainYearMonth(2000, 5); +const yearmonth2 = new Temporal.PlainYearMonth(2000, 5, "gregory", 1); + +[ + [yearmonth1, "2000-05"], + [yearmonth2, "2000-05-01[u-ca=gregory]"], +].forEach(([yearmonth, expected]) => { + const explicit = yearmonth.toString(undefined); + assert.sameValue(explicit, expected, "default calendarName option is auto"); + + const implicit = yearmonth.toString(); + assert.sameValue(implicit, expected, "default calendarName option is auto"); +}); diff --git a/test/intl402/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js b/test/intl402/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js new file mode 100644 index 00000000000..3341fab43d6 --- /dev/null +++ b/test/intl402/Temporal/PlainYearMonth/prototype/until/mixed-calendar-invalid.js @@ -0,0 +1,13 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.plainyearmonth.prototype.until +description: Mixed calendars throw as invalid +features: [Temporal] +---*/ + +const ym1 = new Temporal.PlainYearMonth(2000, 1); +const ym2 = new Temporal.PlainYearMonth(2000, 1, "gregory"); + +assert.throws(RangeError, () => ym1.until(ym2), 'until throws with different calendars'); diff --git a/test/intl402/Temporal/TimeZone/basic.js b/test/intl402/Temporal/TimeZone/basic.js deleted file mode 100644 index 11552287a10..00000000000 --- a/test/intl402/Temporal/TimeZone/basic.js +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Basic tests for the Temporal.TimeZone constructor. -features: [Temporal] ----*/ - -const valid = [ - ["Europe/Vienna"], - ["America/New_York"], - ["Africa/CAIRO", "Africa/Cairo"], - ["africa/cairo", "Africa/Cairo"], - ["Asia/Ulaanbaatar"], - ["Asia/Ulan_Bator"], - ["UTC"], - ["GMT"] -]; -for (const [zone, id = zone] of valid) { - const result = new Temporal.TimeZone(zone); - assert.sameValue(typeof result, "object", `object should be created for ${zone}`); - assert.sameValue(result.id, id, `id for ${zone} should be ${id}`); -} - -const invalid = ["+00:01.1", "-01.1"]; -for (const zone of invalid) { - assert.throws(RangeError, () => new Temporal.TimeZone(zone), `should throw for ${zone}`); -} diff --git a/test/intl402/Temporal/TimeZone/etc-timezone.js b/test/intl402/Temporal/TimeZone/etc-timezone.js deleted file mode 100644 index e2260dc7440..00000000000 --- a/test/intl402/Temporal/TimeZone/etc-timezone.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Some Etc/GMT{+/-}{0}N timezones are valid, but not all -features: [Temporal] ----*/ - -// "Etc/GMT-0" through "Etc/GMT-14" are OK - -[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14].forEach((n) => { - let tz = "Etc/GMT-" + n; - let instance = new Temporal.TimeZone(tz); - assert.sameValue( - instance.toString(), - tz, - tz + " is a valid timezone" - ); -}); - -let gmtMinus24TZ = "Etc/GMT-24"; -assert.throws( - RangeError, - () => { new Temporal.TimeZone(gmtMinus24TZ); }, - gmtMinus24TZ + " is an invalid timezone" -); - -// "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9) -[1,2,3,4,5,6,7,8,9].forEach((n) => { - let tz = "Etc/GMT-0" + n; - assert.throws( - RangeError, - () => { new Temporal.TimeZone(tz); }, - tz + " is an invalid timezone" - ); -}); - -// "Etc/GMT+0N" is not OK (0 ≤ N ≤ 9) -[0,1,2,3,4,5,6,7,8,9].forEach((n) => { - let tz = "Etc/GMT+0" + n; - assert.throws( - RangeError, - () => { new Temporal.TimeZone(tz); }, - tz + " is an invalid timezone" - ); -}); - -// Etc/GMT+0" through "Etc/GMT+12" are OK - -[0,1,2,3,4,5,6,7,8,9,10,11,12].forEach((n) => { - let tz = "Etc/GMT+" + n; - let instance = new Temporal.TimeZone(tz); - assert.sameValue( - instance.toString(), - tz, - tz + " is a valid timezone" - ); -}); - -let gmtPlus24TZ = "Etc/GMT+24"; -assert.throws( - RangeError, - () => { new Temporal.TimeZone(gmtPlus24TZ); }, - gmtPlus24TZ + " is an invalid timezone" -); diff --git a/test/intl402/Temporal/TimeZone/from/argument-object.js b/test/intl402/Temporal/TimeZone/from/argument-object.js deleted file mode 100644 index 235c25f285b..00000000000 --- a/test/intl402/Temporal/TimeZone/from/argument-object.js +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: An object is returned unchanged -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone {} - -const objects = [ - new Temporal.TimeZone("Europe/Madrid"), - new CustomTimeZone("Africa/Accra"), -]; - -const thisValues = [ - Temporal.TimeZone, - CustomTimeZone, - {}, - null, - undefined, - 7, -]; - -for (const thisValue of thisValues) { - for (const object of objects) { - const result = Temporal.TimeZone.from.call(thisValue, object); - assert.sameValue(result, object); - } - - const zdt = new Temporal.ZonedDateTime(0n, "Africa/Cairo"); - const fromZdt = Temporal.TimeZone.from.call(thisValue, zdt); - assert.notSameValue(fromZdt, zdt.getTimeZone(), "from() creates a new object for a string slot value"); - assert.sameValue(fromZdt.id, "Africa/Cairo"); -} diff --git a/test/intl402/Temporal/TimeZone/from/argument-valid.js b/test/intl402/Temporal/TimeZone/from/argument-valid.js deleted file mode 100644 index 3671857ab1f..00000000000 --- a/test/intl402/Temporal/TimeZone/from/argument-valid.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2020 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Built-in time zones are parsed correctly out of valid strings -features: [Temporal] ----*/ - -const valids = [ - ["Africa/Bissau"], - ["America/Belem"], - ["Europe/Vienna"], - ["America/New_York"], - ["Africa/CAIRO", "Africa/Cairo"], - ["Asia/Ulan_Bator"], - ["GMT"], - ["etc/gmt", "Etc/GMT"], - ["1994-11-05T08:15:30-05:00[America/New_York]", "America/New_York"], - ["1994-11-05T08:15:30-05[America/New_York]", "America/New_York"], -]; - -for (const [valid, canonical = valid] of valids) { - const result = Temporal.TimeZone.from(valid); - assert.sameValue(Object.getPrototypeOf(result), Temporal.TimeZone.prototype); - assert.sameValue(result.id, canonical); - assert.sameValue(result.toString(), canonical); -} diff --git a/test/intl402/Temporal/TimeZone/from/etc-timezone.js b/test/intl402/Temporal/TimeZone/from/etc-timezone.js deleted file mode 100644 index a925836c191..00000000000 --- a/test/intl402/Temporal/TimeZone/from/etc-timezone.js +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Some Etc/GMT{+/-}{0}N timezones are valid, but not all -features: [Temporal] ----*/ - -// "Etc/GMT-0" through "Etc/GMT-14" are OK - -[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14].forEach((n) => { - const tz = "Etc/GMT-" + n; - const instance = Temporal.TimeZone.from(tz); - assert.sameValue( - instance.toString(), - tz, - tz + " is a valid timezone" - ); -}); - -const gmtMinus24TZ = "Etc/GMT-24"; -assert.throws( - RangeError, - () => Temporal.TimeZone.from(gmtMinus24TZ), - gmtMinus24TZ + " is an invalid timezone" -); - -// "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9) -[1, 2, 3, 4, 5, 6, 7, 8, 9].forEach((n) => { - const tz = "Etc/GMT-0" + n; - assert.throws( - RangeError, - () => Temporal.TimeZone.from(tz), - tz + " is an invalid timezone" - ); -}); - -// "Etc/GMT+0N" is not OK (0 ≤ N ≤ 9) -[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].forEach((n) => { - const tz = "Etc/GMT+0" + n; - assert.throws( - RangeError, - () => Temporal.TimeZone.from(tz), - tz + " is an invalid timezone" - ); -}); - -// "Etc/GMT+0" through "Etc/GMT+12" are OK - -[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].forEach((n) => { - const tz = "Etc/GMT+" + n; - const instance = Temporal.TimeZone.from(tz); - assert.sameValue( - instance.toString(), - tz, - tz + " is a valid timezone" - ); -}); - -const gmtPlus24TZ = "Etc/GMT+24"; -assert.throws( - RangeError, - () => Temporal.TimeZone.from(gmtPlus24TZ), - gmtPlus24TZ + " is an invalid timezone" -); diff --git a/test/intl402/Temporal/TimeZone/from/iana-legacy-names.js b/test/intl402/Temporal/TimeZone/from/iana-legacy-names.js deleted file mode 100644 index d820320e17f..00000000000 --- a/test/intl402/Temporal/TimeZone/from/iana-legacy-names.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: IANA legacy names must be supported -features: [Temporal] ----*/ - -const legacyNames = [ - "Etc/GMT0", - "GMT0", - "GMT-0", - "GMT+0", - "EST5EDT", - "CST6CDT", - "MST7MDT", - "PST8PDT" -]; - -legacyNames.forEach((arg) => { - const tz = Temporal.TimeZone.from(arg); - assert.sameValue(tz.toString(), arg, `"${arg}" does not match "${tz.toString()}" time zone identifier`); -}); diff --git a/test/intl402/Temporal/TimeZone/from/timezone-case-insensitive.js b/test/intl402/Temporal/TimeZone/from/timezone-case-insensitive.js deleted file mode 100644 index 53369d8377b..00000000000 --- a/test/intl402/Temporal/TimeZone/from/timezone-case-insensitive.js +++ /dev/null @@ -1,625 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Time zone identifiers are case-normalized -features: [Temporal] ----*/ - -const timeZoneIdentifiers = [ - // IANA TZDB Zone names - 'Africa/Abidjan', - 'Africa/Algiers', - 'Africa/Bissau', - 'Africa/Cairo', - 'Africa/Casablanca', - 'Africa/Ceuta', - 'Africa/El_Aaiun', - 'Africa/Johannesburg', - 'Africa/Juba', - 'Africa/Khartoum', - 'Africa/Lagos', - 'Africa/Maputo', - 'Africa/Monrovia', - 'Africa/Nairobi', - 'Africa/Ndjamena', - 'Africa/Sao_Tome', - 'Africa/Tripoli', - 'Africa/Tunis', - 'Africa/Windhoek', - 'America/Adak', - 'America/Anchorage', - 'America/Araguaina', - 'America/Argentina/Buenos_Aires', - 'America/Argentina/Catamarca', - 'America/Argentina/Cordoba', - 'America/Argentina/Jujuy', - 'America/Argentina/La_Rioja', - 'America/Argentina/Mendoza', - 'America/Argentina/Rio_Gallegos', - 'America/Argentina/Salta', - 'America/Argentina/San_Juan', - 'America/Argentina/San_Luis', - 'America/Argentina/Tucuman', - 'America/Argentina/Ushuaia', - 'America/Asuncion', - 'America/Bahia', - 'America/Bahia_Banderas', - 'America/Barbados', - 'America/Belem', - 'America/Belize', - 'America/Boa_Vista', - 'America/Bogota', - 'America/Boise', - 'America/Cambridge_Bay', - 'America/Campo_Grande', - 'America/Cancun', - 'America/Caracas', - 'America/Cayenne', - 'America/Chicago', - 'America/Chihuahua', - // 'America/Ciudad_Juarez' // uncomment after Node supports this ID added in TZDB 2022g - 'America/Costa_Rica', - 'America/Cuiaba', - 'America/Danmarkshavn', - 'America/Dawson', - 'America/Dawson_Creek', - 'America/Denver', - 'America/Detroit', - 'America/Edmonton', - 'America/Eirunepe', - 'America/El_Salvador', - 'America/Fort_Nelson', - 'America/Fortaleza', - 'America/Glace_Bay', - 'America/Goose_Bay', - 'America/Grand_Turk', - 'America/Guatemala', - 'America/Guayaquil', - 'America/Guyana', - 'America/Halifax', - 'America/Havana', - 'America/Hermosillo', - 'America/Indiana/Indianapolis', - 'America/Indiana/Knox', - 'America/Indiana/Marengo', - 'America/Indiana/Petersburg', - 'America/Indiana/Tell_City', - 'America/Indiana/Vevay', - 'America/Indiana/Vincennes', - 'America/Indiana/Winamac', - 'America/Inuvik', - 'America/Iqaluit', - 'America/Jamaica', - 'America/Juneau', - 'America/Kentucky/Louisville', - 'America/Kentucky/Monticello', - 'America/La_Paz', - 'America/Lima', - 'America/Los_Angeles', - 'America/Maceio', - 'America/Managua', - 'America/Manaus', - 'America/Martinique', - 'America/Matamoros', - 'America/Mazatlan', - 'America/Menominee', - 'America/Merida', - 'America/Metlakatla', - 'America/Mexico_City', - 'America/Miquelon', - 'America/Moncton', - 'America/Monterrey', - 'America/Montevideo', - 'America/New_York', - 'America/Nome', - 'America/Noronha', - 'America/North_Dakota/Beulah', - 'America/North_Dakota/Center', - 'America/North_Dakota/New_Salem', - 'America/Nuuk', - 'America/Ojinaga', - 'America/Panama', - 'America/Paramaribo', - 'America/Phoenix', - 'America/Port-au-Prince', - 'America/Porto_Velho', - 'America/Puerto_Rico', - 'America/Punta_Arenas', - 'America/Rankin_Inlet', - 'America/Recife', - 'America/Regina', - 'America/Resolute', - 'America/Rio_Branco', - 'America/Santarem', - 'America/Santiago', - 'America/Santo_Domingo', - 'America/Sao_Paulo', - 'America/Scoresbysund', - 'America/Sitka', - 'America/St_Johns', - 'America/Swift_Current', - 'America/Tegucigalpa', - 'America/Thule', - 'America/Tijuana', - 'America/Toronto', - 'America/Vancouver', - 'America/Whitehorse', - 'America/Winnipeg', - 'America/Yakutat', - 'America/Yellowknife', - 'Antarctica/Casey', - 'Antarctica/Davis', - 'Antarctica/Macquarie', - 'Antarctica/Mawson', - 'Antarctica/Palmer', - 'Antarctica/Rothera', - 'Antarctica/Troll', - 'Asia/Almaty', - 'Asia/Amman', - 'Asia/Anadyr', - 'Asia/Aqtau', - 'Asia/Aqtobe', - 'Asia/Ashgabat', - 'Asia/Atyrau', - 'Asia/Baghdad', - 'Asia/Baku', - 'Asia/Bangkok', - 'Asia/Barnaul', - 'Asia/Beirut', - 'Asia/Bishkek', - 'Asia/Chita', - 'Asia/Choibalsan', - 'Asia/Colombo', - 'Asia/Damascus', - 'Asia/Dhaka', - 'Asia/Dili', - 'Asia/Dubai', - 'Asia/Dushanbe', - 'Asia/Famagusta', - 'Asia/Gaza', - 'Asia/Hebron', - 'Asia/Ho_Chi_Minh', - 'Asia/Hong_Kong', - 'Asia/Hovd', - 'Asia/Irkutsk', - 'Asia/Jakarta', - 'Asia/Jayapura', - 'Asia/Jerusalem', - 'Asia/Kabul', - 'Asia/Kamchatka', - 'Asia/Karachi', - 'Asia/Kathmandu', - 'Asia/Khandyga', - 'Asia/Kolkata', - 'Asia/Krasnoyarsk', - 'Asia/Kuching', - 'Asia/Macau', - 'Asia/Magadan', - 'Asia/Makassar', - 'Asia/Manila', - 'Asia/Nicosia', - 'Asia/Novokuznetsk', - 'Asia/Novosibirsk', - 'Asia/Omsk', - 'Asia/Oral', - 'Asia/Pontianak', - 'Asia/Pyongyang', - 'Asia/Qatar', - 'Asia/Qostanay', - 'Asia/Qyzylorda', - 'Asia/Riyadh', - 'Asia/Sakhalin', - 'Asia/Samarkand', - 'Asia/Seoul', - 'Asia/Shanghai', - 'Asia/Singapore', - 'Asia/Srednekolymsk', - 'Asia/Taipei', - 'Asia/Tashkent', - 'Asia/Tbilisi', - 'Asia/Tehran', - 'Asia/Thimphu', - 'Asia/Tokyo', - 'Asia/Tomsk', - 'Asia/Ulaanbaatar', - 'Asia/Urumqi', - 'Asia/Ust-Nera', - 'Asia/Vladivostok', - 'Asia/Yakutsk', - 'Asia/Yangon', - 'Asia/Yekaterinburg', - 'Asia/Yerevan', - 'Atlantic/Azores', - 'Atlantic/Bermuda', - 'Atlantic/Canary', - 'Atlantic/Cape_Verde', - 'Atlantic/Faroe', - 'Atlantic/Madeira', - 'Atlantic/South_Georgia', - 'Atlantic/Stanley', - 'Australia/Adelaide', - 'Australia/Brisbane', - 'Australia/Broken_Hill', - 'Australia/Darwin', - 'Australia/Eucla', - 'Australia/Hobart', - 'Australia/Lindeman', - 'Australia/Lord_Howe', - 'Australia/Melbourne', - 'Australia/Perth', - 'Australia/Sydney', - 'CET', - 'CST6CDT', - 'EET', - 'EST', - 'EST5EDT', - 'Etc/GMT', - 'Etc/GMT+1', - 'Etc/GMT+10', - 'Etc/GMT+11', - 'Etc/GMT+12', - 'Etc/GMT+2', - 'Etc/GMT+3', - 'Etc/GMT+4', - 'Etc/GMT+5', - 'Etc/GMT+6', - 'Etc/GMT+7', - 'Etc/GMT+8', - 'Etc/GMT+9', - 'Etc/GMT-1', - 'Etc/GMT-10', - 'Etc/GMT-11', - 'Etc/GMT-12', - 'Etc/GMT-13', - 'Etc/GMT-14', - 'Etc/GMT-2', - 'Etc/GMT-3', - 'Etc/GMT-4', - 'Etc/GMT-5', - 'Etc/GMT-6', - 'Etc/GMT-7', - 'Etc/GMT-8', - 'Etc/GMT-9', - 'Etc/UTC', - 'Europe/Andorra', - 'Europe/Astrakhan', - 'Europe/Athens', - 'Europe/Belgrade', - 'Europe/Berlin', - 'Europe/Brussels', - 'Europe/Bucharest', - 'Europe/Budapest', - 'Europe/Chisinau', - 'Europe/Dublin', - 'Europe/Gibraltar', - 'Europe/Helsinki', - 'Europe/Istanbul', - 'Europe/Kaliningrad', - 'Europe/Kirov', - 'Europe/Kyiv', - 'Europe/Lisbon', - 'Europe/London', - 'Europe/Madrid', - 'Europe/Malta', - 'Europe/Minsk', - 'Europe/Moscow', - 'Europe/Paris', - 'Europe/Prague', - 'Europe/Riga', - 'Europe/Rome', - 'Europe/Samara', - 'Europe/Saratov', - 'Europe/Simferopol', - 'Europe/Sofia', - 'Europe/Tallinn', - 'Europe/Tirane', - 'Europe/Ulyanovsk', - 'Europe/Vienna', - 'Europe/Vilnius', - 'Europe/Volgograd', - 'Europe/Warsaw', - 'Europe/Zurich', - 'HST', - 'Indian/Chagos', - 'Indian/Maldives', - 'Indian/Mauritius', - 'MET', - 'MST', - 'MST7MDT', - 'PST8PDT', - 'Pacific/Apia', - 'Pacific/Auckland', - 'Pacific/Bougainville', - 'Pacific/Chatham', - 'Pacific/Easter', - 'Pacific/Efate', - 'Pacific/Fakaofo', - 'Pacific/Fiji', - 'Pacific/Galapagos', - 'Pacific/Gambier', - 'Pacific/Guadalcanal', - 'Pacific/Guam', - 'Pacific/Honolulu', - 'Pacific/Kanton', - 'Pacific/Kiritimati', - 'Pacific/Kosrae', - 'Pacific/Kwajalein', - 'Pacific/Marquesas', - 'Pacific/Nauru', - 'Pacific/Niue', - 'Pacific/Norfolk', - 'Pacific/Noumea', - 'Pacific/Pago_Pago', - 'Pacific/Palau', - 'Pacific/Pitcairn', - 'Pacific/Port_Moresby', - 'Pacific/Rarotonga', - 'Pacific/Tahiti', - 'Pacific/Tarawa', - 'Pacific/Tongatapu', - - // IANA TZDB Link names - 'WET', - 'Africa/Accra', - 'Africa/Addis_Ababa', - 'Africa/Asmara', - 'Africa/Asmera', - 'Africa/Bamako', - 'Africa/Bangui', - 'Africa/Banjul', - 'Africa/Blantyre', - 'Africa/Brazzaville', - 'Africa/Bujumbura', - 'Africa/Conakry', - 'Africa/Dakar', - 'Africa/Dar_es_Salaam', - 'Africa/Djibouti', - 'Africa/Douala', - 'Africa/Freetown', - 'Africa/Gaborone', - 'Africa/Harare', - 'Africa/Kampala', - 'Africa/Kigali', - 'Africa/Kinshasa', - 'Africa/Libreville', - 'Africa/Lome', - 'Africa/Luanda', - 'Africa/Lubumbashi', - 'Africa/Lusaka', - 'Africa/Malabo', - 'Africa/Maseru', - 'Africa/Mbabane', - 'Africa/Mogadishu', - 'Africa/Niamey', - 'Africa/Nouakchott', - 'Africa/Ouagadougou', - 'Africa/Porto-Novo', - 'Africa/Timbuktu', - 'America/Anguilla', - 'America/Antigua', - 'America/Argentina/ComodRivadavia', - 'America/Aruba', - 'America/Atikokan', - 'America/Atka', - 'America/Blanc-Sablon', - 'America/Buenos_Aires', - 'America/Catamarca', - 'America/Cayman', - 'America/Coral_Harbour', - 'America/Cordoba', - 'America/Creston', - 'America/Curacao', - 'America/Dominica', - 'America/Ensenada', - 'America/Fort_Wayne', - 'America/Godthab', - 'America/Grenada', - 'America/Guadeloupe', - 'America/Indianapolis', - 'America/Jujuy', - 'America/Knox_IN', - 'America/Kralendijk', - 'America/Louisville', - 'America/Lower_Princes', - 'America/Marigot', - 'America/Mendoza', - 'America/Montreal', - 'America/Montserrat', - 'America/Nassau', - 'America/Nipigon', - 'America/Pangnirtung', - 'America/Port_of_Spain', - 'America/Porto_Acre', - 'America/Rainy_River', - 'America/Rosario', - 'America/Santa_Isabel', - 'America/Shiprock', - 'America/St_Barthelemy', - 'America/St_Kitts', - 'America/St_Lucia', - 'America/St_Thomas', - 'America/St_Vincent', - 'America/Thunder_Bay', - 'America/Tortola', - 'America/Virgin', - 'Antarctica/DumontDUrville', - 'Antarctica/McMurdo', - 'Antarctica/South_Pole', - 'Antarctica/Syowa', - 'Antarctica/Vostok', - 'Arctic/Longyearbyen', - 'Asia/Aden', - 'Asia/Ashkhabad', - 'Asia/Bahrain', - 'Asia/Brunei', - 'Asia/Calcutta', - 'Asia/Chongqing', - 'Asia/Chungking', - 'Asia/Dacca', - 'Asia/Harbin', - 'Asia/Istanbul', - 'Asia/Kashgar', - 'Asia/Katmandu', - 'Asia/Kuala_Lumpur', - 'Asia/Kuwait', - 'Asia/Macao', - 'Asia/Muscat', - 'Asia/Phnom_Penh', - 'Asia/Rangoon', - 'Asia/Saigon', - 'Asia/Tel_Aviv', - 'Asia/Thimbu', - 'Asia/Ujung_Pandang', - 'Asia/Ulan_Bator', - 'Asia/Vientiane', - 'Atlantic/Faeroe', - 'Atlantic/Jan_Mayen', - 'Atlantic/Reykjavik', - 'Atlantic/St_Helena', - 'Australia/ACT', - 'Australia/Canberra', - 'Australia/Currie', - 'Australia/LHI', - 'Australia/NSW', - 'Australia/North', - 'Australia/Queensland', - 'Australia/South', - 'Australia/Tasmania', - 'Australia/Victoria', - 'Australia/West', - 'Australia/Yancowinna', - 'Brazil/Acre', - 'Brazil/DeNoronha', - 'Brazil/East', - 'Brazil/West', - 'Canada/Atlantic', - 'Canada/Central', - 'Canada/Eastern', - 'Canada/Mountain', - 'Canada/Newfoundland', - 'Canada/Pacific', - 'Canada/Saskatchewan', - 'Canada/Yukon', - 'Chile/Continental', - 'Chile/EasterIsland', - 'Cuba', - 'Egypt', - 'Eire', - 'Etc/GMT+0', - 'Etc/GMT-0', - 'Etc/GMT0', - 'Etc/Greenwich', - 'Etc/UCT', - 'Etc/Universal', - 'Etc/Zulu', - 'Europe/Amsterdam', - 'Europe/Belfast', - 'Europe/Bratislava', - 'Europe/Busingen', - 'Europe/Copenhagen', - 'Europe/Guernsey', - 'Europe/Isle_of_Man', - 'Europe/Jersey', - 'Europe/Kiev', - 'Europe/Ljubljana', - 'Europe/Luxembourg', - 'Europe/Mariehamn', - 'Europe/Monaco', - 'Europe/Nicosia', - 'Europe/Oslo', - 'Europe/Podgorica', - 'Europe/San_Marino', - 'Europe/Sarajevo', - 'Europe/Skopje', - 'Europe/Stockholm', - 'Europe/Tiraspol', - 'Europe/Uzhgorod', - 'Europe/Vaduz', - 'Europe/Vatican', - 'Europe/Zagreb', - 'Europe/Zaporozhye', - 'GB', - 'GB-Eire', - 'GMT', - 'GMT+0', - 'GMT-0', - 'GMT0', - 'Greenwich', - 'Hongkong', - 'Iceland', - 'Indian/Antananarivo', - 'Indian/Christmas', - 'Indian/Cocos', - 'Indian/Comoro', - 'Indian/Kerguelen', - 'Indian/Mahe', - 'Indian/Mayotte', - 'Indian/Reunion', - 'Iran', - 'Israel', - 'Jamaica', - 'Japan', - 'Kwajalein', - 'Libya', - 'Mexico/BajaNorte', - 'Mexico/BajaSur', - 'Mexico/General', - 'NZ', - 'NZ-CHAT', - 'Navajo', - 'PRC', - 'Pacific/Chuuk', - 'Pacific/Enderbury', - 'Pacific/Funafuti', - 'Pacific/Johnston', - 'Pacific/Majuro', - 'Pacific/Midway', - 'Pacific/Pohnpei', - 'Pacific/Ponape', - 'Pacific/Saipan', - 'Pacific/Samoa', - 'Pacific/Truk', - 'Pacific/Wake', - 'Pacific/Wallis', - 'Pacific/Yap', - 'Poland', - 'Portugal', - 'ROC', - 'ROK', - 'Singapore', - 'Turkey', - 'UCT', - 'US/Alaska', - 'US/Aleutian', - 'US/Arizona', - 'US/Central', - 'US/East-Indiana', - 'US/Eastern', - 'US/Hawaii', - 'US/Indiana-Starke', - 'US/Michigan', - 'US/Mountain', - 'US/Pacific', - 'US/Pacific-New', - 'US/Samoa', - 'UTC', - 'Universal', - 'W-SU', - 'Zulu' -]; - -// We want to test all available named time zone identifiers (both primary and non-primary), -// but no ECMAScript built-in API exposes that list. So we use a union of two sources: -// 1. A hard-coded list of Zone and Link identifiers from the 2022g version of IANA TZDB. -// 2. Canonical IDs exposed by Intl.supportedValuesOf('timeZone'), which ensures that IDs -// added to TZDB later than 2022g will be tested. (New IDs are almost always added as primary.) -const ids = [...new Set([...timeZoneIdentifiers, ...Intl.supportedValuesOf('timeZone')])]; -for (const id of ids) { - const lower = id.toLowerCase(); - const upper = id.toUpperCase(); - assert.sameValue(new Temporal.TimeZone(id).toString(), id, `Time zone created from string "${id}"`); - assert.sameValue(new Temporal.TimeZone(upper).toString(), id, `Time zone created from string "${upper}"`); - assert.sameValue(new Temporal.TimeZone(lower).toString(), id, `Time zone created from string "${lower}"`); -} diff --git a/test/intl402/Temporal/TimeZone/from/timezone-string-datetime.js b/test/intl402/Temporal/TimeZone/from/timezone-string-datetime.js deleted file mode 100644 index 64ba3e649ca..00000000000 --- a/test/intl402/Temporal/TimeZone/from/timezone-string-datetime.js +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) -features: [Temporal] ----*/ - -let timeZone = "2021-08-19T17:30[America/Vancouver]"; -const result1 = Temporal.TimeZone.from(timeZone); -assert.sameValue(result1.id, "America/Vancouver", "date-time + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30Z[America/Vancouver]"; -const result2 = Temporal.TimeZone.from(timeZone); -assert.sameValue(result2.id, "America/Vancouver", "date-time + Z + IANA annotation is the IANA time zone"); - -timeZone = "2021-08-19T17:30-07:00[America/Vancouver]"; -const result3 = Temporal.TimeZone.from(timeZone); -assert.sameValue(result3.id, "America/Vancouver", "date-time + offset + IANA annotation is the IANA time zone"); diff --git a/test/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js b/test/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js deleted file mode 100644 index 88008dc53db..00000000000 --- a/test/intl402/Temporal/TimeZone/from/timezone-string-legacy-non-iana.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2024 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Only IANA time zone identifiers are allowed. -features: [Temporal] ----*/ - -// List of non-IANA link names, copied from: -// https://github.com/unicode-org/icu/blob/main/icu4c/source/tools/tzcode/icuzones -const invalidTimeZones = [ - "ACT", - "AET", - "AGT", - "ART", - "AST", - "BET", - "BST", - "CAT", - "CNT", - "CST", - "CTT", - "EAT", - "ECT", - "IET", - "IST", - "JST", - "MIT", - "NET", - "NST", - "PLT", - "PNT", - "PRT", - "PST", - "SST", - "VST", -]; - -for (let timeZone of invalidTimeZones) { - assert.throws(RangeError, () => { - Temporal.TimeZone.from(timeZone); - }, "Time zone: " + timeZone); -} diff --git a/test/intl402/Temporal/TimeZone/iana-legacy-names.js b/test/intl402/Temporal/TimeZone/iana-legacy-names.js deleted file mode 100644 index 4f6974fa627..00000000000 --- a/test/intl402/Temporal/TimeZone/iana-legacy-names.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: IANA legacy names must be supported -features: [Temporal] ----*/ - -const legacyNames = [ - "Etc/GMT0", - "GMT0", - "GMT-0", - "GMT+0", - "EST5EDT", - "CST6CDT", - "MST7MDT", - "PST8PDT" -]; - -legacyNames.forEach((arg) => { - const tz = new Temporal.TimeZone(arg); - assert.sameValue(tz.toString(), arg, `"${arg}" does not match "${tz.toString()}" time zone identifier`); -}); diff --git a/test/intl402/Temporal/TimeZone/links-australasia.js b/test/intl402/Temporal/TimeZone/links-australasia.js deleted file mode 100644 index 8aeaf33efb2..00000000000 --- a/test/intl402/Temporal/TimeZone/links-australasia.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor accepts link names as its input. -features: [Temporal] ----*/ - -const testCases = [ - "Pacific/Saipan", // Link Pacific/Guam Pacific/Saipan # N Mariana Is - "Antarctica/McMurdo", // Link Pacific/Auckland Antarctica/McMurdo - "Antarctica/DumontDUrville", // Link Pacific/Port_Moresby Antarctica/DumontDUrville - "Pacific/Midway", // Link Pacific/Pago_Pago Pacific/Midway # in US minor outlying islands -]; - -for (let id of testCases) { - const tz = new Temporal.TimeZone(id); - assert.sameValue(tz.id, id); -} diff --git a/test/intl402/Temporal/TimeZone/non-canonical-utc.js b/test/intl402/Temporal/TimeZone/non-canonical-utc.js deleted file mode 100644 index f7cde4e07df..00000000000 --- a/test/intl402/Temporal/TimeZone/non-canonical-utc.js +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor canonicalises its input. -features: [Temporal] ----*/ - -const testCases = [ - "Etc/GMT", - "Etc/GMT+0", - "Etc/GMT-0", - "Etc/GMT0", - "Etc/Greenwich", - "Etc/UCT", - "Etc/UTC", - "Etc/Universal", - "Etc/Zulu", -]; - -for (let id of testCases) { - let tz = new Temporal.TimeZone(id); - - assert.sameValue(tz.id, id); -} diff --git a/test/intl402/Temporal/TimeZone/prototype/equals/argument-object.js b/test/intl402/Temporal/TimeZone/prototype/equals/argument-object.js deleted file mode 100644 index f73b55e807e..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/equals/argument-object.js +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Objects with IANA IDs are compared case-insensitively with their canonical IDs -features: [Temporal] ----*/ - -class CustomTimeZone extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} - -const classInstancesIANA = [ - new Temporal.TimeZone("Asia/Calcutta"), - new CustomTimeZone("Asia/Calcutta"), - new Temporal.TimeZone("Asia/Kolkata"), - new CustomTimeZone("Asia/Kolkata"), - new CustomTimeZone("ASIA/calcutta"), - new CustomTimeZone("Asia/KOLKATA") -]; - -const plainObjectsIANA = [ - { id: "Asia/Calcutta", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, - { id: "Asia/Kolkata", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, - { id: "ASIA/calcutta", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null }, - { id: "asia/kolkatA", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null } -]; - -for (const object1 of classInstancesIANA) { - for (const object2 of classInstancesIANA) { - assert.sameValue(object1.equals(object2), true, `Receiver ${object1.id} should not equal argument ${object2.id}`); - } - for (const object2 of plainObjectsIANA) { - assert.sameValue(object1.equals(object2), true, `Receiver ${object2.id} should not equal argument ${object1.id}`); - } -} - -const classInstancesIANADifferentCanonical = [ - new Temporal.TimeZone("Asia/Colombo"), - new CustomTimeZone("Asia/Colombo"), - new Temporal.TimeZone("ASIA/colombo"), - new CustomTimeZone("ASIA/colombo") -]; - -for (const object1 of classInstancesIANADifferentCanonical) { - for (const object2 of classInstancesIANA) { - assert.sameValue(object1.equals(object2), false, `Receiver ${object1.id} should not equal argument ${object2.id}`); - assert.sameValue(object2.equals(object1), false, `Receiver ${object2.id} should not equal argument ${object1.id}`); - } - for (const object2 of plainObjectsIANA) { - assert.sameValue(object1.equals(object2), false, `Receiver ${object1.id} should not equal argument ${object2.id}`); - assert.sameValue( - object1.equals(object2.id), - false, - `Receiver ${object1.id} should not equal argument ${object2.id}` - ); - } -} - -const classInstancesCustomNotIANA = [new CustomTimeZone("Moon/Cheese")]; -for (const object1 of classInstancesCustomNotIANA) { - for (const object2 of classInstancesIANA) { - assert.sameValue(object1.equals(object2), false, `Receiver ${object1.id} should not equal argument ${object2.id}`); - assert.sameValue(object2.equals(object1), false, `Receiver ${object2.id} should not equal argument ${object1.id}`); - } - for (const object2 of plainObjectsIANA) { - assert.sameValue(object1.equals(object2), false, `Receiver ${object1.id} should not equal argument ${object2.id}`); - assert.sameValue( - object1.equals(object2.id), - false, - `Receiver ${object1.id} should not equal argument ${object2.id}` - ); - } -} diff --git a/test/intl402/Temporal/TimeZone/prototype/equals/argument-valid.js b/test/intl402/Temporal/TimeZone/prototype/equals/argument-valid.js deleted file mode 100644 index 734ccf4401a..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/equals/argument-valid.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Built-in time zones are parsed correctly out of valid strings -features: [Temporal] ----*/ - -const valids = [ - ["Africa/CAIRO", "Africa/Cairo"], - ["Asia/Ulan_Bator", "Asia/Ulaanbaatar"], - ["etc/gmt", "Etc/GMT"], - ["1994-11-05T08:15:30-05:00[America/New_York]", "America/New_York"], - ["1994-11-05T08:15:30+05:30[Asia/Calcutta]", "Asia/Calcutta"], - ["1994-11-05T08:15:30+05:30[Asia/Calcutta]", "Asia/Kolkata"], - ["1994-11-05T08:15:30+05:30[Asia/Kolkata]", "Asia/Calcutta"], - ["1994-11-05T08:15:30+05:30[Asia/Kolkata]", "Asia/Kolkata"], -]; - -for (const [valid, canonical = valid] of valids) { - const tzValid = Temporal.TimeZone.from(canonical); - const tzCanonical = Temporal.TimeZone.from(canonical); - assert.sameValue(tzValid.equals(tzCanonical), true); - assert.sameValue(tzCanonical.equals(tzValid), true); -} diff --git a/test/intl402/Temporal/TimeZone/prototype/equals/canonical-iana-names.js b/test/intl402/Temporal/TimeZone/prototype/equals/canonical-iana-names.js deleted file mode 100644 index f686fa21b91..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/equals/canonical-iana-names.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Canonicalizes to evaluate time zone equality -features: [Temporal] ----*/ - -const neverEqual = new Temporal.TimeZone('Asia/Tokyo'); -const zdt = new Temporal.ZonedDateTime(0n, 'America/Los_Angeles'); -const ids = [ - ['America/Atka', 'America/Adak'], - ['America/Knox_IN', 'America/Indiana/Knox'], - ['Asia/Ashkhabad', 'Asia/Ashgabat'], - ['Asia/Dacca', 'Asia/Dhaka'], - ['Asia/Istanbul', 'Europe/Istanbul'], - ['Asia/Macao', 'Asia/Macau'], - ['Asia/Thimbu', 'Asia/Thimphu'], - ['Asia/Ujung_Pandang', 'Asia/Makassar'], - ['Asia/Ulan_Bator', 'Asia/Ulaanbaatar'] -]; - -for (const [identifier, primaryIdentifier] of ids) { - const tz1 = new Temporal.TimeZone(identifier); - const tz2 = new Temporal.TimeZone(primaryIdentifier); - - // compare objects - assert.sameValue(tz1.equals(tz2), true); - assert.sameValue(tz2.equals(tz1), true); - assert.sameValue(tz1.equals(neverEqual), false); - - // compare string IDs - assert.sameValue(tz1.equals(tz2.id), true); - assert.sameValue(tz2.equals(tz1.id), true); - assert.sameValue(tz1.equals(neverEqual.id), false); - - // compare ZonedDateTime instances - assert.sameValue(tz1.equals(zdt.withTimeZone(tz2)), true); - assert.sameValue(tz2.equals(zdt.withTimeZone(tz1)), true); - assert.sameValue(tz1.equals(zdt.withTimeZone(neverEqual)), false); - - // compare IXDTF strings - assert.sameValue(tz1.equals(zdt.withTimeZone(tz2).toString()), true); - assert.sameValue(tz2.equals(zdt.withTimeZone(tz1).toString()), true); - assert.sameValue(tz1.equals(zdt.withTimeZone(neverEqual).toString()), false); -} diff --git a/test/intl402/Temporal/TimeZone/prototype/equals/canonical-not-equal.js b/test/intl402/Temporal/TimeZone/prototype/equals/canonical-not-equal.js deleted file mode 100644 index 024499167ea..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/equals/canonical-not-equal.js +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Canonical time zone identifiers are never equal to each other -features: [Temporal] ----*/ - -// supportedValuesOf only returns canonical IDs -const ids = Intl.supportedValuesOf("timeZone"); - -const forEachDistinctPair = (array, func) => { - for (let i = 0; i < array.length; i++) { - for (let j = i + 1; j < array.length; j++) { - func(array[i], array[j]); - } - } -}; - -forEachDistinctPair(ids, (id1, id2) => { - const tz = new Temporal.TimeZone(id1); - assert.sameValue(tz.equals(id2), false); -}) - diff --git a/test/intl402/Temporal/TimeZone/prototype/equals/offset-and-iana.js b/test/intl402/Temporal/TimeZone/prototype/equals/offset-and-iana.js deleted file mode 100644 index 85cc2be5993..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/equals/offset-and-iana.js +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Offset string time zones compare as expected -features: [Temporal] ----*/ - -const zdt = new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); -const otz1 = new Temporal.TimeZone("+05:30"); -const otz2 = new Temporal.TimeZone("+0530"); -const tz = new Temporal.TimeZone("Asia/Kolkata"); -assert.sameValue(otz1.equals(otz2), true); -assert.sameValue(otz2.equals(otz1), true); -assert.sameValue(otz1.equals("+05:30"), true); -assert.sameValue(otz1.equals(zdt.withTimeZone(otz2)), true); -assert.sameValue(otz1.equals(zdt.withTimeZone(otz2).toString()), true); -assert.sameValue(otz1.equals(tz), false); -assert.sameValue(otz1.equals("Asia/Kolkata"), false); -assert.sameValue(otz1.equals(zdt.withTimeZone(tz)), false); -assert.sameValue(otz1.equals(zdt.withTimeZone(tz).toString()), false); diff --git a/test/intl402/Temporal/TimeZone/prototype/equals/timezone-case-insensitive.js b/test/intl402/Temporal/TimeZone/prototype/equals/timezone-case-insensitive.js deleted file mode 100644 index c9b6a19c4e8..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/equals/timezone-case-insensitive.js +++ /dev/null @@ -1,624 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.from -description: Time zone names are compared case-insensitively -features: [Temporal] ----*/ - -const timeZoneIdentifiers = [ - // IANA TZDB Zone names - 'Africa/Abidjan', - 'Africa/Algiers', - 'Africa/Bissau', - 'Africa/Cairo', - 'Africa/Casablanca', - 'Africa/Ceuta', - 'Africa/El_Aaiun', - 'Africa/Johannesburg', - 'Africa/Juba', - 'Africa/Khartoum', - 'Africa/Lagos', - 'Africa/Maputo', - 'Africa/Monrovia', - 'Africa/Nairobi', - 'Africa/Ndjamena', - 'Africa/Sao_Tome', - 'Africa/Tripoli', - 'Africa/Tunis', - 'Africa/Windhoek', - 'America/Adak', - 'America/Anchorage', - 'America/Araguaina', - 'America/Argentina/Buenos_Aires', - 'America/Argentina/Catamarca', - 'America/Argentina/Cordoba', - 'America/Argentina/Jujuy', - 'America/Argentina/La_Rioja', - 'America/Argentina/Mendoza', - 'America/Argentina/Rio_Gallegos', - 'America/Argentina/Salta', - 'America/Argentina/San_Juan', - 'America/Argentina/San_Luis', - 'America/Argentina/Tucuman', - 'America/Argentina/Ushuaia', - 'America/Asuncion', - 'America/Bahia', - 'America/Bahia_Banderas', - 'America/Barbados', - 'America/Belem', - 'America/Belize', - 'America/Boa_Vista', - 'America/Bogota', - 'America/Boise', - 'America/Cambridge_Bay', - 'America/Campo_Grande', - 'America/Cancun', - 'America/Caracas', - 'America/Cayenne', - 'America/Chicago', - 'America/Chihuahua', - // 'America/Ciudad_Juarez' // uncomment after Node supports this ID added in TZDB 2022g - 'America/Costa_Rica', - 'America/Cuiaba', - 'America/Danmarkshavn', - 'America/Dawson', - 'America/Dawson_Creek', - 'America/Denver', - 'America/Detroit', - 'America/Edmonton', - 'America/Eirunepe', - 'America/El_Salvador', - 'America/Fort_Nelson', - 'America/Fortaleza', - 'America/Glace_Bay', - 'America/Goose_Bay', - 'America/Grand_Turk', - 'America/Guatemala', - 'America/Guayaquil', - 'America/Guyana', - 'America/Halifax', - 'America/Havana', - 'America/Hermosillo', - 'America/Indiana/Indianapolis', - 'America/Indiana/Knox', - 'America/Indiana/Marengo', - 'America/Indiana/Petersburg', - 'America/Indiana/Tell_City', - 'America/Indiana/Vevay', - 'America/Indiana/Vincennes', - 'America/Indiana/Winamac', - 'America/Inuvik', - 'America/Iqaluit', - 'America/Jamaica', - 'America/Juneau', - 'America/Kentucky/Louisville', - 'America/Kentucky/Monticello', - 'America/La_Paz', - 'America/Lima', - 'America/Los_Angeles', - 'America/Maceio', - 'America/Managua', - 'America/Manaus', - 'America/Martinique', - 'America/Matamoros', - 'America/Mazatlan', - 'America/Menominee', - 'America/Merida', - 'America/Metlakatla', - 'America/Mexico_City', - 'America/Miquelon', - 'America/Moncton', - 'America/Monterrey', - 'America/Montevideo', - 'America/New_York', - 'America/Nome', - 'America/Noronha', - 'America/North_Dakota/Beulah', - 'America/North_Dakota/Center', - 'America/North_Dakota/New_Salem', - 'America/Nuuk', - 'America/Ojinaga', - 'America/Panama', - 'America/Paramaribo', - 'America/Phoenix', - 'America/Port-au-Prince', - 'America/Porto_Velho', - 'America/Puerto_Rico', - 'America/Punta_Arenas', - 'America/Rankin_Inlet', - 'America/Recife', - 'America/Regina', - 'America/Resolute', - 'America/Rio_Branco', - 'America/Santarem', - 'America/Santiago', - 'America/Santo_Domingo', - 'America/Sao_Paulo', - 'America/Scoresbysund', - 'America/Sitka', - 'America/St_Johns', - 'America/Swift_Current', - 'America/Tegucigalpa', - 'America/Thule', - 'America/Tijuana', - 'America/Toronto', - 'America/Vancouver', - 'America/Whitehorse', - 'America/Winnipeg', - 'America/Yakutat', - 'America/Yellowknife', - 'Antarctica/Casey', - 'Antarctica/Davis', - 'Antarctica/Macquarie', - 'Antarctica/Mawson', - 'Antarctica/Palmer', - 'Antarctica/Rothera', - 'Antarctica/Troll', - 'Asia/Almaty', - 'Asia/Amman', - 'Asia/Anadyr', - 'Asia/Aqtau', - 'Asia/Aqtobe', - 'Asia/Ashgabat', - 'Asia/Atyrau', - 'Asia/Baghdad', - 'Asia/Baku', - 'Asia/Bangkok', - 'Asia/Barnaul', - 'Asia/Beirut', - 'Asia/Bishkek', - 'Asia/Chita', - 'Asia/Choibalsan', - 'Asia/Colombo', - 'Asia/Damascus', - 'Asia/Dhaka', - 'Asia/Dili', - 'Asia/Dubai', - 'Asia/Dushanbe', - 'Asia/Famagusta', - 'Asia/Gaza', - 'Asia/Hebron', - 'Asia/Ho_Chi_Minh', - 'Asia/Hong_Kong', - 'Asia/Hovd', - 'Asia/Irkutsk', - 'Asia/Jakarta', - 'Asia/Jayapura', - 'Asia/Jerusalem', - 'Asia/Kabul', - 'Asia/Kamchatka', - 'Asia/Karachi', - 'Asia/Kathmandu', - 'Asia/Khandyga', - 'Asia/Kolkata', - 'Asia/Krasnoyarsk', - 'Asia/Kuching', - 'Asia/Macau', - 'Asia/Magadan', - 'Asia/Makassar', - 'Asia/Manila', - 'Asia/Nicosia', - 'Asia/Novokuznetsk', - 'Asia/Novosibirsk', - 'Asia/Omsk', - 'Asia/Oral', - 'Asia/Pontianak', - 'Asia/Pyongyang', - 'Asia/Qatar', - 'Asia/Qostanay', - 'Asia/Qyzylorda', - 'Asia/Riyadh', - 'Asia/Sakhalin', - 'Asia/Samarkand', - 'Asia/Seoul', - 'Asia/Shanghai', - 'Asia/Singapore', - 'Asia/Srednekolymsk', - 'Asia/Taipei', - 'Asia/Tashkent', - 'Asia/Tbilisi', - 'Asia/Tehran', - 'Asia/Thimphu', - 'Asia/Tokyo', - 'Asia/Tomsk', - 'Asia/Ulaanbaatar', - 'Asia/Urumqi', - 'Asia/Ust-Nera', - 'Asia/Vladivostok', - 'Asia/Yakutsk', - 'Asia/Yangon', - 'Asia/Yekaterinburg', - 'Asia/Yerevan', - 'Atlantic/Azores', - 'Atlantic/Bermuda', - 'Atlantic/Canary', - 'Atlantic/Cape_Verde', - 'Atlantic/Faroe', - 'Atlantic/Madeira', - 'Atlantic/South_Georgia', - 'Atlantic/Stanley', - 'Australia/Adelaide', - 'Australia/Brisbane', - 'Australia/Broken_Hill', - 'Australia/Darwin', - 'Australia/Eucla', - 'Australia/Hobart', - 'Australia/Lindeman', - 'Australia/Lord_Howe', - 'Australia/Melbourne', - 'Australia/Perth', - 'Australia/Sydney', - 'CET', - 'CST6CDT', - 'EET', - 'EST', - 'EST5EDT', - 'Etc/GMT', - 'Etc/GMT+1', - 'Etc/GMT+10', - 'Etc/GMT+11', - 'Etc/GMT+12', - 'Etc/GMT+2', - 'Etc/GMT+3', - 'Etc/GMT+4', - 'Etc/GMT+5', - 'Etc/GMT+6', - 'Etc/GMT+7', - 'Etc/GMT+8', - 'Etc/GMT+9', - 'Etc/GMT-1', - 'Etc/GMT-10', - 'Etc/GMT-11', - 'Etc/GMT-12', - 'Etc/GMT-13', - 'Etc/GMT-14', - 'Etc/GMT-2', - 'Etc/GMT-3', - 'Etc/GMT-4', - 'Etc/GMT-5', - 'Etc/GMT-6', - 'Etc/GMT-7', - 'Etc/GMT-8', - 'Etc/GMT-9', - 'Etc/UTC', - 'Europe/Andorra', - 'Europe/Astrakhan', - 'Europe/Athens', - 'Europe/Belgrade', - 'Europe/Berlin', - 'Europe/Brussels', - 'Europe/Bucharest', - 'Europe/Budapest', - 'Europe/Chisinau', - 'Europe/Dublin', - 'Europe/Gibraltar', - 'Europe/Helsinki', - 'Europe/Istanbul', - 'Europe/Kaliningrad', - 'Europe/Kirov', - 'Europe/Kyiv', - 'Europe/Lisbon', - 'Europe/London', - 'Europe/Madrid', - 'Europe/Malta', - 'Europe/Minsk', - 'Europe/Moscow', - 'Europe/Paris', - 'Europe/Prague', - 'Europe/Riga', - 'Europe/Rome', - 'Europe/Samara', - 'Europe/Saratov', - 'Europe/Simferopol', - 'Europe/Sofia', - 'Europe/Tallinn', - 'Europe/Tirane', - 'Europe/Ulyanovsk', - 'Europe/Vienna', - 'Europe/Vilnius', - 'Europe/Volgograd', - 'Europe/Warsaw', - 'Europe/Zurich', - 'HST', - 'Indian/Chagos', - 'Indian/Maldives', - 'Indian/Mauritius', - 'MET', - 'MST', - 'MST7MDT', - 'PST8PDT', - 'Pacific/Apia', - 'Pacific/Auckland', - 'Pacific/Bougainville', - 'Pacific/Chatham', - 'Pacific/Easter', - 'Pacific/Efate', - 'Pacific/Fakaofo', - 'Pacific/Fiji', - 'Pacific/Galapagos', - 'Pacific/Gambier', - 'Pacific/Guadalcanal', - 'Pacific/Guam', - 'Pacific/Honolulu', - 'Pacific/Kanton', - 'Pacific/Kiritimati', - 'Pacific/Kosrae', - 'Pacific/Kwajalein', - 'Pacific/Marquesas', - 'Pacific/Nauru', - 'Pacific/Niue', - 'Pacific/Norfolk', - 'Pacific/Noumea', - 'Pacific/Pago_Pago', - 'Pacific/Palau', - 'Pacific/Pitcairn', - 'Pacific/Port_Moresby', - 'Pacific/Rarotonga', - 'Pacific/Tahiti', - 'Pacific/Tarawa', - 'Pacific/Tongatapu', - - // IANA TZDB Link names - 'WET', - 'Africa/Accra', - 'Africa/Addis_Ababa', - 'Africa/Asmara', - 'Africa/Asmera', - 'Africa/Bamako', - 'Africa/Bangui', - 'Africa/Banjul', - 'Africa/Blantyre', - 'Africa/Brazzaville', - 'Africa/Bujumbura', - 'Africa/Conakry', - 'Africa/Dakar', - 'Africa/Dar_es_Salaam', - 'Africa/Djibouti', - 'Africa/Douala', - 'Africa/Freetown', - 'Africa/Gaborone', - 'Africa/Harare', - 'Africa/Kampala', - 'Africa/Kigali', - 'Africa/Kinshasa', - 'Africa/Libreville', - 'Africa/Lome', - 'Africa/Luanda', - 'Africa/Lubumbashi', - 'Africa/Lusaka', - 'Africa/Malabo', - 'Africa/Maseru', - 'Africa/Mbabane', - 'Africa/Mogadishu', - 'Africa/Niamey', - 'Africa/Nouakchott', - 'Africa/Ouagadougou', - 'Africa/Porto-Novo', - 'Africa/Timbuktu', - 'America/Anguilla', - 'America/Antigua', - 'America/Argentina/ComodRivadavia', - 'America/Aruba', - 'America/Atikokan', - 'America/Atka', - 'America/Blanc-Sablon', - 'America/Buenos_Aires', - 'America/Catamarca', - 'America/Cayman', - 'America/Coral_Harbour', - 'America/Cordoba', - 'America/Creston', - 'America/Curacao', - 'America/Dominica', - 'America/Ensenada', - 'America/Fort_Wayne', - 'America/Godthab', - 'America/Grenada', - 'America/Guadeloupe', - 'America/Indianapolis', - 'America/Jujuy', - 'America/Knox_IN', - 'America/Kralendijk', - 'America/Louisville', - 'America/Lower_Princes', - 'America/Marigot', - 'America/Mendoza', - 'America/Montreal', - 'America/Montserrat', - 'America/Nassau', - 'America/Nipigon', - 'America/Pangnirtung', - 'America/Port_of_Spain', - 'America/Porto_Acre', - 'America/Rainy_River', - 'America/Rosario', - 'America/Santa_Isabel', - 'America/Shiprock', - 'America/St_Barthelemy', - 'America/St_Kitts', - 'America/St_Lucia', - 'America/St_Thomas', - 'America/St_Vincent', - 'America/Thunder_Bay', - 'America/Tortola', - 'America/Virgin', - 'Antarctica/DumontDUrville', - 'Antarctica/McMurdo', - 'Antarctica/South_Pole', - 'Antarctica/Syowa', - 'Antarctica/Vostok', - 'Arctic/Longyearbyen', - 'Asia/Aden', - 'Asia/Ashkhabad', - 'Asia/Bahrain', - 'Asia/Brunei', - 'Asia/Calcutta', - 'Asia/Chongqing', - 'Asia/Chungking', - 'Asia/Dacca', - 'Asia/Harbin', - 'Asia/Istanbul', - 'Asia/Kashgar', - 'Asia/Katmandu', - 'Asia/Kuala_Lumpur', - 'Asia/Kuwait', - 'Asia/Macao', - 'Asia/Muscat', - 'Asia/Phnom_Penh', - 'Asia/Rangoon', - 'Asia/Saigon', - 'Asia/Tel_Aviv', - 'Asia/Thimbu', - 'Asia/Ujung_Pandang', - 'Asia/Ulan_Bator', - 'Asia/Vientiane', - 'Atlantic/Faeroe', - 'Atlantic/Jan_Mayen', - 'Atlantic/Reykjavik', - 'Atlantic/St_Helena', - 'Australia/ACT', - 'Australia/Canberra', - 'Australia/Currie', - 'Australia/LHI', - 'Australia/NSW', - 'Australia/North', - 'Australia/Queensland', - 'Australia/South', - 'Australia/Tasmania', - 'Australia/Victoria', - 'Australia/West', - 'Australia/Yancowinna', - 'Brazil/Acre', - 'Brazil/DeNoronha', - 'Brazil/East', - 'Brazil/West', - 'Canada/Atlantic', - 'Canada/Central', - 'Canada/Eastern', - 'Canada/Mountain', - 'Canada/Newfoundland', - 'Canada/Pacific', - 'Canada/Saskatchewan', - 'Canada/Yukon', - 'Chile/Continental', - 'Chile/EasterIsland', - 'Cuba', - 'Egypt', - 'Eire', - 'Etc/GMT+0', - 'Etc/GMT-0', - 'Etc/GMT0', - 'Etc/Greenwich', - 'Etc/UCT', - 'Etc/Universal', - 'Etc/Zulu', - 'Europe/Amsterdam', - 'Europe/Belfast', - 'Europe/Bratislava', - 'Europe/Busingen', - 'Europe/Copenhagen', - 'Europe/Guernsey', - 'Europe/Isle_of_Man', - 'Europe/Jersey', - 'Europe/Kiev', - 'Europe/Ljubljana', - 'Europe/Luxembourg', - 'Europe/Mariehamn', - 'Europe/Monaco', - 'Europe/Nicosia', - 'Europe/Oslo', - 'Europe/Podgorica', - 'Europe/San_Marino', - 'Europe/Sarajevo', - 'Europe/Skopje', - 'Europe/Stockholm', - 'Europe/Tiraspol', - 'Europe/Uzhgorod', - 'Europe/Vaduz', - 'Europe/Vatican', - 'Europe/Zagreb', - 'Europe/Zaporozhye', - 'GB', - 'GB-Eire', - 'GMT', - 'GMT+0', - 'GMT-0', - 'GMT0', - 'Greenwich', - 'Hongkong', - 'Iceland', - 'Indian/Antananarivo', - 'Indian/Christmas', - 'Indian/Cocos', - 'Indian/Comoro', - 'Indian/Kerguelen', - 'Indian/Mahe', - 'Indian/Mayotte', - 'Indian/Reunion', - 'Iran', - 'Israel', - 'Jamaica', - 'Japan', - 'Kwajalein', - 'Libya', - 'Mexico/BajaNorte', - 'Mexico/BajaSur', - 'Mexico/General', - 'NZ', - 'NZ-CHAT', - 'Navajo', - 'PRC', - 'Pacific/Chuuk', - 'Pacific/Enderbury', - 'Pacific/Funafuti', - 'Pacific/Johnston', - 'Pacific/Majuro', - 'Pacific/Midway', - 'Pacific/Pohnpei', - 'Pacific/Ponape', - 'Pacific/Saipan', - 'Pacific/Samoa', - 'Pacific/Truk', - 'Pacific/Wake', - 'Pacific/Wallis', - 'Pacific/Yap', - 'Poland', - 'Portugal', - 'ROC', - 'ROK', - 'Singapore', - 'Turkey', - 'UCT', - 'US/Alaska', - 'US/Aleutian', - 'US/Arizona', - 'US/Central', - 'US/East-Indiana', - 'US/Eastern', - 'US/Hawaii', - 'US/Indiana-Starke', - 'US/Michigan', - 'US/Mountain', - 'US/Pacific', - 'US/Samoa', - 'UTC', - 'Universal', - 'W-SU', - 'Zulu' -]; - -// We want to test all available named time zone identifiers (both primary and non-primary), -// but no ECMAScript built-in API exposes that list. So we use a union of two sources: -// 1. A hard-coded list of Zone and Link identifiers from the 2022g version of IANA TZDB. -// 2. Canonical IDs exposed by Intl.supportedValuesOf('timeZone'), which ensures that IDs -// added to TZDB later than 2022g will be tested. (New IDs are almost always added as primary.) -const ids = [...new Set([...timeZoneIdentifiers, ...Intl.supportedValuesOf('timeZone')])]; -for (const id of ids) { - const lower = id.toLowerCase(); - const upper = id.toUpperCase(); - const tz = new Temporal.TimeZone(id); - assert.sameValue(tz.equals(upper), true, `Time zone "${id}" compared to string "${upper}"`); - assert.sameValue(tz.equals(lower), true, `Time zone "${id}" compared to string "${lower}"`); -} diff --git a/test/intl402/Temporal/TimeZone/prototype/getInstantFor/infinity-throws-rangeerror.js b/test/intl402/Temporal/TimeZone/prototype/getInstantFor/infinity-throws-rangeerror.js deleted file mode 100644 index d525a22fb0a..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getInstantFor/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.timezone.prototype.getinstantfor -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); -const base = { era: "ad", month: 5, day: 2, hour: 15, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.getInstantFor({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.getInstantFor({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition.js b/test/intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition.js deleted file mode 100644 index 1ace980f8bc..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getNextTransition/subtract-second-and-nanosecond-from-last-transition.js +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: > - Compute next transition when seconds resp. nanoseconds are subtracted from the last transition. -features: [Temporal] ----*/ - -// From : -// -// # Zone NAME STDOFF RULES FORMAT [UNTIL] -// Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01 -// 0:09:21 - PMT 1911 Mar 11 0:01 # Paris MT - -let tz = new Temporal.TimeZone("Europe/Paris"); - -let zdt = new Temporal.PlainDateTime(1800, 1, 1).toZonedDateTime(tz); -assert.sameValue(zdt.toString(), "1800-01-01T00:00:00+00:09[Europe/Paris]"); -assert.sameValue(zdt.offsetNanoseconds, (9 * 60 + 21) * 1_000_000_000); - -// Ensure the first transition was correctly computed. -let first = tz.getNextTransition(zdt); -assert.sameValue(first.toString(), "1911-03-10T23:50:39Z"); -assert.sameValue(new Temporal.ZonedDateTime(first.epochNanoseconds, tz).toString(), - "1911-03-10T23:50:39+00:00[Europe/Paris]"); - -let next; - -// Compute the next transition starting from the first transition minus 1s. -let firstMinus1s = first.add({seconds: -1}); -assert.sameValue(firstMinus1s.toString(), "1911-03-10T23:50:38Z"); -assert.sameValue(new Temporal.ZonedDateTime(firstMinus1s.epochNanoseconds, tz).toString(), - "1911-03-10T23:59:59+00:09[Europe/Paris]"); -assert.sameValue(new Temporal.ZonedDateTime(firstMinus1s.epochNanoseconds, tz).offsetNanoseconds, - (9 * 60 + 21) * 1_000_000_000); - -next = tz.getNextTransition(firstMinus1s); -assert.sameValue(next.toString(), "1911-03-10T23:50:39Z"); -assert.sameValue(new Temporal.ZonedDateTime(next.epochNanoseconds, tz).toString(), - "1911-03-10T23:50:39+00:00[Europe/Paris]"); - -// Compute the next transition starting from the first transition minus 1ns. -let firstMinus1ns = first.add({nanoseconds: -1}); -assert.sameValue(firstMinus1ns.toString(), "1911-03-10T23:50:38.999999999Z"); -assert.sameValue(new Temporal.ZonedDateTime(firstMinus1ns.epochNanoseconds, tz).toString(), - "1911-03-10T23:59:59.999999999+00:09[Europe/Paris]"); -assert.sameValue(new Temporal.ZonedDateTime(firstMinus1ns.epochNanoseconds, tz).offsetNanoseconds, - (9 * 60 + 21) * 1_000_000_000); - -next = tz.getNextTransition(firstMinus1ns); -assert.sameValue(next.toString(), "1911-03-10T23:50:39Z"); -assert.sameValue(new Temporal.ZonedDateTime(next.epochNanoseconds, tz).toString(), - "1911-03-10T23:50:39+00:00[Europe/Paris]"); diff --git a/test/intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries.js b/test/intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries.js deleted file mode 100644 index d909b666422..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getNextTransition/transition-at-instant-boundaries.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getnexttransition -description: > - Test transitions at the instant boundaries. -features: [Temporal, Intl-enumeration] ----*/ - -const min = new Temporal.Instant(-86_40000_00000_00000_00000n); -const max = new Temporal.Instant(86_40000_00000_00000_00000n); - -for (let id of Intl.supportedValuesOf("timeZone")) { - let tz = new Temporal.TimeZone(id); - - // If there's any next transition, it should be after |min|. - let next = tz.getNextTransition(min); - if (next) { - assert(next.epochNanoseconds > min.epochNanoseconds); - } - - // There shouldn't be any next transition after |max|. - next = tz.getNextTransition(max); - assert.sameValue(next, null); -} diff --git a/test/intl402/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string.js b/test/intl402/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string.js deleted file mode 100644 index 1635fc858a7..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/instant-string.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: Conversion of ISO date-time strings to Temporal.Instant instances -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("America/Vancouver"); - -let str = "1970-01-01T00:00"; -assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), "bare date-time string is not an instant"); -str = "1970-01-01T00:00[America/Vancouver]"; -assert.throws(RangeError, () => instance.getOffsetNanosecondsFor(str), "date-time + IANA annotation is not an instant"); - -// The following are all valid strings so should not throw: - -const valids = [ - "1970-01-01T00:00Z", - "1970-01-01T00:00+01:00", - "1970-01-01T00:00Z[America/Vancouver]", - "1970-01-01T00:00+01:00[America/Vancouver]", -]; -for (const str of valids) { - const result = instance.getOffsetNanosecondsFor(str); - assert.sameValue(result, -28800e9); -} diff --git a/test/intl402/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/nanoseconds-subtracted-or-added-at-dst-transition.js b/test/intl402/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/nanoseconds-subtracted-or-added-at-dst-transition.js deleted file mode 100644 index 268924e79e2..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getOffsetNanosecondsFor/nanoseconds-subtracted-or-added-at-dst-transition.js +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetnanosecondsfor -description: > - Test offset when nanoseconds are subtracted or added from DST transition. -features: [Temporal, exponentiation] ----*/ - -// From : -// -// # Rule NAME FROM TO - IN ON AT SAVE LETTER -// Rule CA 1950 1966 - Apr lastSun 1:00 1:00 D -// -// # Zone NAME STDOFF RULES FORMAT [UNTIL] -// Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:07:02 -// -8:00 US P%sT 1946 -// -8:00 CA P%sT 1967 -// -8:00 US P%sT - -let tz = new Temporal.TimeZone("America/Los_Angeles"); -let p = Temporal.Instant.from("1965-04-25T09:00:00Z"); - -const nsPerHour = 60 * 60 * 1000**3; - -assert.sameValue(tz.getOffsetNanosecondsFor(p), - -7 * nsPerHour, - "DST transition"); - -assert.sameValue(tz.getOffsetNanosecondsFor(p.add({nanoseconds: +1})), - -7 * nsPerHour, - "DST transition plus one nanosecond"); - -assert.sameValue(tz.getOffsetNanosecondsFor(p.add({nanoseconds: -1})), - -8 * nsPerHour, - "DST transition minus one nanosecond"); diff --git a/test/intl402/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string.js b/test/intl402/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string.js deleted file mode 100644 index 8fa65ff52d2..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getOffsetStringFor/instant-string.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getoffsetstringfor -description: Conversion of ISO date-time strings to Temporal.TimeZone instances -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("America/Vancouver"); - -let str = "1970-01-01T00:00"; -assert.throws(RangeError, () => instance.getOffsetStringFor(str), "bare date-time string is not an instant"); -str = "1970-01-01T00:00[America/Vancouver]"; -assert.throws(RangeError, () => instance.getOffsetStringFor(str), "date-time + IANA annotation is not an instant"); - -// The following are all valid strings so should not throw: - -const valids = [ - "1970-01-01T00:00Z", - "1970-01-01T00:00+01:00", - "1970-01-01T00:00Z[America/Vancouver]", - "1970-01-01T00:00+01:00[America/Vancouver]", -]; -for (const str of valids) { - const result = instance.getOffsetStringFor(str); - assert.sameValue(result, "-08:00"); -} diff --git a/test/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/basic.js b/test/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/basic.js deleted file mode 100644 index aaa7f82ddd6..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/basic.js +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Sample of results for IANA time zones -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -function test(epochNs, results) { - const instant = new Temporal.Instant(epochNs); - Object.entries(results).forEach(([id, expected]) => { - const tz = new Temporal.TimeZone(id); - const dt = tz.getPlainDateTimeFor(instant); - TemporalHelpers.assertPlainDateTime(dt, ...expected, `Local time of ${instant} in ${id}`); - }); -} - -// Unix epoch -test(0n, { - 'America/Los_Angeles': [1969, 12, "M12", 31, 16, 0, 0, 0, 0, 0], - 'America/New_York': [1969, 12, "M12", 31, 19, 0, 0, 0, 0, 0], - 'Africa/Monrovia': [1969, 12, "M12", 31, 23, 15, 30, 0, 0, 0], - 'Europe/London': [1970, 1, "M01", 1, 1, 0, 0, 0, 0, 0], - 'Europe/Berlin': [1970, 1, "M01", 1, 1, 0, 0, 0, 0, 0], - 'Europe/Moscow': [1970, 1, "M01", 1, 3, 0, 0, 0, 0, 0], - 'Asia/Kolkata': [1970, 1, "M01", 1, 5, 30, 0, 0, 0, 0], - 'Asia/Tokyo': [1970, 1, "M01", 1, 9, 0, 0, 0, 0, 0], -}); - -// Just before epoch -test(-1n, { - 'America/Los_Angeles': [1969, 12, "M12", 31, 15, 59, 59, 999, 999, 999], - 'America/New_York': [1969, 12, "M12", 31, 18, 59, 59, 999, 999, 999], - 'Africa/Monrovia': [1969, 12, "M12", 31, 23, 15, 29, 999, 999, 999], - 'Europe/London': [1970, 1, "M01", 1, 0, 59, 59, 999, 999, 999], - 'Europe/Berlin': [1970, 1, "M01", 1, 0, 59, 59, 999, 999, 999], - 'Europe/Moscow': [1970, 1, "M01", 1, 2, 59, 59, 999, 999, 999], - 'Asia/Kolkata': [1970, 1, "M01", 1, 5, 29, 59, 999, 999, 999], - 'Asia/Tokyo': [1970, 1, "M01", 1, 8, 59, 59, 999, 999, 999], -}); - -// Just after epoch -test(1n, { - 'America/Los_Angeles': [1969, 12, "M12", 31, 16, 0, 0, 0, 0, 1], - 'America/New_York': [1969, 12, "M12", 31, 19, 0, 0, 0, 0, 1], - 'Africa/Monrovia': [1969, 12, "M12", 31, 23, 15, 30, 0, 0, 1], - 'Europe/London': [1970, 1, "M01", 1, 1, 0, 0, 0, 0, 1], - 'Europe/Berlin': [1970, 1, "M01", 1, 1, 0, 0, 0, 0, 1], - 'Europe/Moscow': [1970, 1, "M01", 1, 3, 0, 0, 0, 0, 1], - 'Asia/Kolkata': [1970, 1, "M01", 1, 5, 30, 0, 0, 0, 1], - 'Asia/Tokyo': [1970, 1, "M01", 1, 9, 0, 0, 0, 0, 1], -}); - -// Hours before epoch -test(-6300_000_000_001n, { - 'America/Los_Angeles': [1969, 12, "M12", 31, 14, 14, 59, 999, 999, 999], - 'America/New_York': [1969, 12, "M12", 31, 17, 14, 59, 999, 999, 999], - 'Africa/Monrovia': [1969, 12, "M12", 31, 21, 30, 29, 999, 999, 999], - 'Europe/London': [1969, 12, "M12", 31, 23, 14, 59, 999, 999, 999], - 'Europe/Berlin': [1969, 12, "M12", 31, 23, 14, 59, 999, 999, 999], - 'Europe/Moscow': [1970, 1, "M01", 1, 1, 14, 59, 999, 999, 999], - 'Asia/Kolkata': [1970, 1, "M01", 1, 3, 44, 59, 999, 999, 999], - 'Asia/Tokyo': [1970, 1, "M01", 1, 7, 14, 59, 999, 999, 999], -}); - -// Hours after epoch -test(6300_000_000_001n, { - 'America/Los_Angeles': [1969, 12, "M12", 31, 17, 45, 0, 0, 0, 1], - 'America/New_York': [1969, 12, "M12", 31, 20, 45, 0, 0, 0, 1], - 'Africa/Monrovia': [1970, 1, "M01", 1, 1, 0, 30, 0, 0, 1], - 'Europe/London': [1970, 1, "M01", 1, 2, 45, 0, 0, 0, 1], - 'Europe/Berlin': [1970, 1, "M01", 1, 2, 45, 0, 0, 0, 1], - 'Europe/Moscow': [1970, 1, "M01", 1, 4, 45, 0, 0, 0, 1], - 'Asia/Kolkata': [1970, 1, "M01", 1, 7, 15, 0, 0, 0, 1], - 'Asia/Tokyo': [1970, 1, "M01", 1, 10, 45, 0, 0, 0, 1], -}); diff --git a/test/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string.js b/test/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string.js deleted file mode 100644 index 2c2973e72f2..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/instant-string.js +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor -description: Conversion of ISO date-time strings to Temporal.Instant instances -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("America/Vancouver"); - -let str = "1970-01-01T00:00"; -assert.throws(RangeError, () => instance.getPlainDateTimeFor(str), "bare date-time string is not an instant"); -str = "1970-01-01T00:00[America/Vancouver]"; -assert.throws(RangeError, () => instance.getPlainDateTimeFor(str), "date-time + IANA annotation is not an instant"); - -str = "1970-01-01T00:00Z"; -const result1 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result1, 1969, 12, "M12", 31, 16, 0, 0, 0, 0, 0, "date-time + Z preserves exact time"); - -str = "1970-01-01T00:00+01:00"; -const result2 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result2, 1969, 12, "M12", 31, 15, 0, 0, 0, 0, 0, "date-time + offset preserves exact time with offset"); - -str = "1970-01-01T00:00Z[America/Vancouver]"; -const result3 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result3, 1969, 12, "M12", 31, 16, 0, 0, 0, 0, 0, "date-time + Z + IANA annotation ignores the IANA annotation"); - -str = "1970-01-01T00:00+01:00[America/Vancouver]"; -const result4 = instance.getPlainDateTimeFor(str); -TemporalHelpers.assertPlainDateTime(result4, 1969, 12, "M12", 31, 15, 0, 0, 0, 0, 0, "date-time + offset + IANA annotation ignores the IANA annotation"); diff --git a/test/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/infinity-throws-rangeerror.js b/test/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/infinity-throws-rangeerror.js deleted file mode 100644 index d388f95092d..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getPossibleInstantsFor/infinity-throws-rangeerror.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: Throws if eraYear in the property bag is Infinity or -Infinity -esid: sec-temporal.timezone.prototype.getpossibleinstantsfor -includes: [compareArray.js, temporalHelpers.js] -features: [Temporal] ----*/ - -const instance = new Temporal.TimeZone("UTC"); -const base = { era: "ad", month: 5, day: 2, hour: 15, calendar: "gregory" }; - -[Infinity, -Infinity].forEach((inf) => { - assert.throws(RangeError, () => instance.getPossibleInstantsFor({ ...base, eraYear: inf }), `eraYear property cannot be ${inf}`); - - const calls = []; - const obj = TemporalHelpers.toPrimitiveObserver(calls, inf, "eraYear"); - assert.throws(RangeError, () => instance.getPossibleInstantsFor({ ...base, eraYear: obj })); - assert.compareArray(calls, ["get eraYear.valueOf", "call eraYear.valueOf"], "it fails after fetching the primitive value"); -}); diff --git a/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition.js b/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition.js deleted file mode 100644 index fd5a8606246..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/nanoseconds-subtracted-or-added-at-dst-transition.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: > - Test previous transition when nanoseconds are subtracted resp. added to the DST transition. -features: [Temporal] ----*/ - -let tz = new Temporal.TimeZone("Europe/Berlin"); -let p = Temporal.Instant.from("2021-03-28T01:00:00Z"); - -assert.sameValue(tz.getPreviousTransition(p.add({nanoseconds: -1})).toString(), - "2020-10-25T01:00:00Z", - "DST transition minus one nanosecond"); - -assert.sameValue(tz.getPreviousTransition(p).toString(), - "2020-10-25T01:00:00Z", - "DST transition"); - -assert.sameValue(tz.getPreviousTransition(p.add({nanoseconds: +1})).toString(), - "2021-03-28T01:00:00Z", - "DST transition plus one nanosecond"); diff --git a/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js b/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js deleted file mode 100644 index c2f149bb6a2..00000000000 --- a/test/intl402/Temporal/TimeZone/prototype/getPreviousTransition/transition-at-instant-boundaries.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone.prototype.getprevioustransition -description: > - Test transitions at the instant boundaries. -features: [Temporal, Intl-enumeration] ----*/ - -const min = new Temporal.Instant(-86_40000_00000_00000_00000n); -const max = new Temporal.Instant(86_40000_00000_00000_00000n); - -for (let id of Intl.supportedValuesOf("timeZone")) { - let tz = new Temporal.TimeZone(id); - - // If there's any previous transition, it should be before |max|. - let prev = tz.getPreviousTransition(max); - if (prev) { - assert(prev.epochNanoseconds < max.epochNanoseconds); - } - - // There shouldn't be any previous transition before |min|. - prev = tz.getPreviousTransition(min); - assert.sameValue(prev, null); -} diff --git a/test/intl402/Temporal/TimeZone/supported-values-of.js b/test/intl402/Temporal/TimeZone/supported-values-of.js deleted file mode 100644 index bcc87b2f2d0..00000000000 --- a/test/intl402/Temporal/TimeZone/supported-values-of.js +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (C) 2022 André Bargull. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor accepts all time zone identifiers from Intl.supportedValuesOf. -features: [Temporal, Intl-enumeration] ----*/ - -// Ensure all identifiers are valid and canonical. -for (let id of Intl.supportedValuesOf("timeZone")) { - let tz = new Temporal.TimeZone(id); - - assert.sameValue(tz.id, id); -} diff --git a/test/intl402/Temporal/TimeZone/timezone-case-insensitive.js b/test/intl402/Temporal/TimeZone/timezone-case-insensitive.js deleted file mode 100644 index fa90f4dcc67..00000000000 --- a/test/intl402/Temporal/TimeZone/timezone-case-insensitive.js +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (C) 2022 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.timezone -description: Time zone names are case insensitive -features: [Temporal] ----*/ - -const timeZone = 'eTc/gMt+1'; -const result = new Temporal.TimeZone(timeZone); -assert.sameValue(result.toString(), 'Etc/GMT+1', `Time zone created from string "${timeZone}"`); diff --git a/test/intl402/Temporal/ZonedDateTime/compare/disregards-calendar-if-exact-times-equal.js b/test/intl402/Temporal/ZonedDateTime/compare/disregards-calendar-if-exact-times-equal.js new file mode 100644 index 00000000000..f03906a00aa --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/compare/disregards-calendar-if-exact-times-equal.js @@ -0,0 +1,13 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.compare +description: > + Disregards the calendar if the exact times of the arguments are equal +features: [Temporal] +---*/ + +const arg1 = new Temporal.ZonedDateTime(1572342398_271_986_102n, "-07:00", "iso8601"); +const arg2 = new Temporal.ZonedDateTime(1572342398_271_986_102n, "-07:00", "japanese"); +assert.sameValue(Temporal.ZonedDateTime.compare(arg1, arg2), 0); diff --git a/test/intl402/Temporal/ZonedDateTime/compare/exhaustive.js b/test/intl402/Temporal/ZonedDateTime/compare/exhaustive.js new file mode 100644 index 00000000000..7120b92a841 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/compare/exhaustive.js @@ -0,0 +1,29 @@ +// Copyright (C) 2023 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.compare +description: Tests for compare() with each possible outcome +features: [Temporal] +---*/ + +const tz1 = "UTC"; +const tz2 = "-00:30"; +const cal1 = "iso8601"; +const cal2 = "gregory"; + +assert.sameValue( + Temporal.ZonedDateTime.compare(new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, tz1, cal1), new Temporal.ZonedDateTime(500_000_000_000_000_000n, tz2, cal2)), + 1, + ">" +); +assert.sameValue( + Temporal.ZonedDateTime.compare(new Temporal.ZonedDateTime(-1000n, tz1, cal1), new Temporal.ZonedDateTime(1000n, tz2, cal2)), + -1, + "<" +); +assert.sameValue( + Temporal.ZonedDateTime.compare(new Temporal.ZonedDateTime(123_456_789n, tz1, cal1), new Temporal.ZonedDateTime(123_456_789n, tz2, cal2)), + 0, + "=" +); diff --git a/test/intl402/Temporal/ZonedDateTime/construct-non-utc-non-iso.js b/test/intl402/Temporal/ZonedDateTime/construct-non-utc-non-iso.js new file mode 100644 index 00000000000..7420f2cf881 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/construct-non-utc-non-iso.js @@ -0,0 +1,46 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime +description: > + Test construction and properties of an instance with non-UTC time zone and + non-ISO8601 calendar +features: [Temporal, BigInt] +---*/ + +var epochMillis = Date.UTC(1976, 10, 18, 15, 23, 30, 123); +var epochNanos = BigInt(epochMillis) * 1000000n + 456789n; + +const instance = new Temporal.ZonedDateTime(epochNanos, "Europe/Vienna", "gregory"); +assert(instance instanceof Temporal.ZonedDateTime, "instanceof is correct"); +assert.sameValue(typeof instance, "object", "typeof is correct"); + +assert.sameValue(instance.era, "ce", "era"); +assert.sameValue(instance.eraYear, 1976, "eraYear"); +assert.sameValue(instance.year, 1976, "year"); +assert.sameValue(instance.month, 11, "month"); +assert.sameValue(instance.monthCode, "M11", "monthCode"); +assert.sameValue(instance.day, 18, "day"); +assert.sameValue(instance.hour, 16, "hour"); +assert.sameValue(instance.minute, 23, "minute"); +assert.sameValue(instance.second, 30, "second"); +assert.sameValue(instance.millisecond, 123, "millisecond"); +assert.sameValue(instance.microsecond, 456, "microsecond"); +assert.sameValue(instance.nanosecond, 789, "nanosecond"); + +assert.sameValue(instance.epochMilliseconds, 217178610123, "epochMilliseconds"); +assert.sameValue(instance.epochNanoseconds, 217178610123456789n, "epochNanoseconds"); + +assert.sameValue(instance.dayOfWeek, 4, "dayOfWeek"); +assert.sameValue(instance.dayOfYear, 323, "dayOfYear"); +assert.sameValue(instance.weekOfYear, 47, "weekOfYear"); +assert.sameValue(instance.yearOfWeek, 1976, "yearOfWeek"); +assert.sameValue(instance.daysInWeek, 7, "daysInWeek"); +assert.sameValue(instance.daysInMonth, 30, "daysInMonth"); +assert.sameValue(instance.daysInYear, 366, "daysInYear"); +assert.sameValue(instance.monthsInYear, 12, "monthsInYear"); +assert.sameValue(instance.inLeapYear, true, "inLeapYear"); + +assert.sameValue(instance.offset, "+01:00", "offset"); +assert.sameValue(instance.offsetNanoseconds, 3600e9, "offsetNanoseconds"); diff --git a/test/intl402/Temporal/ZonedDateTime/etc-timezone.js b/test/intl402/Temporal/ZonedDateTime/etc-timezone.js new file mode 100644 index 00000000000..955edf6539f --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/etc-timezone.js @@ -0,0 +1,66 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime +description: Some Etc/GMT{+/-}{0}N timezones are valid, but not all +features: [Temporal] +---*/ + +// "Etc/GMT-0" through "Etc/GMT-14" are OK + +[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14].forEach((n) => { + let tz = "Etc/GMT-" + n; + let instance = new Temporal.ZonedDateTime(0n, tz); + assert.sameValue( + instance.timeZoneId, + tz, + tz + " is a valid timezone" + ); +}); + +let gmtMinus24TZ = "Etc/GMT-24"; +assert.throws( + RangeError, + () => { new Temporal.ZonedDateTime(0n, gmtMinus24TZ); }, + gmtMinus24TZ + " is an invalid timezone" +); + +// "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9) +[1,2,3,4,5,6,7,8,9].forEach((n) => { + let tz = "Etc/GMT-0" + n; + assert.throws( + RangeError, + () => { new Temporal.ZonedDateTime(0n, tz); }, + tz + " is an invalid timezone" + ); +}); + +// "Etc/GMT+0N" is not OK (0 ≤ N ≤ 9) +[0,1,2,3,4,5,6,7,8,9].forEach((n) => { + let tz = "Etc/GMT+0" + n; + assert.throws( + RangeError, + () => { new Temporal.ZonedDateTime(0n, tz); }, + tz + " is an invalid timezone" + ); +}); + +// Etc/GMT+0" through "Etc/GMT+12" are OK + +[0,1,2,3,4,5,6,7,8,9,10,11,12].forEach((n) => { + let tz = "Etc/GMT+" + n; + let instance = new Temporal.ZonedDateTime(0n, tz); + assert.sameValue( + instance.timeZoneId, + tz, + tz + " is a valid timezone" + ); +}); + +let gmtPlus24TZ = "Etc/GMT+24"; +assert.throws( + RangeError, + () => { new Temporal.ZonedDateTime(0n, gmtPlus24TZ); }, + gmtPlus24TZ + " is an invalid timezone" +); diff --git a/test/intl402/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js b/test/intl402/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js index bca3f64ab7f..09d35598dbf 100644 --- a/test/intl402/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js +++ b/test/intl402/Temporal/ZonedDateTime/from/argument-propertybag-timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.zoneddatetime.from -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) +description: Conversion of ISO date-time strings to time zone IDs (with IANA time zones) features: [Temporal] ---*/ diff --git a/test/intl402/Temporal/ZonedDateTime/from/argument-valid.js b/test/intl402/Temporal/ZonedDateTime/from/argument-valid.js new file mode 100644 index 00000000000..ff897d932ac --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/from/argument-valid.js @@ -0,0 +1,27 @@ +// Copyright (C) 2020 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: Built-in time zones are parsed correctly out of valid strings +features: [Temporal] +---*/ + +const valids = [ + ["Africa/Bissau"], + ["America/Belem"], + ["Europe/Vienna"], + ["America/New_York"], + ["Africa/CAIRO", "Africa/Cairo"], + ["Asia/Ulan_Bator"], + ["GMT"], + ["etc/gmt", "Etc/GMT"], + ["1994-11-05T08:15:30-05:00[America/New_York]", "America/New_York"], + ["1994-11-05T08:15:30-05[America/New_York]", "America/New_York"], +]; + +for (const [valid, canonical = valid] of valids) { + const result = Temporal.ZonedDateTime.from({ year: 1970, month: 1, day: 1, timeZone: valid }); + assert.sameValue(Object.getPrototypeOf(result), Temporal.ZonedDateTime.prototype); + assert.sameValue(result.timeZoneId, canonical); +} diff --git a/test/intl402/Temporal/ZonedDateTime/from/disambiguation-undefined.js b/test/intl402/Temporal/ZonedDateTime/from/disambiguation-undefined.js new file mode 100644 index 00000000000..37014105932 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/from/disambiguation-undefined.js @@ -0,0 +1,33 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: Fallback value for disambiguation option +info: | + sec-getoption step 3: + 3. If _value_ is *undefined*, return _fallback_. + sec-temporal-totemporaldisambiguation step 1: + 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). + sec-temporal-totemporalzoneddatetime step 5: + 5. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). + sec-temporal.zoneddatetime.from step 2: + 2. If Type(_item_) is Object and _item_ has an [[InitializedTemporalZonedDateTime]] internal slot, then + ... + d. Return ... + 3. Return ? ToTemporalZonedDateTime(_item_, _options_). +features: [Temporal] +---*/ + +const springForwardFields = { timeZone: "America/Vancouver", year: 2000, month: 4, day: 2, hour: 2, minute: 30 }; +const fallBackFields = { timeZone: "America/Vancouver", year: 2000, month: 10, day: 29, hour: 1, minute: 30 }; + +[ + [springForwardFields, 954671400_000_000_000n], + [fallBackFields, 972808200_000_000_000n], +].forEach(([fields, expected]) => { + const explicit = Temporal.ZonedDateTime.from(fields, { disambiguation: undefined }); + assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible (later)"); + + // See options-undefined.js for {} +}); diff --git a/test/intl402/Temporal/ZonedDateTime/from/etc-timezone.js b/test/intl402/Temporal/ZonedDateTime/from/etc-timezone.js new file mode 100644 index 00000000000..4afd6ec3d5c --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/from/etc-timezone.js @@ -0,0 +1,68 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: Some Etc/GMT{+/-}{0}N timezones are valid, but not all +features: [Temporal] +---*/ + +// "Etc/GMT-0" through "Etc/GMT-14" are OK + +const fields = { year: 1970, month: 1, day: 1 }; + +[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14].forEach((n) => { + const tz = "Etc/GMT-" + n; + const instance = Temporal.ZonedDateTime.from({ ...fields, timeZone: tz }); + assert.sameValue( + instance.timeZoneId, + tz, + tz + " is a valid timezone" + ); +}); + +const gmtMinus24TZ = "Etc/GMT-24"; +assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from({ ...fields, timeZone: gmtMinus24TZ }), + gmtMinus24TZ + " is an invalid timezone" +); + +// "Etc/GMT-0N" is not OK (1 ≤ N ≤ 9) +[1, 2, 3, 4, 5, 6, 7, 8, 9].forEach((n) => { + const tz = "Etc/GMT-0" + n; + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from({ ...fields, timeZone: tz }), + tz + " is an invalid timezone" + ); +}); + +// "Etc/GMT+0N" is not OK (0 ≤ N ≤ 9) +[0, 1, 2, 3, 4, 5, 6, 7, 8, 9].forEach((n) => { + const tz = "Etc/GMT+0" + n; + assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from({ ...fields, timeZone: tz }), + tz + " is an invalid timezone" + ); +}); + +// "Etc/GMT+0" through "Etc/GMT+12" are OK + +[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].forEach((n) => { + const tz = "Etc/GMT+" + n; + const instance = Temporal.ZonedDateTime.from({ ...fields, timeZone: tz }); + assert.sameValue( + instance.timeZoneId, + tz, + tz + " is a valid timezone" + ); +}); + +const gmtPlus24TZ = "Etc/GMT+24"; +assert.throws( + RangeError, + () => Temporal.ZonedDateTime.from({ ...fields, timeZone: gmtPlus24TZ }), + gmtPlus24TZ + " is an invalid timezone" +); diff --git a/test/intl402/Temporal/ZonedDateTime/from/options-undefined.js b/test/intl402/Temporal/ZonedDateTime/from/options-undefined.js new file mode 100644 index 00000000000..02a4091fe14 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/from/options-undefined.js @@ -0,0 +1,42 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.from +description: Verify that undefined options are handled correctly. +features: [Temporal] +---*/ + +const overflowFields = { year: 2000, month: 13, day: 2, timeZone: "UTC" }; + +const overflowExplicit = Temporal.ZonedDateTime.from(overflowFields, undefined); +assert.sameValue(overflowExplicit.month, 12, "default overflow is constrain"); + +const overflowPropertyImplicit = Temporal.ZonedDateTime.from(overflowFields, {}); +assert.sameValue(overflowPropertyImplicit.month, 12, "default overflow is constrain"); + +const overflowImplicit = Temporal.ZonedDateTime.from(overflowFields); +assert.sameValue(overflowImplicit.month, 12, "default overflow is constrain"); + +const timeZone = "America/Vancouver"; +const disambiguationEarlierFields = { timeZone, year: 2000, month: 10, day: 29, hour: 1, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321 }; +const disambiguationLaterFields = { timeZone, year: 2000, month: 4, day: 2, hour: 2, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321 }; + +[ + [disambiguationEarlierFields, 972808496987654321n], + [disambiguationLaterFields, 954671696987654321n], +].forEach(([fields, expected]) => { + const explicit = Temporal.ZonedDateTime.from(fields, undefined); + assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); + + const propertyImplicit = Temporal.ZonedDateTime.from(fields, {}); + assert.sameValue(propertyImplicit.epochNanoseconds, expected, "default disambiguation is compatible"); + + const implicit = Temporal.ZonedDateTime.from(fields); + assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); +}); + +const offsetFields = { year: 2000, month: 5, day: 2, offset: "+23:59", timeZone: "UTC" }; +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(offsetFields, undefined), "default offset is reject"); +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(offsetFields, {}), "default offset is reject"); +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(offsetFields), "default offset is reject"); diff --git a/test/intl402/Temporal/ZonedDateTime/iana-legacy-names.js b/test/intl402/Temporal/ZonedDateTime/iana-legacy-names.js new file mode 100644 index 00000000000..7306570ceed --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/iana-legacy-names.js @@ -0,0 +1,24 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime +description: IANA legacy names must be supported +features: [Temporal] +---*/ + +const legacyNames = [ + "Etc/GMT0", + "GMT0", + "GMT-0", + "GMT+0", + "EST5EDT", + "CST6CDT", + "MST7MDT", + "PST8PDT" +]; + +legacyNames.forEach((arg) => { + const instance = new Temporal.ZonedDateTime(0n, arg); + assert.sameValue(instance.timeZoneId, arg, `"${arg}" does not match "${instance.timeZoneId}" time zone identifier`); +}); diff --git a/test/intl402/Temporal/TimeZone/legacy-non-iana.js b/test/intl402/Temporal/ZonedDateTime/legacy-non-iana.js similarity index 90% rename from test/intl402/Temporal/TimeZone/legacy-non-iana.js rename to test/intl402/Temporal/ZonedDateTime/legacy-non-iana.js index 87db5d09f46..f51dc56a790 100644 --- a/test/intl402/Temporal/TimeZone/legacy-non-iana.js +++ b/test/intl402/Temporal/ZonedDateTime/legacy-non-iana.js @@ -2,7 +2,7 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone +esid: sec-temporal.zoneddatetime description: Only IANA time zone identifiers are allowed. features: [Temporal] ---*/ @@ -39,6 +39,6 @@ const invalidTimeZones = [ for (let timeZone of invalidTimeZones) { assert.throws(RangeError, () => { - new Temporal.TimeZone(timeZone); + new Temporal.ZonedDateTime(0n, timeZone); }, "Time zone: " + timeZone); } diff --git a/test/intl402/Temporal/TimeZone/links-africa.js b/test/intl402/Temporal/ZonedDateTime/links-africa.js similarity index 93% rename from test/intl402/Temporal/TimeZone/links-africa.js rename to test/intl402/Temporal/ZonedDateTime/links-africa.js index 05f36d73e3e..4ddafb0c6f1 100644 --- a/test/intl402/Temporal/TimeZone/links-africa.js +++ b/test/intl402/Temporal/ZonedDateTime/links-africa.js @@ -2,9 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor accepts link names as its input. +esid: sec-temporal.zoneddatetime +description: ZonedDateTime constructor accepts link names as time zone ID input features: [Temporal] ---*/ @@ -49,6 +48,6 @@ const testCases = [ ]; for (let id of testCases) { - const tz = new Temporal.TimeZone(id); - assert.sameValue(tz.id, id); + const instance = new Temporal.ZonedDateTime(0n, id); + assert.sameValue(instance.timeZoneId, id); } diff --git a/test/intl402/Temporal/TimeZone/links-asia.js b/test/intl402/Temporal/ZonedDateTime/links-asia.js similarity index 76% rename from test/intl402/Temporal/TimeZone/links-asia.js rename to test/intl402/Temporal/ZonedDateTime/links-asia.js index 0359cfb232a..d7e30a15091 100644 --- a/test/intl402/Temporal/TimeZone/links-asia.js +++ b/test/intl402/Temporal/ZonedDateTime/links-asia.js @@ -2,9 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor accepts link names as its input. +esid: sec-temporal.zoneddatetime +description: ZonedDateTime constructor accepts link names as time zone ID input features: [Temporal] ---*/ @@ -20,6 +19,6 @@ const testCases = [ ]; for (let id of testCases) { - const tz = new Temporal.TimeZone(id); - assert.sameValue(tz.id, id); + const instance = new Temporal.ZonedDateTime(0n, id); + assert.sameValue(instance.timeZoneId, id); } diff --git a/test/intl402/Temporal/ZonedDateTime/links-australasia.js b/test/intl402/Temporal/ZonedDateTime/links-australasia.js new file mode 100644 index 00000000000..8f55b49f9f9 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/links-australasia.js @@ -0,0 +1,20 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime +description: ZonedDateTime constructor accepts link names as time zone ID input +features: [Temporal] +---*/ + +const testCases = [ + "Pacific/Saipan", // Link Pacific/Guam Pacific/Saipan # N Mariana Is + "Antarctica/McMurdo", // Link Pacific/Auckland Antarctica/McMurdo + "Antarctica/DumontDUrville", // Link Pacific/Port_Moresby Antarctica/DumontDUrville + "Pacific/Midway", // Link Pacific/Pago_Pago Pacific/Midway # in US minor outlying islands +]; + +for (let id of testCases) { + const instance = new Temporal.ZonedDateTime(0n, id); + assert.sameValue(instance.timeZoneId, id); +} diff --git a/test/intl402/Temporal/TimeZone/links-backward.js b/test/intl402/Temporal/ZonedDateTime/links-backward.js similarity index 97% rename from test/intl402/Temporal/TimeZone/links-backward.js rename to test/intl402/Temporal/ZonedDateTime/links-backward.js index bbcd5945cbb..2589861fddf 100644 --- a/test/intl402/Temporal/TimeZone/links-backward.js +++ b/test/intl402/Temporal/ZonedDateTime/links-backward.js @@ -2,9 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor accepts link names as its input. +esid: sec-temporal.zoneddatetime +description: ZonedDateTime constructor accepts link names as time zone ID input features: [Temporal] ---*/ @@ -135,6 +134,6 @@ const testCases = [ ]; for (let id of testCases) { - const tz = new Temporal.TimeZone(id); - assert.sameValue(tz.id, id); + const instance = new Temporal.ZonedDateTime(0n, id); + assert.sameValue(instance.timeZoneId, id); } diff --git a/test/intl402/Temporal/TimeZone/links-backzone.js b/test/intl402/Temporal/ZonedDateTime/links-backzone.js similarity index 78% rename from test/intl402/Temporal/TimeZone/links-backzone.js rename to test/intl402/Temporal/ZonedDateTime/links-backzone.js index cfeb44ef850..f2017e0e961 100644 --- a/test/intl402/Temporal/TimeZone/links-backzone.js +++ b/test/intl402/Temporal/ZonedDateTime/links-backzone.js @@ -2,9 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor accepts link names as its input. +esid: sec-temporal.zoneddatetime +description: ZonedDateTime constructor accepts link names as time zone ID input features: [Temporal] ---*/ @@ -20,6 +19,6 @@ const testCases = [ ]; for (let id of testCases) { - const tz = new Temporal.TimeZone(id); - assert.sameValue(tz.id, id); + const instance = new Temporal.ZonedDateTime(0n, id); + assert.sameValue(instance.timeZoneId, id); } diff --git a/test/intl402/Temporal/TimeZone/links-etcetera.js b/test/intl402/Temporal/ZonedDateTime/links-etcetera.js similarity index 76% rename from test/intl402/Temporal/TimeZone/links-etcetera.js rename to test/intl402/Temporal/ZonedDateTime/links-etcetera.js index de1f19a92fe..1eeff08dbc0 100644 --- a/test/intl402/Temporal/TimeZone/links-etcetera.js +++ b/test/intl402/Temporal/ZonedDateTime/links-etcetera.js @@ -2,9 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor accepts link names as its input. +esid: sec-temporal.zoneddatetime +description: ZonedDateTime constructor accepts link names as time zone ID input features: [Temporal] ---*/ @@ -19,6 +18,6 @@ const testCases = [ ]; for (let id of testCases) { - const tz = new Temporal.TimeZone(id); - assert.sameValue(tz.id, id); + const instance = new Temporal.ZonedDateTime(0n, id); + assert.sameValue(instance.timeZoneId, id); } diff --git a/test/intl402/Temporal/TimeZone/links-europe.js b/test/intl402/Temporal/ZonedDateTime/links-europe.js similarity index 86% rename from test/intl402/Temporal/TimeZone/links-europe.js rename to test/intl402/Temporal/ZonedDateTime/links-europe.js index ba650e72d65..36eb1c04ded 100644 --- a/test/intl402/Temporal/TimeZone/links-europe.js +++ b/test/intl402/Temporal/ZonedDateTime/links-europe.js @@ -2,9 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor accepts link names as its input. +esid: sec-temporal.zoneddatetime +description: ZonedDateTime constructor accepts link names as time zone ID input features: [Temporal] ---*/ @@ -28,6 +27,6 @@ const testCases = [ ]; for (let id of testCases) { - const tz = new Temporal.TimeZone(id); - assert.sameValue(tz.id, id); + const instance = new Temporal.ZonedDateTime(0n, id); + assert.sameValue(instance.timeZoneId, id); } diff --git a/test/intl402/Temporal/TimeZone/links-northamerica.js b/test/intl402/Temporal/ZonedDateTime/links-northamerica.js similarity index 90% rename from test/intl402/Temporal/TimeZone/links-northamerica.js rename to test/intl402/Temporal/ZonedDateTime/links-northamerica.js index 6f1d5bba9b6..91141cc9742 100644 --- a/test/intl402/Temporal/TimeZone/links-northamerica.js +++ b/test/intl402/Temporal/ZonedDateTime/links-northamerica.js @@ -2,9 +2,8 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone -description: > - TimeZone constructor accepts link names as its input. +esid: sec-temporal.zoneddatetime +description: ZonedDateTime constructor accepts link names as time zone ID input features: [Temporal] ---*/ @@ -35,6 +34,6 @@ const testCases = [ ]; for (let id of testCases) { - const tz = new Temporal.TimeZone(id); - assert.sameValue(tz.id, id); + const instance = new Temporal.ZonedDateTime(0n, id); + assert.sameValue(instance.timeZoneId, id); } diff --git a/test/intl402/Temporal/ZonedDateTime/non-canonical-utc.js b/test/intl402/Temporal/ZonedDateTime/non-canonical-utc.js new file mode 100644 index 00000000000..082797f48b9 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/non-canonical-utc.js @@ -0,0 +1,26 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime +description: ZonedDateTime constructor accepts link names as time zone ID input +features: [Temporal] +---*/ + +const testCases = [ + "Etc/GMT", + "Etc/GMT+0", + "Etc/GMT-0", + "Etc/GMT0", + "Etc/Greenwich", + "Etc/UCT", + "Etc/UTC", + "Etc/Universal", + "Etc/Zulu", +]; + +for (let id of testCases) { + let instance = new Temporal.ZonedDateTime(0n, id); + + assert.sameValue(instance.timeZoneId, id); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-object.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-object.js new file mode 100644 index 00000000000..a5e707f6832 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-object.js @@ -0,0 +1,44 @@ +// Copyright (C) 2023 Justin Grant. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Objects with IANA IDs are compared case-insensitively with their canonical IDs +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const namesIANA = [ + "Asia/Calcutta", + "Asia/Kolkata", + "ASIA/calcutta", + "Asia/KOLKATA", +]; + +for (const id1 of namesIANA) { + for (const id2 of namesIANA) { + assert( + instance.withTimeZone(id1).equals(instance.withTimeZone(id2)), + `Receiver ${id1} should equal argument ${id2}` + ); + } +} + +const namesIANADifferentCanonical = [ + "Asia/Colombo", + "ASIA/colombo", +]; + +for (const id1 of namesIANADifferentCanonical) { + for (const id2 of namesIANA) { + assert( + !instance.withTimeZone(id1).equals(instance.withTimeZone(id2)), + `Receiver ${id1} should not equal argument ${id2}` + ); + assert( + !instance.withTimeZone(id2).equals(instance.withTimeZone(id1)), + `Receiver ${id2} should not equal argument ${id1}` + ); + } +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-datetime.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-datetime.js index 1869a17b06a..d6a1cdc15c8 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-datetime.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-propertybag-timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.equals -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) +description: Conversion of ISO date-time strings to time zone IDs (with IANA time zones) features: [Temporal] ---*/ diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-valid.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-valid.js new file mode 100644 index 00000000000..34cca79facc --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/argument-valid.js @@ -0,0 +1,26 @@ +// Copyright (C) 2023 Justin Grant. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Built-in time zones are parsed correctly out of valid strings +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "UTC"); + +const valids = [ + ["Africa/CAIRO", "Africa/Cairo"], + ["Asia/Ulan_Bator", "Asia/Ulaanbaatar"], + ["etc/gmt", "Etc/GMT"], + ["1994-11-05T08:15:30-05:00[America/New_York]", "America/New_York"], + ["1994-11-05T08:15:30+05:30[Asia/Calcutta]", "Asia/Calcutta"], + ["1994-11-05T08:15:30+05:30[Asia/Calcutta]", "Asia/Kolkata"], + ["1994-11-05T08:15:30+05:30[Asia/Kolkata]", "Asia/Calcutta"], + ["1994-11-05T08:15:30+05:30[Asia/Kolkata]", "Asia/Kolkata"], +]; + +for (const [valid, canonical = valid] of valids) { + assert(instance.withTimeZone(valid).equals(instance.withTimeZone(canonical)), `${valid} equals ${canonical}`); + assert(instance.withTimeZone(canonical).equals(instance.withTimeZone(valid)), `${canonical} equals ${valid}`); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/canonical-iana-names.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/canonical-iana-names.js new file mode 100644 index 00000000000..fbd43af572d --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/canonical-iana-names.js @@ -0,0 +1,37 @@ +// Copyright (C) 2023 Justin Grant. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Canonicalizes to evaluate time zone equality +features: [Temporal] +---*/ + +const neverEqual = new Temporal.ZonedDateTime(0n, 'Asia/Tokyo'); +const zdt = new Temporal.ZonedDateTime(0n, 'America/Los_Angeles'); +const ids = [ + ['America/Atka', 'America/Adak'], + ['America/Knox_IN', 'America/Indiana/Knox'], + ['Asia/Ashkhabad', 'Asia/Ashgabat'], + ['Asia/Dacca', 'Asia/Dhaka'], + ['Asia/Istanbul', 'Europe/Istanbul'], + ['Asia/Macao', 'Asia/Macau'], + ['Asia/Thimbu', 'Asia/Thimphu'], + ['Asia/Ujung_Pandang', 'Asia/Makassar'], + ['Asia/Ulan_Bator', 'Asia/Ulaanbaatar'] +]; + +for (const [identifier, primaryIdentifier] of ids) { + const z1 = zdt.withTimeZone(identifier); + const z2 = zdt.withTimeZone(primaryIdentifier); + + // compare objects + assert(z1.equals(z2), `${identifier} equals ${primaryIdentifier} object`); + assert(z2.equals(z1), `${primaryIdentifier} equals ${identifier} object`); + assert(!z1.equals(neverEqual), "not equal to unrelated time zone object"); + + // compare IXDTF strings + assert(z1.equals(z2.toString()), `${identifier} equals ${primaryIdentifier} IXDTF string`); + assert(z2.equals(z1.toString()), `${primaryIdentifier} equals ${identifier} IXDTF string`); + assert(!z1.equals(neverEqual.toString()), "not equal to unrelated IXDTF string"); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/canonical-not-equal.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/canonical-not-equal.js new file mode 100644 index 00000000000..10e7776d375 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/canonical-not-equal.js @@ -0,0 +1,25 @@ +// Copyright (C) 2023 Justin Grant. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Canonical time zone identifiers are never equal to each other +features: [Temporal, Intl-enumeration] +---*/ + +// supportedValuesOf only returns canonical IDs +const ids = Intl.supportedValuesOf("timeZone"); + +const forEachDistinctPair = (array, func) => { + for (let i = 0; i < array.length; i++) { + for (let j = i + 1; j < array.length; j++) { + func(array[i], array[j]); + } + } +}; + +forEachDistinctPair(ids, (id1, id2) => { + const instance = new Temporal.ZonedDateTime(0n, id1); + assert(!instance.equals(instance.withTimeZone(id2)), `${id1} does not equal ${id2}`); +}) + diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/custom-time-zone-ids-case-sensitive.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/custom-time-zone-ids-case-sensitive.js deleted file mode 100644 index d2d057259fb..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/equals/custom-time-zone-ids-case-sensitive.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.equals -description: Custom time zone IDs are compared case-sensitively -features: [Temporal] ----*/ - -class Custom extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} -const custom = Temporal.ZonedDateTime.from({ year: 2020, month: 1, day: 1, timeZone: new Custom("Moon/Cheese") }); -const customSameCase = custom.withTimeZone(new Custom("Moon/Cheese")); -const customDifferentCase = custom.withTimeZone(new Custom("MOON/CHEESE")); - -assert.sameValue(custom.equals(customSameCase), true); -assert.sameValue(custom.equals(customDifferentCase), false); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/different-calendar-not-equal.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/different-calendar-not-equal.js new file mode 100644 index 00000000000..71dc4a78873 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/different-calendar-not-equal.js @@ -0,0 +1,12 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Instances with different calendars are not equal to each other +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(0n, "-05:00", "iso8601"); +const instance2 = new Temporal.ZonedDateTime(0n, "-05:00", "gregory"); +assert(!instance.equals(instance2), "Instances with different calendars are not equal"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/offset-and-iana.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/offset-and-iana.js new file mode 100644 index 00000000000..548cb7f12cc --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/offset-and-iana.js @@ -0,0 +1,15 @@ +// Copyright (C) 2023 Justin Grant. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Offset string time zones compare as expected +features: [Temporal] +---*/ + +const zdt = new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); +assert(zdt.withTimeZone("+05:30").equals(zdt.withTimeZone("+0530")), "+05:30 = +0530"); +assert(zdt.withTimeZone("+0530").equals(zdt.withTimeZone("+05:30")), "+0530 = +05:30"); +assert(zdt.withTimeZone("+05:30").equals(zdt.withTimeZone("+0530").toString()), "+05:30 = +0530 IXDTF string"); +assert(!zdt.withTimeZone("+05:30").equals(zdt.withTimeZone("Asia/Kolkata")), "+05:30 != Asia/Kolkata string ID"); +assert(!zdt.withTimeZone("+05:30").equals(zdt.withTimeZone("Asia/Kolkata").toString()), "+05:30 != Asia/Kolkata IXDTF string"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js index fe058b4a7bf..0e4bd1173b1 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/sub-minute-offset.js @@ -8,8 +8,7 @@ features: [Temporal] ---*/ const expectedNanoseconds = BigInt((44 * 60 + 30) * 1e9); -const timeZone = new Temporal.TimeZone("Africa/Monrovia"); -const instance = new Temporal.ZonedDateTime(expectedNanoseconds, timeZone); +const instance = new Temporal.ZonedDateTime(expectedNanoseconds, "Africa/Monrovia"); let result = instance.equals("1970-01-01T00:00:00-00:45[Africa/Monrovia]"); assert.sameValue(result, true, "UTC offset rounded to minutes is accepted"); @@ -30,6 +29,6 @@ const properties = { day: 1, minute: 44, second: 30, - timeZone + timeZone: "Africa/Monrovia" }; assert.throws(RangeError, () => instance.equals(properties), "no fuzzy matching is done on offset in property bag"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/equals/timezone-case-insensitive.js b/test/intl402/Temporal/ZonedDateTime/prototype/equals/timezone-case-insensitive.js new file mode 100644 index 00000000000..2016e3b994f --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/equals/timezone-case-insensitive.js @@ -0,0 +1,624 @@ +// Copyright (C) 2023 Justin Grant. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.equals +description: Time zone names are compared case-insensitively +features: [Temporal, Intl-enumeration] +---*/ + +const timeZoneIdentifiers = [ + // IANA TZDB Zone names + 'Africa/Abidjan', + 'Africa/Algiers', + 'Africa/Bissau', + 'Africa/Cairo', + 'Africa/Casablanca', + 'Africa/Ceuta', + 'Africa/El_Aaiun', + 'Africa/Johannesburg', + 'Africa/Juba', + 'Africa/Khartoum', + 'Africa/Lagos', + 'Africa/Maputo', + 'Africa/Monrovia', + 'Africa/Nairobi', + 'Africa/Ndjamena', + 'Africa/Sao_Tome', + 'Africa/Tripoli', + 'Africa/Tunis', + 'Africa/Windhoek', + 'America/Adak', + 'America/Anchorage', + 'America/Araguaina', + 'America/Argentina/Buenos_Aires', + 'America/Argentina/Catamarca', + 'America/Argentina/Cordoba', + 'America/Argentina/Jujuy', + 'America/Argentina/La_Rioja', + 'America/Argentina/Mendoza', + 'America/Argentina/Rio_Gallegos', + 'America/Argentina/Salta', + 'America/Argentina/San_Juan', + 'America/Argentina/San_Luis', + 'America/Argentina/Tucuman', + 'America/Argentina/Ushuaia', + 'America/Asuncion', + 'America/Bahia', + 'America/Bahia_Banderas', + 'America/Barbados', + 'America/Belem', + 'America/Belize', + 'America/Boa_Vista', + 'America/Bogota', + 'America/Boise', + 'America/Cambridge_Bay', + 'America/Campo_Grande', + 'America/Cancun', + 'America/Caracas', + 'America/Cayenne', + 'America/Chicago', + 'America/Chihuahua', + // 'America/Ciudad_Juarez' // uncomment after Node supports this ID added in TZDB 2022g + 'America/Costa_Rica', + 'America/Cuiaba', + 'America/Danmarkshavn', + 'America/Dawson', + 'America/Dawson_Creek', + 'America/Denver', + 'America/Detroit', + 'America/Edmonton', + 'America/Eirunepe', + 'America/El_Salvador', + 'America/Fort_Nelson', + 'America/Fortaleza', + 'America/Glace_Bay', + 'America/Goose_Bay', + 'America/Grand_Turk', + 'America/Guatemala', + 'America/Guayaquil', + 'America/Guyana', + 'America/Halifax', + 'America/Havana', + 'America/Hermosillo', + 'America/Indiana/Indianapolis', + 'America/Indiana/Knox', + 'America/Indiana/Marengo', + 'America/Indiana/Petersburg', + 'America/Indiana/Tell_City', + 'America/Indiana/Vevay', + 'America/Indiana/Vincennes', + 'America/Indiana/Winamac', + 'America/Inuvik', + 'America/Iqaluit', + 'America/Jamaica', + 'America/Juneau', + 'America/Kentucky/Louisville', + 'America/Kentucky/Monticello', + 'America/La_Paz', + 'America/Lima', + 'America/Los_Angeles', + 'America/Maceio', + 'America/Managua', + 'America/Manaus', + 'America/Martinique', + 'America/Matamoros', + 'America/Mazatlan', + 'America/Menominee', + 'America/Merida', + 'America/Metlakatla', + 'America/Mexico_City', + 'America/Miquelon', + 'America/Moncton', + 'America/Monterrey', + 'America/Montevideo', + 'America/New_York', + 'America/Nome', + 'America/Noronha', + 'America/North_Dakota/Beulah', + 'America/North_Dakota/Center', + 'America/North_Dakota/New_Salem', + 'America/Nuuk', + 'America/Ojinaga', + 'America/Panama', + 'America/Paramaribo', + 'America/Phoenix', + 'America/Port-au-Prince', + 'America/Porto_Velho', + 'America/Puerto_Rico', + 'America/Punta_Arenas', + 'America/Rankin_Inlet', + 'America/Recife', + 'America/Regina', + 'America/Resolute', + 'America/Rio_Branco', + 'America/Santarem', + 'America/Santiago', + 'America/Santo_Domingo', + 'America/Sao_Paulo', + 'America/Scoresbysund', + 'America/Sitka', + 'America/St_Johns', + 'America/Swift_Current', + 'America/Tegucigalpa', + 'America/Thule', + 'America/Tijuana', + 'America/Toronto', + 'America/Vancouver', + 'America/Whitehorse', + 'America/Winnipeg', + 'America/Yakutat', + 'America/Yellowknife', + 'Antarctica/Casey', + 'Antarctica/Davis', + 'Antarctica/Macquarie', + 'Antarctica/Mawson', + 'Antarctica/Palmer', + 'Antarctica/Rothera', + 'Antarctica/Troll', + 'Asia/Almaty', + 'Asia/Amman', + 'Asia/Anadyr', + 'Asia/Aqtau', + 'Asia/Aqtobe', + 'Asia/Ashgabat', + 'Asia/Atyrau', + 'Asia/Baghdad', + 'Asia/Baku', + 'Asia/Bangkok', + 'Asia/Barnaul', + 'Asia/Beirut', + 'Asia/Bishkek', + 'Asia/Chita', + 'Asia/Choibalsan', + 'Asia/Colombo', + 'Asia/Damascus', + 'Asia/Dhaka', + 'Asia/Dili', + 'Asia/Dubai', + 'Asia/Dushanbe', + 'Asia/Famagusta', + 'Asia/Gaza', + 'Asia/Hebron', + 'Asia/Ho_Chi_Minh', + 'Asia/Hong_Kong', + 'Asia/Hovd', + 'Asia/Irkutsk', + 'Asia/Jakarta', + 'Asia/Jayapura', + 'Asia/Jerusalem', + 'Asia/Kabul', + 'Asia/Kamchatka', + 'Asia/Karachi', + 'Asia/Kathmandu', + 'Asia/Khandyga', + 'Asia/Kolkata', + 'Asia/Krasnoyarsk', + 'Asia/Kuching', + 'Asia/Macau', + 'Asia/Magadan', + 'Asia/Makassar', + 'Asia/Manila', + 'Asia/Nicosia', + 'Asia/Novokuznetsk', + 'Asia/Novosibirsk', + 'Asia/Omsk', + 'Asia/Oral', + 'Asia/Pontianak', + 'Asia/Pyongyang', + 'Asia/Qatar', + 'Asia/Qostanay', + 'Asia/Qyzylorda', + 'Asia/Riyadh', + 'Asia/Sakhalin', + 'Asia/Samarkand', + 'Asia/Seoul', + 'Asia/Shanghai', + 'Asia/Singapore', + 'Asia/Srednekolymsk', + 'Asia/Taipei', + 'Asia/Tashkent', + 'Asia/Tbilisi', + 'Asia/Tehran', + 'Asia/Thimphu', + 'Asia/Tokyo', + 'Asia/Tomsk', + 'Asia/Ulaanbaatar', + 'Asia/Urumqi', + 'Asia/Ust-Nera', + 'Asia/Vladivostok', + 'Asia/Yakutsk', + 'Asia/Yangon', + 'Asia/Yekaterinburg', + 'Asia/Yerevan', + 'Atlantic/Azores', + 'Atlantic/Bermuda', + 'Atlantic/Canary', + 'Atlantic/Cape_Verde', + 'Atlantic/Faroe', + 'Atlantic/Madeira', + 'Atlantic/South_Georgia', + 'Atlantic/Stanley', + 'Australia/Adelaide', + 'Australia/Brisbane', + 'Australia/Broken_Hill', + 'Australia/Darwin', + 'Australia/Eucla', + 'Australia/Hobart', + 'Australia/Lindeman', + 'Australia/Lord_Howe', + 'Australia/Melbourne', + 'Australia/Perth', + 'Australia/Sydney', + 'CET', + 'CST6CDT', + 'EET', + 'EST', + 'EST5EDT', + 'Etc/GMT', + 'Etc/GMT+1', + 'Etc/GMT+10', + 'Etc/GMT+11', + 'Etc/GMT+12', + 'Etc/GMT+2', + 'Etc/GMT+3', + 'Etc/GMT+4', + 'Etc/GMT+5', + 'Etc/GMT+6', + 'Etc/GMT+7', + 'Etc/GMT+8', + 'Etc/GMT+9', + 'Etc/GMT-1', + 'Etc/GMT-10', + 'Etc/GMT-11', + 'Etc/GMT-12', + 'Etc/GMT-13', + 'Etc/GMT-14', + 'Etc/GMT-2', + 'Etc/GMT-3', + 'Etc/GMT-4', + 'Etc/GMT-5', + 'Etc/GMT-6', + 'Etc/GMT-7', + 'Etc/GMT-8', + 'Etc/GMT-9', + 'Etc/UTC', + 'Europe/Andorra', + 'Europe/Astrakhan', + 'Europe/Athens', + 'Europe/Belgrade', + 'Europe/Berlin', + 'Europe/Brussels', + 'Europe/Bucharest', + 'Europe/Budapest', + 'Europe/Chisinau', + 'Europe/Dublin', + 'Europe/Gibraltar', + 'Europe/Helsinki', + 'Europe/Istanbul', + 'Europe/Kaliningrad', + 'Europe/Kirov', + 'Europe/Kyiv', + 'Europe/Lisbon', + 'Europe/London', + 'Europe/Madrid', + 'Europe/Malta', + 'Europe/Minsk', + 'Europe/Moscow', + 'Europe/Paris', + 'Europe/Prague', + 'Europe/Riga', + 'Europe/Rome', + 'Europe/Samara', + 'Europe/Saratov', + 'Europe/Simferopol', + 'Europe/Sofia', + 'Europe/Tallinn', + 'Europe/Tirane', + 'Europe/Ulyanovsk', + 'Europe/Vienna', + 'Europe/Vilnius', + 'Europe/Volgograd', + 'Europe/Warsaw', + 'Europe/Zurich', + 'HST', + 'Indian/Chagos', + 'Indian/Maldives', + 'Indian/Mauritius', + 'MET', + 'MST', + 'MST7MDT', + 'PST8PDT', + 'Pacific/Apia', + 'Pacific/Auckland', + 'Pacific/Bougainville', + 'Pacific/Chatham', + 'Pacific/Easter', + 'Pacific/Efate', + 'Pacific/Fakaofo', + 'Pacific/Fiji', + 'Pacific/Galapagos', + 'Pacific/Gambier', + 'Pacific/Guadalcanal', + 'Pacific/Guam', + 'Pacific/Honolulu', + 'Pacific/Kanton', + 'Pacific/Kiritimati', + 'Pacific/Kosrae', + 'Pacific/Kwajalein', + 'Pacific/Marquesas', + 'Pacific/Nauru', + 'Pacific/Niue', + 'Pacific/Norfolk', + 'Pacific/Noumea', + 'Pacific/Pago_Pago', + 'Pacific/Palau', + 'Pacific/Pitcairn', + 'Pacific/Port_Moresby', + 'Pacific/Rarotonga', + 'Pacific/Tahiti', + 'Pacific/Tarawa', + 'Pacific/Tongatapu', + + // IANA TZDB Link names + 'WET', + 'Africa/Accra', + 'Africa/Addis_Ababa', + 'Africa/Asmara', + 'Africa/Asmera', + 'Africa/Bamako', + 'Africa/Bangui', + 'Africa/Banjul', + 'Africa/Blantyre', + 'Africa/Brazzaville', + 'Africa/Bujumbura', + 'Africa/Conakry', + 'Africa/Dakar', + 'Africa/Dar_es_Salaam', + 'Africa/Djibouti', + 'Africa/Douala', + 'Africa/Freetown', + 'Africa/Gaborone', + 'Africa/Harare', + 'Africa/Kampala', + 'Africa/Kigali', + 'Africa/Kinshasa', + 'Africa/Libreville', + 'Africa/Lome', + 'Africa/Luanda', + 'Africa/Lubumbashi', + 'Africa/Lusaka', + 'Africa/Malabo', + 'Africa/Maseru', + 'Africa/Mbabane', + 'Africa/Mogadishu', + 'Africa/Niamey', + 'Africa/Nouakchott', + 'Africa/Ouagadougou', + 'Africa/Porto-Novo', + 'Africa/Timbuktu', + 'America/Anguilla', + 'America/Antigua', + 'America/Argentina/ComodRivadavia', + 'America/Aruba', + 'America/Atikokan', + 'America/Atka', + 'America/Blanc-Sablon', + 'America/Buenos_Aires', + 'America/Catamarca', + 'America/Cayman', + 'America/Coral_Harbour', + 'America/Cordoba', + 'America/Creston', + 'America/Curacao', + 'America/Dominica', + 'America/Ensenada', + 'America/Fort_Wayne', + 'America/Godthab', + 'America/Grenada', + 'America/Guadeloupe', + 'America/Indianapolis', + 'America/Jujuy', + 'America/Knox_IN', + 'America/Kralendijk', + 'America/Louisville', + 'America/Lower_Princes', + 'America/Marigot', + 'America/Mendoza', + 'America/Montreal', + 'America/Montserrat', + 'America/Nassau', + 'America/Nipigon', + 'America/Pangnirtung', + 'America/Port_of_Spain', + 'America/Porto_Acre', + 'America/Rainy_River', + 'America/Rosario', + 'America/Santa_Isabel', + 'America/Shiprock', + 'America/St_Barthelemy', + 'America/St_Kitts', + 'America/St_Lucia', + 'America/St_Thomas', + 'America/St_Vincent', + 'America/Thunder_Bay', + 'America/Tortola', + 'America/Virgin', + 'Antarctica/DumontDUrville', + 'Antarctica/McMurdo', + 'Antarctica/South_Pole', + 'Antarctica/Syowa', + 'Antarctica/Vostok', + 'Arctic/Longyearbyen', + 'Asia/Aden', + 'Asia/Ashkhabad', + 'Asia/Bahrain', + 'Asia/Brunei', + 'Asia/Calcutta', + 'Asia/Chongqing', + 'Asia/Chungking', + 'Asia/Dacca', + 'Asia/Harbin', + 'Asia/Istanbul', + 'Asia/Kashgar', + 'Asia/Katmandu', + 'Asia/Kuala_Lumpur', + 'Asia/Kuwait', + 'Asia/Macao', + 'Asia/Muscat', + 'Asia/Phnom_Penh', + 'Asia/Rangoon', + 'Asia/Saigon', + 'Asia/Tel_Aviv', + 'Asia/Thimbu', + 'Asia/Ujung_Pandang', + 'Asia/Ulan_Bator', + 'Asia/Vientiane', + 'Atlantic/Faeroe', + 'Atlantic/Jan_Mayen', + 'Atlantic/Reykjavik', + 'Atlantic/St_Helena', + 'Australia/ACT', + 'Australia/Canberra', + 'Australia/Currie', + 'Australia/LHI', + 'Australia/NSW', + 'Australia/North', + 'Australia/Queensland', + 'Australia/South', + 'Australia/Tasmania', + 'Australia/Victoria', + 'Australia/West', + 'Australia/Yancowinna', + 'Brazil/Acre', + 'Brazil/DeNoronha', + 'Brazil/East', + 'Brazil/West', + 'Canada/Atlantic', + 'Canada/Central', + 'Canada/Eastern', + 'Canada/Mountain', + 'Canada/Newfoundland', + 'Canada/Pacific', + 'Canada/Saskatchewan', + 'Canada/Yukon', + 'Chile/Continental', + 'Chile/EasterIsland', + 'Cuba', + 'Egypt', + 'Eire', + 'Etc/GMT+0', + 'Etc/GMT-0', + 'Etc/GMT0', + 'Etc/Greenwich', + 'Etc/UCT', + 'Etc/Universal', + 'Etc/Zulu', + 'Europe/Amsterdam', + 'Europe/Belfast', + 'Europe/Bratislava', + 'Europe/Busingen', + 'Europe/Copenhagen', + 'Europe/Guernsey', + 'Europe/Isle_of_Man', + 'Europe/Jersey', + 'Europe/Kiev', + 'Europe/Ljubljana', + 'Europe/Luxembourg', + 'Europe/Mariehamn', + 'Europe/Monaco', + 'Europe/Nicosia', + 'Europe/Oslo', + 'Europe/Podgorica', + 'Europe/San_Marino', + 'Europe/Sarajevo', + 'Europe/Skopje', + 'Europe/Stockholm', + 'Europe/Tiraspol', + 'Europe/Uzhgorod', + 'Europe/Vaduz', + 'Europe/Vatican', + 'Europe/Zagreb', + 'Europe/Zaporozhye', + 'GB', + 'GB-Eire', + 'GMT', + 'GMT+0', + 'GMT-0', + 'GMT0', + 'Greenwich', + 'Hongkong', + 'Iceland', + 'Indian/Antananarivo', + 'Indian/Christmas', + 'Indian/Cocos', + 'Indian/Comoro', + 'Indian/Kerguelen', + 'Indian/Mahe', + 'Indian/Mayotte', + 'Indian/Reunion', + 'Iran', + 'Israel', + 'Jamaica', + 'Japan', + 'Kwajalein', + 'Libya', + 'Mexico/BajaNorte', + 'Mexico/BajaSur', + 'Mexico/General', + 'NZ', + 'NZ-CHAT', + 'Navajo', + 'PRC', + 'Pacific/Chuuk', + 'Pacific/Enderbury', + 'Pacific/Funafuti', + 'Pacific/Johnston', + 'Pacific/Majuro', + 'Pacific/Midway', + 'Pacific/Pohnpei', + 'Pacific/Ponape', + 'Pacific/Saipan', + 'Pacific/Samoa', + 'Pacific/Truk', + 'Pacific/Wake', + 'Pacific/Wallis', + 'Pacific/Yap', + 'Poland', + 'Portugal', + 'ROC', + 'ROK', + 'Singapore', + 'Turkey', + 'UCT', + 'US/Alaska', + 'US/Aleutian', + 'US/Arizona', + 'US/Central', + 'US/East-Indiana', + 'US/Eastern', + 'US/Hawaii', + 'US/Indiana-Starke', + 'US/Michigan', + 'US/Mountain', + 'US/Pacific', + 'US/Samoa', + 'UTC', + 'Universal', + 'W-SU', + 'Zulu' +]; + +// We want to test all available named time zone identifiers (both primary and non-primary), +// but no ECMAScript built-in API exposes that list. So we use a union of two sources: +// 1. A hard-coded list of Zone and Link identifiers from the 2022g version of IANA TZDB. +// 2. Canonical IDs exposed by Intl.supportedValuesOf('timeZone'), which ensures that IDs +// added to TZDB later than 2022g will be tested. (New IDs are almost always added as primary.) +const ids = [...new Set([...timeZoneIdentifiers, ...Intl.supportedValuesOf('timeZone')])]; +for (const id of ids) { + const lower = id.toLowerCase(); + const upper = id.toUpperCase(); + const zdt = new Temporal.ZonedDateTime(0n, id); + assert(zdt.equals(zdt.withTimeZone(upper)), `Time zone "${id}" compared to string "${upper}"`); + assert(zdt.equals(zdt.withTimeZone(lower)), `Time zone "${id}" compared to string "${lower}"`); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-non-integer.js b/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 84c05894e6d..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.era -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.era); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-not-callable.js b/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index b9f13752848..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.era -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.era, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 6cb1d216ab9..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.era -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.era); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index f856f4dc995..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/era/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.era -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.era); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/era/validate-calendar-value.js b/test/intl402/Temporal/ZonedDateTime/prototype/era/validate-calendar-value.js deleted file mode 100644 index 363d0aab0d2..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/era/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2023 Richard Gibson. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.era -description: Validate result returned from calendar era() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, TypeError], - [-Infinity, TypeError], - [NaN, TypeError], - [-7, TypeError], - [-0.1, TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, TypeError], - [{valueOf() { return "7"; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - era() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.era, `${typeof result} ${String(result)} not converted to string`); -}); - -const preservedResults = [ - undefined, - "string", - "7", - "7.5", -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - era() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.sameValue(instance.era, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-non-integer.js b/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-non-integer.js deleted file mode 100644 index 6e7165f78ee..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-non-integer.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.erayear -description: RangeError thrown if time zone reports an offset that is not an integer number of nanoseconds -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[3600_000_000_000.5, NaN, -Infinity, Infinity].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.eraYear); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-not-callable.js b/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-not-callable.js deleted file mode 100644 index cfb3ec1040b..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-not-callable.js +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.erayear -description: TypeError thrown if timeZone.getOffsetNanosecondsFor is not callable -features: [BigInt, Symbol, Temporal, arrow-function] ----*/ - -[undefined, null, true, Math.PI, 'string', Symbol('sym'), 42n, {}].forEach((notCallable) => { - const timeZone = new Temporal.TimeZone("UTC"); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - timeZone.getOffsetNanosecondsFor = notCallable; - assert.throws( - TypeError, - () => datetime.eraYear, - `Uncallable ${notCallable === null ? 'null' : typeof notCallable} getOffsetNanosecondsFor should throw TypeError` - ); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-out-of-range.js b/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-out-of-range.js deleted file mode 100644 index 15885c2b990..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-out-of-range.js +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.erayear -description: RangeError thrown if time zone reports an offset that is out of range -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[-86400_000_000_000, 86400_000_000_000].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(RangeError, () => datetime.eraYear); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-wrong-type.js b/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-wrong-type.js deleted file mode 100644 index 84c119a595e..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/timezone-getoffsetnanosecondsfor-wrong-type.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2021 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.erayear -description: TypeError thrown if time zone reports an offset that is not a Number -features: [Temporal] -includes: [temporalHelpers.js] ----*/ - -[ - undefined, - null, - true, - "+01:00", - Symbol(), - 3600_000_000_000n, - {}, - { valueOf() { return 3600_000_000_000; } }, -].forEach((wrongOffset) => { - const timeZone = TemporalHelpers.specificOffsetTimeZone(wrongOffset); - const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, timeZone); - assert.throws(TypeError, () => datetime.eraYear); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/validate-calendar-value.js b/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/validate-calendar-value.js deleted file mode 100644 index 6b182b748bb..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/eraYear/validate-calendar-value.js +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (C) 2023 Richard Gibson. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-get-temporal.zoneddatetime.prototype.erayear -description: Validate result returned from calendar eraYear() method -features: [Temporal] ----*/ - -const badResults = [ - [null, TypeError], - [false, TypeError], - [Infinity, RangeError], - [-Infinity, RangeError], - [NaN, RangeError], - [-0.1, RangeError], - ["string", TypeError], - [Symbol("foo"), TypeError], - [7n, TypeError], - [{}, TypeError], - [true, TypeError], - [7.1, RangeError], - ["7", TypeError], - ["7.5", TypeError], - [{valueOf() { return 7; }}, TypeError], -]; - -badResults.forEach(([result, error]) => { - const calendar = new class extends Temporal.Calendar { - eraYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.throws(error, () => instance.eraYear, `${typeof result} ${String(result)} not converted to integer`); -}); - -const preservedResults = [ - undefined, - -7, -]; - -preservedResults.forEach(result => { - const calendar = new class extends Temporal.Calendar { - eraYear() { - return result; - } - }("iso8601"); - const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar); - assert.sameValue(instance.eraYear, result, `${typeof result} ${String(result)} preserved`); -}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/nanoseconds-subtracted-or-added-at-dst-transition.js b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/nanoseconds-subtracted-or-added-at-dst-transition.js new file mode 100644 index 00000000000..e5b6551ff29 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/nanoseconds-subtracted-or-added-at-dst-transition.js @@ -0,0 +1,23 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Test previous transition when nanoseconds are subtracted resp. added to the DST transition. +features: [Temporal] +---*/ + +const dt = Temporal.ZonedDateTime.from("2021-03-28T01:00:00Z[Europe/Berlin]"); + +assert.sameValue(dt.add({nanoseconds: -1}).getTimeZoneTransition("previous").toString(), + "2020-10-25T02:00:00+01:00[Europe/Berlin]", + "DST transition minus one nanosecond"); + +assert.sameValue(dt.getTimeZoneTransition("previous").toString(), + "2020-10-25T02:00:00+01:00[Europe/Berlin]", + "DST transition"); + +assert.sameValue(dt.add({nanoseconds: +1}).getTimeZoneTransition("previous").toString(), + "2021-03-28T03:00:00+02:00[Europe/Berlin]", + "DST transition plus one nanosecond"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/result-type.js b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/result-type.js new file mode 100644 index 00000000000..c017a341b76 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/result-type.js @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Next and previous transition in a named time zone has the correct return type +features: [Temporal] +---*/ + +let zdt = new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); +for (let count = 0; count < 4; count++) { + const transition = zdt.getTimeZoneTransition("next"); + assert(transition instanceof Temporal.ZonedDateTime, "getTimeZoneTransition(next) returns Temporal.ZonedDateTime"); + assert(!transition.equals(zdt), "getTimeZoneTransition(next) does not return its input"); + zdt = transition; +} + +zdt = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "America/Los_Angeles"); +for (let count = 0; count < 4; count++) { + const transition = zdt.getTimeZoneTransition("previous"); + assert(transition instanceof Temporal.ZonedDateTime, "getTimeZoneTransition(previous) returns Temporal.ZonedDateTime"); + assert(!transition.equals(zdt), "getTimeZoneTransition(previous) does not return its input"); + zdt = transition; +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/specific-tzdb-values.js b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/specific-tzdb-values.js new file mode 100644 index 00000000000..99239097dd0 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/specific-tzdb-values.js @@ -0,0 +1,20 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: Smoke test specific values from time zone database +features: [Temporal] +---*/ + +const a1 = new Temporal.ZonedDateTime(1555448460_000_000_000n /* = 2019-04-16T21:01Z */, "America/New_York"); +assert.sameValue(a1.getTimeZoneTransition("next").epochNanoseconds, 1572760800_000_000_000n /* = 2019-11-03T06:00:00Z */); + +const a2 = new Temporal.ZonedDateTime(-5364662400_000_000_000n /* = 1800-01-01T00:00Z */, "America/New_York"); +assert.sameValue(a2.getTimeZoneTransition("next").epochNanoseconds, -2717650800_000_000_000n /* = 1883-11-18T17:00:00Z */); + +const a3 = new Temporal.ZonedDateTime(1591909260_000_000_000n /* = 2020-06-11T21:01Z */, "Europe/London"); +assert.sameValue(a3.getTimeZoneTransition("previous").epochNanoseconds, 1585443600_000_000_000n /* = 2020-03-29T01:00:00Z */); + +const a4 = new Temporal.ZonedDateTime(-3849984000_000_000_000n /* = 1848-01-01T00:00Z */, "Europe/London"); +assert.sameValue(a4.getTimeZoneTransition("previous").epochNanoseconds, -3852662325_000_000_000n, /* = 1847-12-01T00:01:15Z */); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/subtract-second-and-nanosecond-from-last-transition.js b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/subtract-second-and-nanosecond-from-last-transition.js new file mode 100644 index 00000000000..acabbc6b12a --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/subtract-second-and-nanosecond-from-last-transition.js @@ -0,0 +1,41 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Compute next transition when seconds resp. nanoseconds are subtracted from the last transition. +features: [Temporal] +---*/ + +// From : +// +// # Zone NAME STDOFF RULES FORMAT [UNTIL] +// Zone Europe/Paris 0:09:21 - LMT 1891 Mar 15 0:01 +// 0:09:21 - PMT 1911 Mar 11 0:01 # Paris MT + +const zdt = new Temporal.PlainDateTime(1800, 1, 1).toZonedDateTime("Europe/Paris"); +assert.sameValue(zdt.toString(), "1800-01-01T00:00:00+00:09[Europe/Paris]"); +assert.sameValue(zdt.offsetNanoseconds, (9 * 60 + 21) * 1_000_000_000); + +// Ensure the first transition was correctly computed. +const first = zdt.getTimeZoneTransition("next"); +assert.sameValue(first.toString(), "1911-03-10T23:50:39+00:00[Europe/Paris]"); + +let next; + +// Compute the next transition starting from the first transition minus 1s. +const firstMinus1s = first.add({seconds: -1}); +assert.sameValue(firstMinus1s.toString(), "1911-03-10T23:59:59+00:09[Europe/Paris]"); +assert.sameValue(firstMinus1s.offsetNanoseconds, (9 * 60 + 21) * 1_000_000_000); + +next = firstMinus1s.getTimeZoneTransition("next"); +assert.sameValue(next.toString(), "1911-03-10T23:50:39+00:00[Europe/Paris]"); + +// Compute the next transition starting from the first transition minus 1ns. +const firstMinus1ns = first.add({nanoseconds: -1}); +assert.sameValue(firstMinus1ns.toString(), "1911-03-10T23:59:59.999999999+00:09[Europe/Paris]"); +assert.sameValue(firstMinus1ns.offsetNanoseconds, (9 * 60 + 21) * 1_000_000_000); + +next = firstMinus1ns.getTimeZoneTransition("next"); +assert.sameValue(next.toString(), "1911-03-10T23:50:39+00:00[Europe/Paris]"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/transition-at-instant-boundaries.js b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/transition-at-instant-boundaries.js new file mode 100644 index 00000000000..5531d4e496f --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/getTimeZoneTransition/transition-at-instant-boundaries.js @@ -0,0 +1,30 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.gettimezonetransition +description: > + Test transitions at the instant boundaries. +features: [Temporal, Intl-enumeration] +---*/ + +for (let id of Intl.supportedValuesOf("timeZone")) { + const min = new Temporal.ZonedDateTime(-86_40000_00000_00000_00000n, id); + const max = new Temporal.ZonedDateTime(86_40000_00000_00000_00000n, id); + + const next = min.getTimeZoneTransition("next"); + if (next) { + assert(next.epochNanoseconds > min.epochNanoseconds, + "If there's any next transition, it should be after |min|"); + } + + const prev = max.getTimeZoneTransition("previous"); + if (prev) { + assert(prev.epochNanoseconds < max.epochNanoseconds, + "If there's any previous transition, it should be before |max|"); + } + + assert.sameValue(max.getTimeZoneTransition("next"), null, "There shouldn't be any next transition after |max|"); + assert.sameValue(min.getTimeZoneTransition("previous"), null, + "There shouldn't be any previous transition before |min|"); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/hoursInDay/dst-midnight.js b/test/intl402/Temporal/ZonedDateTime/prototype/hoursInDay/dst-midnight.js new file mode 100644 index 00000000000..24e443d3d42 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/hoursInDay/dst-midnight.js @@ -0,0 +1,26 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-get-temporal.zoneddatetime.prototype.hoursinday +description: Test hoursInDay for DST changes at midnight +features: [Temporal] +---*/ + +const fall = Temporal.ZonedDateTime.from({ + year: 2018, + month: 2, + day: 17, + hour: 12, + timeZone: "America/Sao_Paulo", +}); +assert.sameValue(fall.hoursInDay, 25, "25-hour day with backward jump at midnight"); + +const spring = Temporal.ZonedDateTime.from({ + year: 2018, + month: 11, + day: 4, + hour: 12, + timeZone: "America/Sao_Paulo", +}); +assert.sameValue(spring.hoursInDay, 23, "23-hour day with forward jump at midnight"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/offset/basic-named-timezone.js b/test/intl402/Temporal/ZonedDateTime/prototype/offset/basic-named-timezone.js new file mode 100644 index 00000000000..217233f9f55 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/offset/basic-named-timezone.js @@ -0,0 +1,11 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.offset +description: Basic functionality in named time zone +features: [Temporal] +---*/ + +var instance = new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); +assert.sameValue(instance.offset, "-08:00"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/offsetNanoseconds/basic-named-timezone.js b/test/intl402/Temporal/ZonedDateTime/prototype/offsetNanoseconds/basic-named-timezone.js new file mode 100644 index 00000000000..c99b8490ef4 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/offsetNanoseconds/basic-named-timezone.js @@ -0,0 +1,11 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.offsetnanoseconds +description: Basic functionality in named time zone +features: [Temporal] +---*/ + +var instance = new Temporal.ZonedDateTime(0n, "America/Los_Angeles"); +assert.sameValue(instance.offsetNanoseconds, -8 * 3600000000000) diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/offsetNanoseconds/nanoseconds-subtracted-or-added-at-dst-transition.js b/test/intl402/Temporal/ZonedDateTime/prototype/offsetNanoseconds/nanoseconds-subtracted-or-added-at-dst-transition.js new file mode 100644 index 00000000000..762153d7b0c --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/offsetNanoseconds/nanoseconds-subtracted-or-added-at-dst-transition.js @@ -0,0 +1,36 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.offsetnanoseconds +description: > + Test offset when nanoseconds are subtracted or added from DST transition. +features: [Temporal, exponentiation] +---*/ + +// From : +// +// # Rule NAME FROM TO - IN ON AT SAVE LETTER +// Rule CA 1950 1966 - Apr lastSun 1:00 1:00 D +// +// # Zone NAME STDOFF RULES FORMAT [UNTIL] +// Zone America/Los_Angeles -7:52:58 - LMT 1883 Nov 18 12:07:02 +// -8:00 US P%sT 1946 +// -8:00 CA P%sT 1967 +// -8:00 US P%sT + +let p = Temporal.Instant.from("1965-04-25T09:00:00Z").toZonedDateTimeISO("America/Los_Angeles"); + +const nsPerHour = 60 * 60 * 1000**3; + +assert.sameValue(p.offsetNanoseconds, + -7 * nsPerHour, + "DST transition"); + +assert.sameValue(p.add({nanoseconds: +1}).offsetNanoseconds, + -7 * nsPerHour, + "DST transition plus one nanosecond"); + +assert.sameValue(p.add({nanoseconds: -1}).offsetNanoseconds, + -8 * nsPerHour, + "DST transition minus one nanosecond"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/since/calendar-mismatch.js b/test/intl402/Temporal/ZonedDateTime/prototype/since/calendar-mismatch.js new file mode 100644 index 00000000000..2b6fb2dce82 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/since/calendar-mismatch.js @@ -0,0 +1,13 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + Arithmetic between instances with two different calendars is disallowed +features: [Temporal] +---*/ + +const instance1 = new Temporal.ZonedDateTime(0n, "UTC", "iso8601"); +const instance2 = new Temporal.ZonedDateTime(0n, "UTC", "japanese"); +assert.throws(RangeError, () => instance1.since(instance2)); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/since/custom-time-zone-ids-case-sensitive.js b/test/intl402/Temporal/ZonedDateTime/prototype/since/custom-time-zone-ids-case-sensitive.js deleted file mode 100644 index cfb6a7ef67e..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/since/custom-time-zone-ids-case-sensitive.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: Custom time zone IDs are compared case-sensitively -features: [Temporal] ----*/ - -class Custom extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} -const custom = Temporal.ZonedDateTime.from({ year: 2020, month: 1, day: 1, timeZone: new Custom("Moon/Cheese") }); -const customSameCase = custom.withTimeZone(new Custom("Moon/Cheese")).with({ year: 2021 }); -const customDifferentCase = custom.withTimeZone(new Custom("MOON/CHEESE")).with({ year: 2021 }); - -assert.sameValue(custom.since(customSameCase, { largestUnit: "year" }).toString(), "-P1Y"); -assert.throws(RangeError, () => custom.since(customDifferentCase, { largestUnit: "year" })); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/since/dst-balancing-result.js b/test/intl402/Temporal/ZonedDateTime/prototype/since/dst-balancing-result.js new file mode 100644 index 00000000000..66df0882aa0 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/since/dst-balancing-result.js @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + Balancing the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw +{ + const start = new Temporal.ZonedDateTime( + 949132800_000_000_000n /* = 2000-01-29T08Z */, + "America/Vancouver"); /* = 2000-01-29T00-08 in local time */ + const end = new Temporal.ZonedDateTime( + 972889200_000_000_000n /* = 2000-10-30T07Z */, + "America/Vancouver"); /* = 2000-10-29T23-08 in local time */ + + const duration = start.since(end, { largestUnit: "years" }); + TemporalHelpers.assertDuration(duration, 0, -9, 0, 0, -24, 0, 0, 0, 0, 0, + "24 hours does not balance to 1 day in 25-hour day"); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/since/dst-month-day-boundary.js b/test/intl402/Temporal/ZonedDateTime/prototype/since/dst-month-day-boundary.js new file mode 100644 index 00000000000..05c1bab86d8 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/since/dst-month-day-boundary.js @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + Difference with the endpoint being the end of a skipped hour, chooses the + smaller of two possible durations +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +const d1 = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00-07:00 */, "America/Vancouver"); +const d2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T03:00-07:00 */, "America/Vancouver"); +// NOTE: nonexistent hour just before d2 + +const result = d1.since(d2, { largestUnit: "months" }); + +TemporalHelpers.assertDuration( + result, 0, 0, 0, 29, 23, 0, 0, 0, 0, 0, + "Result should not balance up to months, but pick the smaller of two possible durations" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/since/dst-rounding-result.js b/test/intl402/Temporal/ZonedDateTime/prototype/since/dst-rounding-result.js new file mode 100644 index 00000000000..22ab0241f0d --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/since/dst-rounding-result.js @@ -0,0 +1,43 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.since +description: > + Rounding the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const start = new Temporal.ZonedDateTime( + 950868000_000_000_000n /* = 2000-02-18T10Z */, + "America/Vancouver"); /* = 2000-02-18T02-08 in local time */ + const end = new Temporal.ZonedDateTime( + 954709200_000_000_000n /* = 2000-04-02T21Z */, + "America/Vancouver"); /* = 2000-04-02T14-07 in local time */ + + const duration = start.since(end, { largestUnit: "months" }); + TemporalHelpers.assertDuration(duration, 0, -1, 0, -15, -11, 0, 0, 0, 0, 0, + "1-month rounding window is shortened by DST"); +} + + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const start = new Temporal.ZonedDateTime( + 951991200_000_000_000n /* = 2000-03-02T10Z */, + "America/Vancouver"); /* = 2000-03-02T02-08 in local time */ + const end = new Temporal.ZonedDateTime( + 956005200_000_000_000n /* = 2000-04-17T21Z */, + "America/Vancouver"); /* = 2000-04-17T14-07 in local time */ + + const duration = start.since(end, { largestUnit: "months" }); + TemporalHelpers.assertDuration(duration, 0, -1, 0, -15, -12, 0, 0, 0, 0, 0, + "1-month rounding window is not shortened by DST"); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js b/test/intl402/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js index 775dd0430c3..f7cd8289476 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/since/sub-minute-offset.js @@ -8,7 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("Africa/Monrovia"); +const timeZone = "Africa/Monrovia"; const instance = new Temporal.ZonedDateTime(0n, timeZone); let result = instance.since("1970-01-01T00:44:30-00:44:30[Africa/Monrovia]"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/custom-time-zone-name-not-supported.js b/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/custom-time-zone-name-not-supported.js deleted file mode 100644 index 6c34b4b14ba..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/custom-time-zone-name-not-supported.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2023 Igalia, S.L. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.tolocalestring -description: > - Custom time zones with unofficial names are not supported for locale formatting -features: [Temporal] ----*/ - -const timeZone = { - id: "Etc/Custom_Zone", - getPossibleInstantsFor() {}, - getOffsetNanosecondsFor() {}, -}; -const datetime = new Temporal.ZonedDateTime(0n, timeZone); -assert.throws(RangeError, () => datetime.toLocaleString(), "Custom time zones with non-IANA identifiers not supported in Intl"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/time-zone-canonicalized.js b/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/time-zone-canonicalized.js index b1cc8b53b6d..095e7d7c97c 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/time-zone-canonicalized.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toLocaleString/time-zone-canonicalized.js @@ -7,18 +7,7 @@ description: Custom time zone names are canonicalized features: [Temporal] ---*/ -const timeZone1 = { - id: "Asia/Kolkata", - getPossibleInstantsFor() {}, - getOffsetNanosecondsFor() {}, -}; -const datetime1 = new Temporal.ZonedDateTime(0n, timeZone1); - -const timeZone2 = { - id: "Asia/Calcutta", - getPossibleInstantsFor() {}, - getOffsetNanosecondsFor() {}, -}; -const datetime2 = new Temporal.ZonedDateTime(0n, timeZone2); +const datetime1 = new Temporal.ZonedDateTime(0n, "Asia/Kolkata"); +const datetime2 = new Temporal.ZonedDateTime(0n, "Asia/Calcutta"); assert.sameValue(datetime1.toLocaleString(), datetime2.toLocaleString(), "Time zone names are canonicalized before passing to DateTimeFormat"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toPlainDate/preserves-calendar.js b/test/intl402/Temporal/ZonedDateTime/prototype/toPlainDate/preserves-calendar.js new file mode 100644 index 00000000000..1254c90c36f --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toPlainDate/preserves-calendar.js @@ -0,0 +1,12 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.toplaindate +description: The receiver's calendar is preserved in the return value +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(1572342398_271_986_102n, "-07:00", "gregory"); +const result = instance.toPlainDate(); +assert.sameValue(result.calendarId, "gregory", "Calendar is preserved in return value"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toPlainDateTime/basic.js b/test/intl402/Temporal/ZonedDateTime/prototype/toPlainDateTime/basic.js new file mode 100644 index 00000000000..327bf393c0f --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toPlainDateTime/basic.js @@ -0,0 +1,77 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.toplaindatetime +description: Sample of results for IANA time zones +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +function test(epochNs, results) { + Object.entries(results).forEach(([id, expected]) => { + const instance = new Temporal.ZonedDateTime(epochNs, id); + const dt = instance.toPlainDateTime(); + TemporalHelpers.assertPlainDateTime(dt, ...expected, `Local time of ${instance.toInstant()} in ${id}`); + }); +} + +// Unix epoch +test(0n, { + 'America/Los_Angeles': [1969, 12, "M12", 31, 16, 0, 0, 0, 0, 0], + 'America/New_York': [1969, 12, "M12", 31, 19, 0, 0, 0, 0, 0], + 'Africa/Monrovia': [1969, 12, "M12", 31, 23, 15, 30, 0, 0, 0], + 'Europe/London': [1970, 1, "M01", 1, 1, 0, 0, 0, 0, 0], + 'Europe/Berlin': [1970, 1, "M01", 1, 1, 0, 0, 0, 0, 0], + 'Europe/Moscow': [1970, 1, "M01", 1, 3, 0, 0, 0, 0, 0], + 'Asia/Kolkata': [1970, 1, "M01", 1, 5, 30, 0, 0, 0, 0], + 'Asia/Tokyo': [1970, 1, "M01", 1, 9, 0, 0, 0, 0, 0], +}); + +// Just before epoch +test(-1n, { + 'America/Los_Angeles': [1969, 12, "M12", 31, 15, 59, 59, 999, 999, 999], + 'America/New_York': [1969, 12, "M12", 31, 18, 59, 59, 999, 999, 999], + 'Africa/Monrovia': [1969, 12, "M12", 31, 23, 15, 29, 999, 999, 999], + 'Europe/London': [1970, 1, "M01", 1, 0, 59, 59, 999, 999, 999], + 'Europe/Berlin': [1970, 1, "M01", 1, 0, 59, 59, 999, 999, 999], + 'Europe/Moscow': [1970, 1, "M01", 1, 2, 59, 59, 999, 999, 999], + 'Asia/Kolkata': [1970, 1, "M01", 1, 5, 29, 59, 999, 999, 999], + 'Asia/Tokyo': [1970, 1, "M01", 1, 8, 59, 59, 999, 999, 999], +}); + +// Just after epoch +test(1n, { + 'America/Los_Angeles': [1969, 12, "M12", 31, 16, 0, 0, 0, 0, 1], + 'America/New_York': [1969, 12, "M12", 31, 19, 0, 0, 0, 0, 1], + 'Africa/Monrovia': [1969, 12, "M12", 31, 23, 15, 30, 0, 0, 1], + 'Europe/London': [1970, 1, "M01", 1, 1, 0, 0, 0, 0, 1], + 'Europe/Berlin': [1970, 1, "M01", 1, 1, 0, 0, 0, 0, 1], + 'Europe/Moscow': [1970, 1, "M01", 1, 3, 0, 0, 0, 0, 1], + 'Asia/Kolkata': [1970, 1, "M01", 1, 5, 30, 0, 0, 0, 1], + 'Asia/Tokyo': [1970, 1, "M01", 1, 9, 0, 0, 0, 0, 1], +}); + +// Hours before epoch +test(-6300_000_000_001n, { + 'America/Los_Angeles': [1969, 12, "M12", 31, 14, 14, 59, 999, 999, 999], + 'America/New_York': [1969, 12, "M12", 31, 17, 14, 59, 999, 999, 999], + 'Africa/Monrovia': [1969, 12, "M12", 31, 21, 30, 29, 999, 999, 999], + 'Europe/London': [1969, 12, "M12", 31, 23, 14, 59, 999, 999, 999], + 'Europe/Berlin': [1969, 12, "M12", 31, 23, 14, 59, 999, 999, 999], + 'Europe/Moscow': [1970, 1, "M01", 1, 1, 14, 59, 999, 999, 999], + 'Asia/Kolkata': [1970, 1, "M01", 1, 3, 44, 59, 999, 999, 999], + 'Asia/Tokyo': [1970, 1, "M01", 1, 7, 14, 59, 999, 999, 999], +}); + +// Hours after epoch +test(6300_000_000_001n, { + 'America/Los_Angeles': [1969, 12, "M12", 31, 17, 45, 0, 0, 0, 1], + 'America/New_York': [1969, 12, "M12", 31, 20, 45, 0, 0, 0, 1], + 'Africa/Monrovia': [1970, 1, "M01", 1, 1, 0, 30, 0, 0, 1], + 'Europe/London': [1970, 1, "M01", 1, 2, 45, 0, 0, 0, 1], + 'Europe/Berlin': [1970, 1, "M01", 1, 2, 45, 0, 0, 0, 1], + 'Europe/Moscow': [1970, 1, "M01", 1, 4, 45, 0, 0, 0, 1], + 'Asia/Kolkata': [1970, 1, "M01", 1, 7, 15, 0, 0, 0, 1], + 'Asia/Tokyo': [1970, 1, "M01", 1, 10, 45, 0, 0, 0, 1], +}); diff --git a/test/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/dst.js b/test/intl402/Temporal/ZonedDateTime/prototype/toPlainDateTime/dst.js similarity index 79% rename from test/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/dst.js rename to test/intl402/Temporal/ZonedDateTime/prototype/toPlainDateTime/dst.js index dea36e2dcdc..ddb26275b06 100644 --- a/test/intl402/Temporal/TimeZone/prototype/getPlainDateTimeFor/dst.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toPlainDateTime/dst.js @@ -2,17 +2,16 @@ // This code is governed by the BSD license found in the LICENSE file. /*--- -esid: sec-temporal.timezone.prototype.getplaindatetimefor +esid: sec-temporal.zoneddatetime.prototype.toplaindatetime description: Sample of results for IANA time zones around DST changes includes: [temporalHelpers.js] features: [Temporal] ---*/ function test(epochNs, id, expected) { - const instant = new Temporal.Instant(epochNs); - const tz = new Temporal.TimeZone(id); - const dt = tz.getPlainDateTimeFor(instant); - TemporalHelpers.assertPlainDateTime(dt, ...expected, `Local time of ${instant} in ${id}`); + const instance = new Temporal.ZonedDateTime(epochNs, id); + const dt = instance.toPlainDateTime(); + TemporalHelpers.assertPlainDateTime(dt, ...expected, `Local time of ${instance.toInstant()} in ${id}`); } // Just before DST forward shift diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js new file mode 100644 index 00000000000..45c4178b9b7 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-always.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.tostring +description: If calendarName is "always", the calendar ID should be included. +features: [Temporal] +---*/ + +const tests = [ + [[], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=iso8601]", "built-in ISO"], + [["gregory"], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); + const result = date.toString({ calendarName: "always" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = always`); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js new file mode 100644 index 00000000000..e55b0dad3cf --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-auto.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.tostring +description: If calendarName is "auto", "iso8601" should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], + [["gregory"], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); + const result = date.toString({ calendarName: "auto" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = auto`); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js new file mode 100644 index 00000000000..928a940cd9e --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-critical.js @@ -0,0 +1,21 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.tostring +description: > + If calendarName is "calendar", the calendar ID should be included and prefixed + with "!". +features: [Temporal] +---*/ + +const tests = [ + [[], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=iso8601]", "built-in ISO"], + [["gregory"], "1970-01-01T01:01:01.987654321+00:00[UTC][!u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); + const result = date.toString({ calendarName: "critical" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = critical`); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js new file mode 100644 index 00000000000..abec820828a --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-never.js @@ -0,0 +1,19 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.tostring +description: If calendarName is "never", the calendar ID should be omitted. +features: [Temporal] +---*/ + +const tests = [ + [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], + [["gregory"], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const date = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); + const result = date.toString({ calendarName: "never" }); + assert.sameValue(result, expected, `${description} calendar for calendarName = never`); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js new file mode 100644 index 00000000000..8b334d50b9a --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.protoype.tostring +description: Fallback value for calendarName option +info: | + sec-getoption step 3: + 3. If _value_ is *undefined*, return _fallback_. + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.zoneddatetime.protoype.tostring step 6: + 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +features: [Temporal] +---*/ + +const tests = [ + [[], "1970-01-01T01:01:01.987654321+00:00[UTC]", "built-in ISO"], + [["gregory"], "1970-01-01T01:01:01.987654321+00:00[UTC][u-ca=gregory]", "built-in Gregorian"], +]; + +for (const [args, expected, description] of tests) { + const datetime = new Temporal.ZonedDateTime(3661_987_654_321n, "UTC", ...args); + const result = datetime.toString({ calendarName: undefined }); + assert.sameValue(result, expected, `default calendarName option is auto with ${description} calendar`); + // See options-object.js for {} and options-undefined.js for absent options arg +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js new file mode 100644 index 00000000000..ec73c3c37b3 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toString/calendarname-wrong-type.js @@ -0,0 +1,23 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.protoype.tostring +description: Type conversions for calendarName option +info: | + sec-getoption step 9.a: + a. Set _value_ to ? ToString(_value_). + sec-temporal-toshowcalendaroption step 1: + 1. Return ? GetOption(_normalizedOptions_, *"calendarName"*, « *"string"* », « *"auto"*, *"always"*, *"never"*, *"critical"* », *"auto"*). + sec-temporal.zoneddatetime.protoype.tostring step 6: + 6. Let _showCalendar_ be ? ToShowCalendarOption(_options_). +includes: [compareArray.js, temporalHelpers.js] +features: [Temporal] +---*/ + +const datetime = new Temporal.ZonedDateTime(1_000_000_000_987_654_321n, "UTC", "gregory"); + +TemporalHelpers.checkStringOptionWrongType("calendarName", "auto", + (calendarName) => datetime.toString({ calendarName }), + (result, descr) => assert.sameValue(result, "2001-09-09T01:46:40.987654321+00:00[UTC][u-ca=gregory]", descr), +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/toString/options-undefined.js b/test/intl402/Temporal/ZonedDateTime/prototype/toString/options-undefined.js new file mode 100644 index 00000000000..1e54c3e4f1c --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/toString/options-undefined.js @@ -0,0 +1,25 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.tostring +description: Verify that undefined options are handled correctly. +features: [Temporal] +---*/ + +const datetime1 = new Temporal.ZonedDateTime(957270896_987_650_000n, "UTC"); +const datetime2 = new Temporal.ZonedDateTime(957270896_987_650_000n, "UTC", "gregory"); + +[ + [datetime1, "2000-05-02T12:34:56.98765+00:00[UTC]"], + [datetime2, "2000-05-02T12:34:56.98765+00:00[UTC][u-ca=gregory]"], +].forEach(([datetime, expected]) => { + const explicit = datetime.toString(undefined); + assert.sameValue(explicit, expected, "default show options are auto, precision is auto, and no rounding"); + + const propertyImplicit = datetime.toString({}); + assert.sameValue(propertyImplicit, expected, "default show options are auto, precision is auto, and no rounding"); + + const implicit = datetime.toString(); + assert.sameValue(implicit, expected, "default show options are auto, precision is auto, and no rounding"); +}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js b/test/intl402/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js index 5d3def2fb3a..101c00a151b 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/until/argument-propertybag-timezone-string-datetime.js @@ -3,7 +3,7 @@ /*--- esid: sec-temporal.zoneddatetime.prototype.until -description: Conversion of ISO date-time strings to Temporal.TimeZone instances (with IANA time zones) +description: Conversion of ISO date-time strings to time zone IDs (with IANA time zones) features: [Temporal] ---*/ diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/until/calendar-mismatch.js b/test/intl402/Temporal/ZonedDateTime/prototype/until/calendar-mismatch.js new file mode 100644 index 00000000000..306ab1fa24c --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/until/calendar-mismatch.js @@ -0,0 +1,13 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Arithmetic between instances with two different calendars is disallowed +features: [Temporal] +---*/ + +const instance1 = new Temporal.ZonedDateTime(0n, "UTC", "iso8601"); +const instance2 = new Temporal.ZonedDateTime(0n, "UTC", "japanese"); +assert.throws(RangeError, () => instance1.until(instance2)); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/until/custom-time-zone-ids-case-sensitive.js b/test/intl402/Temporal/ZonedDateTime/prototype/until/custom-time-zone-ids-case-sensitive.js deleted file mode 100644 index 2410f567b1e..00000000000 --- a/test/intl402/Temporal/ZonedDateTime/prototype/until/custom-time-zone-ids-case-sensitive.js +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright (C) 2023 Justin Grant. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal.zoneddatetime.prototype.since -description: Custom time zone IDs are compared case-sensitively -features: [Temporal] ----*/ - -class Custom extends Temporal.TimeZone { - constructor(id) { - super("UTC"); - this._id = id; - } - get id() { - return this._id; - } -} -const custom = Temporal.ZonedDateTime.from({ year: 2020, month: 1, day: 1, timeZone: new Custom("Moon/Cheese") }); -const customSameCase = custom.withTimeZone(new Custom("Moon/Cheese")).with({ year: 2021 }); -const customDifferentCase = custom.withTimeZone(new Custom("MOON/CHEESE")).with({ year: 2021 }); - -assert.sameValue(custom.until(customSameCase, { largestUnit: "year" }).toString(), "P1Y"); -assert.throws(RangeError, () => custom.until(customDifferentCase, { largestUnit: "year" })); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/until/dst-balancing-result.js b/test/intl402/Temporal/ZonedDateTime/prototype/until/dst-balancing-result.js new file mode 100644 index 00000000000..9fbd5d83a13 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/until/dst-balancing-result.js @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Balancing the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw +{ + const start = new Temporal.ZonedDateTime( + 949132800_000_000_000n /* = 2000-01-29T08Z */, + "America/Vancouver"); /* = 2000-01-29T00-08 in local time */ + const end = new Temporal.ZonedDateTime( + 972889200_000_000_000n /* = 2000-10-30T07Z */, + "America/Vancouver"); /* = 2000-10-29T23-08 in local time */ + + const duration = start.until(end, { largestUnit: "years" }); + TemporalHelpers.assertDuration(duration, 0, 9, 0, 0, 24, 0, 0, 0, 0, 0, + "24 hours does not balance to 1 day in 25-hour day"); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/until/dst-month-day-boundary.js b/test/intl402/Temporal/ZonedDateTime/prototype/until/dst-month-day-boundary.js new file mode 100644 index 00000000000..1945f2d6ea2 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/until/dst-month-day-boundary.js @@ -0,0 +1,24 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Difference with the endpoint being the end of a skipped hour, chooses the + smaller of two possible durations +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +const d1 = new Temporal.ZonedDateTime(957258000_000_000_000n /* = 2000-05-02T02:00-07:00 */, "America/Vancouver"); +const d2 = new Temporal.ZonedDateTime(954669600_000_000_000n /* = 2000-04-02T03:00-07:00 */, "America/Vancouver"); +// NOTE: nonexistent hour just before d2 + +const result = d1.until(d2, { largestUnit: "months" }); + +TemporalHelpers.assertDuration( + result, 0, 0, 0, -29, -23, 0, 0, 0, 0, 0, + "Result should not balance up to months, but pick the smaller of two possible durations" +); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/until/dst-rounding-result.js b/test/intl402/Temporal/ZonedDateTime/prototype/until/dst-rounding-result.js new file mode 100644 index 00000000000..984a070ccc2 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/until/dst-rounding-result.js @@ -0,0 +1,43 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-temporal.zoneddatetime.prototype.until +description: > + Rounding the resulting duration takes the time zone's UTC offset shifts + into account +includes: [temporalHelpers.js] +features: [Temporal] +---*/ + +// Based on a test case by Adam Shaw + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const start = new Temporal.ZonedDateTime( + 950868000_000_000_000n /* = 2000-02-18T10Z */, + "America/Vancouver"); /* = 2000-02-18T02-08 in local time */ + const end = new Temporal.ZonedDateTime( + 954709200_000_000_000n /* = 2000-04-02T21Z */, + "America/Vancouver"); /* = 2000-04-02T14-07 in local time */ + + const duration = start.until(end, { largestUnit: "months" }); + TemporalHelpers.assertDuration(duration, 0, 1, 0, 15, 11, 0, 0, 0, 0, 0, + "1-month rounding window is shortened by DST"); +} + + +{ + // Month-only part of duration lands on skipped DST hour, should not cause + // disambiguation + const start = new Temporal.ZonedDateTime( + 951991200_000_000_000n /* = 2000-03-02T10Z */, + "America/Vancouver"); /* = 2000-03-02T02-08 in local time */ + const end = new Temporal.ZonedDateTime( + 956005200_000_000_000n /* = 2000-04-17T21Z */, + "America/Vancouver"); /* = 2000-04-17T14-07 in local time */ + + const duration = start.until(end, { largestUnit: "months" }); + TemporalHelpers.assertDuration(duration, 0, 1, 0, 15, 12, 0, 0, 0, 0, 0, + "1-month rounding window is not shortened by DST"); +} diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js b/test/intl402/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js index e1081896713..08a6640eb84 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/until/sub-minute-offset.js @@ -8,8 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("Africa/Monrovia"); -const instance = new Temporal.ZonedDateTime(0n, timeZone); +const instance = new Temporal.ZonedDateTime(0n, "Africa/Monrovia"); let result = instance.until("1970-01-01T00:44:30-00:44:30[Africa/Monrovia]"); TemporalHelpers.assertDuration(result, 0, 0, 0, 0, 1, 29, 0, 0, 0, 0, "UTC offset rounded to minutes is accepted"); @@ -30,6 +29,6 @@ const properties = { day: 1, minute: 44, second: 30, - timeZone + timeZone: "Africa/Monrovia" }; assert.throws(RangeError, () => instance.until(properties), "no fuzzy matching is done on offset in property bag"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js b/test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js index c02e49a0b4d..e9c2477db6c 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/gregory-iso-weekofyear.js @@ -16,12 +16,12 @@ features: [Temporal] // -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); assert.sameValue(date.weekOfYear, 1); -calendar = new Temporal.Calendar("iso8601"); +calendar = "iso8601"; const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); assert.sameValue(isodate.weekOfYear, 53); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js b/test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js index c5f23944169..eb856856859 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/weekOfYear/non-iso-week-of-year.js @@ -11,14 +11,14 @@ features: [Temporal] // Gregorian calendar has a well defined week-numbering system. -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; // Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); assert.sameValue(date.weekOfYear, 1); -calendar = new Temporal.Calendar("hebrew"); +calendar = "hebrew"; const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); assert.sameValue(nonisodate.weekOfYear, undefined); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/with/disambiguation-undefined.js b/test/intl402/Temporal/ZonedDateTime/prototype/with/disambiguation-undefined.js new file mode 100644 index 00000000000..67315649593 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/with/disambiguation-undefined.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.with +description: Fallback value for disambiguation option +info: | + sec-getoption step 3: + 3. If _value_ is *undefined*, return _fallback_. + sec-temporal-totemporaldisambiguation step 1: + 1. Return ? GetOption(_normalizedOptions_, *"disambiguation"*, « String », « *"compatible"*, *"earlier"*, *"later"*, *"reject"* », *"compatible"*). + sec-temporal.zoneddatetime.protoype.with step 14: + 14. Let _disambiguation_ be ? ToTemporalDisambiguation(_options_). +features: [Temporal] +---*/ + +const springForwardDatetime = new Temporal.ZonedDateTime(954702001_000_000_000n, "America/Vancouver"); +const fallBackDatetime = new Temporal.ZonedDateTime(972849601_000_000_000n, "America/Vancouver"); +const offset = "ignore"; + +[ + [springForwardDatetime, { hour: 2, minute: 30 }, 954671401_000_000_000n], + [fallBackDatetime, { hour: 1, minute: 30 }, 972808201_000_000_000n], +].forEach(([datetime, fields, expected]) => { + const explicit = datetime.with(fields, { offset, disambiguation: undefined }); + assert.sameValue(explicit.epochNanoseconds, expected, "default disambiguation is compatible"); + const implicit = datetime.with(fields, { offset }); + assert.sameValue(implicit.epochNanoseconds, expected, "default disambiguation is compatible"); +}); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js b/test/intl402/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js index ed5c00b7cfd..d1cc633ee2d 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/with/offset-property-sub-minute.js @@ -8,8 +8,7 @@ includes: [temporalHelpers.js] features: [Temporal] ---*/ -const timeZone = new Temporal.TimeZone("Africa/Monrovia"); -const instance = Temporal.ZonedDateTime.from({ year: 1970, month: 1, day: 1, hour: 12, timeZone }); +const instance = Temporal.ZonedDateTime.from({ year: 1970, month: 1, day: 1, hour: 12, timeZone: "Africa/Monrovia" }); assert.sameValue(instance.offset, "-00:44:30", "original offset"); const properties = { day: 2, offset: "-00:45" }; diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/basic.js b/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/basic.js new file mode 100644 index 00000000000..4ab115c367c --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/basic.js @@ -0,0 +1,12 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withcalendar +description: Basic functionality of withCalendar +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(1572342398_271_986_102n, "-07:00", "gregory"); +const result = instance.withCalendar("japanese"); +assert.sameValue(result.calendarId, "japanese", "withCalendar() returns a new instance with different calendarId"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive.js b/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive.js index dd8d0ee48a6..1b90e38394d 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/calendar-case-insensitive.js @@ -7,29 +7,7 @@ description: Calendar names are case-insensitive features: [Temporal] ---*/ -const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "replace-me", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}); +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC"); const arg = "jApAnEsE";; const result = instance.withCalendar(arg); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/preserves-instant.js b/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/preserves-instant.js new file mode 100644 index 00000000000..5aa4b36a186 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/preserves-instant.js @@ -0,0 +1,12 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withcalendar +description: The receiver's exact time is preserved in the return value +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(1572342398_271_986_102n, "-07:00", "gregory"); +const result = instance.withCalendar("japanese"); +assert.sameValue(result.epochNanoseconds, 1572342398_271_986_102n, "Exact time is preserved in return value"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/preserves-time-zone.js b/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/preserves-time-zone.js new file mode 100644 index 00000000000..14716445406 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/withCalendar/preserves-time-zone.js @@ -0,0 +1,12 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withtimezone +description: The receiver's time zone is preserved in the return value +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(1572342398_271_986_102n, "-07:00", "gregory"); +const result = instance.withCalendar("japanese"); +assert.sameValue(result.timeZoneId, "-07:00", "Time zone is preserved in return value"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/withTimeZone/preserves-calendar.js b/test/intl402/Temporal/ZonedDateTime/prototype/withTimeZone/preserves-calendar.js new file mode 100644 index 00000000000..2c6844b2472 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/prototype/withTimeZone/preserves-calendar.js @@ -0,0 +1,12 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime.prototype.withtimezone +description: The receiver's calendar is preserved in the return value +features: [Temporal] +---*/ + +const instance = new Temporal.ZonedDateTime(1572342398_271_986_102n, "-07:00", "gregory"); +const result = instance.withTimeZone("-08:00"); +assert.sameValue(result.calendarId, "gregory", "Calendar is preserved in return value"); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js b/test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js index 439a5173d11..f7b22ab3583 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/gregory-iso-weekofyear.js @@ -16,12 +16,12 @@ features: [Temporal] // -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; const date = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); assert.sameValue(date.yearOfWeek, 2021); -calendar = new Temporal.Calendar("iso8601"); +calendar = "iso8601"; const isodate = new Temporal.ZonedDateTime(1_609_504_496_987_654_321n, "UTC", calendar); assert.sameValue(isodate.yearOfWeek, 2020); diff --git a/test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js b/test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js index 7e163fa529d..55e8d624ee2 100644 --- a/test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js +++ b/test/intl402/Temporal/ZonedDateTime/prototype/yearOfWeek/non-iso-week-of-year.js @@ -11,14 +11,14 @@ features: [Temporal] // Gregorian calendar has a well defined week-numbering system. -let calendar = new Temporal.Calendar("gregory"); +let calendar = "gregory"; // Epoch Nanoseconds for new Temporal.PlainDateTime(2024, 1, 1, 12, 34, 56, 987, 654, 321, calendar); const date = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); assert.sameValue(date.yearOfWeek, 2024); -calendar = new Temporal.Calendar("hebrew"); +calendar = "hebrew"; const nonisodate = new Temporal.ZonedDateTime(1_704_112_496_987_654_321n, "UTC", calendar); assert.sameValue(nonisodate.yearOfWeek, undefined); diff --git a/test/intl402/Temporal/ZonedDateTime/supported-values-of.js b/test/intl402/Temporal/ZonedDateTime/supported-values-of.js new file mode 100644 index 00000000000..3c827a13c10 --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/supported-values-of.js @@ -0,0 +1,17 @@ +// Copyright (C) 2022 André Bargull. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime +description: > + ZonedDateTime constructor accepts all time zone identifiers from + Intl.supportedValuesOf. +features: [Temporal, Intl-enumeration] +---*/ + +// Ensure all identifiers are valid and canonical. +for (let id of Intl.supportedValuesOf("timeZone")) { + let instance = new Temporal.ZonedDateTime(0n, id); + + assert.sameValue(instance.timeZoneId, id); +} diff --git a/test/intl402/Temporal/ZonedDateTime/timezone-case-insensitive.js b/test/intl402/Temporal/ZonedDateTime/timezone-case-insensitive.js new file mode 100644 index 00000000000..2b6578bdeca --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/timezone-case-insensitive.js @@ -0,0 +1,629 @@ +// Copyright (C) 2022 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime +description: Time zone names are case-normalized +features: [Temporal] +---*/ + +const timeZone = 'eTc/gMt+1'; +const result = new Temporal.ZonedDateTime(0n, timeZone); +assert.sameValue(result.timeZoneId, 'Etc/GMT+1', `Time zone created from string "${timeZone}"`); + +const timeZoneIdentifiers = [ + // IANA TZDB Zone names + 'Africa/Abidjan', + 'Africa/Algiers', + 'Africa/Bissau', + 'Africa/Cairo', + 'Africa/Casablanca', + 'Africa/Ceuta', + 'Africa/El_Aaiun', + 'Africa/Johannesburg', + 'Africa/Juba', + 'Africa/Khartoum', + 'Africa/Lagos', + 'Africa/Maputo', + 'Africa/Monrovia', + 'Africa/Nairobi', + 'Africa/Ndjamena', + 'Africa/Sao_Tome', + 'Africa/Tripoli', + 'Africa/Tunis', + 'Africa/Windhoek', + 'America/Adak', + 'America/Anchorage', + 'America/Araguaina', + 'America/Argentina/Buenos_Aires', + 'America/Argentina/Catamarca', + 'America/Argentina/Cordoba', + 'America/Argentina/Jujuy', + 'America/Argentina/La_Rioja', + 'America/Argentina/Mendoza', + 'America/Argentina/Rio_Gallegos', + 'America/Argentina/Salta', + 'America/Argentina/San_Juan', + 'America/Argentina/San_Luis', + 'America/Argentina/Tucuman', + 'America/Argentina/Ushuaia', + 'America/Asuncion', + 'America/Bahia', + 'America/Bahia_Banderas', + 'America/Barbados', + 'America/Belem', + 'America/Belize', + 'America/Boa_Vista', + 'America/Bogota', + 'America/Boise', + 'America/Cambridge_Bay', + 'America/Campo_Grande', + 'America/Cancun', + 'America/Caracas', + 'America/Cayenne', + 'America/Chicago', + 'America/Chihuahua', + // 'America/Ciudad_Juarez' // uncomment after Node supports this ID added in TZDB 2022g + 'America/Costa_Rica', + 'America/Cuiaba', + 'America/Danmarkshavn', + 'America/Dawson', + 'America/Dawson_Creek', + 'America/Denver', + 'America/Detroit', + 'America/Edmonton', + 'America/Eirunepe', + 'America/El_Salvador', + 'America/Fort_Nelson', + 'America/Fortaleza', + 'America/Glace_Bay', + 'America/Goose_Bay', + 'America/Grand_Turk', + 'America/Guatemala', + 'America/Guayaquil', + 'America/Guyana', + 'America/Halifax', + 'America/Havana', + 'America/Hermosillo', + 'America/Indiana/Indianapolis', + 'America/Indiana/Knox', + 'America/Indiana/Marengo', + 'America/Indiana/Petersburg', + 'America/Indiana/Tell_City', + 'America/Indiana/Vevay', + 'America/Indiana/Vincennes', + 'America/Indiana/Winamac', + 'America/Inuvik', + 'America/Iqaluit', + 'America/Jamaica', + 'America/Juneau', + 'America/Kentucky/Louisville', + 'America/Kentucky/Monticello', + 'America/La_Paz', + 'America/Lima', + 'America/Los_Angeles', + 'America/Maceio', + 'America/Managua', + 'America/Manaus', + 'America/Martinique', + 'America/Matamoros', + 'America/Mazatlan', + 'America/Menominee', + 'America/Merida', + 'America/Metlakatla', + 'America/Mexico_City', + 'America/Miquelon', + 'America/Moncton', + 'America/Monterrey', + 'America/Montevideo', + 'America/New_York', + 'America/Nome', + 'America/Noronha', + 'America/North_Dakota/Beulah', + 'America/North_Dakota/Center', + 'America/North_Dakota/New_Salem', + 'America/Nuuk', + 'America/Ojinaga', + 'America/Panama', + 'America/Paramaribo', + 'America/Phoenix', + 'America/Port-au-Prince', + 'America/Porto_Velho', + 'America/Puerto_Rico', + 'America/Punta_Arenas', + 'America/Rankin_Inlet', + 'America/Recife', + 'America/Regina', + 'America/Resolute', + 'America/Rio_Branco', + 'America/Santarem', + 'America/Santiago', + 'America/Santo_Domingo', + 'America/Sao_Paulo', + 'America/Scoresbysund', + 'America/Sitka', + 'America/St_Johns', + 'America/Swift_Current', + 'America/Tegucigalpa', + 'America/Thule', + 'America/Tijuana', + 'America/Toronto', + 'America/Vancouver', + 'America/Whitehorse', + 'America/Winnipeg', + 'America/Yakutat', + 'America/Yellowknife', + 'Antarctica/Casey', + 'Antarctica/Davis', + 'Antarctica/Macquarie', + 'Antarctica/Mawson', + 'Antarctica/Palmer', + 'Antarctica/Rothera', + 'Antarctica/Troll', + 'Asia/Almaty', + 'Asia/Amman', + 'Asia/Anadyr', + 'Asia/Aqtau', + 'Asia/Aqtobe', + 'Asia/Ashgabat', + 'Asia/Atyrau', + 'Asia/Baghdad', + 'Asia/Baku', + 'Asia/Bangkok', + 'Asia/Barnaul', + 'Asia/Beirut', + 'Asia/Bishkek', + 'Asia/Chita', + 'Asia/Choibalsan', + 'Asia/Colombo', + 'Asia/Damascus', + 'Asia/Dhaka', + 'Asia/Dili', + 'Asia/Dubai', + 'Asia/Dushanbe', + 'Asia/Famagusta', + 'Asia/Gaza', + 'Asia/Hebron', + 'Asia/Ho_Chi_Minh', + 'Asia/Hong_Kong', + 'Asia/Hovd', + 'Asia/Irkutsk', + 'Asia/Jakarta', + 'Asia/Jayapura', + 'Asia/Jerusalem', + 'Asia/Kabul', + 'Asia/Kamchatka', + 'Asia/Karachi', + 'Asia/Kathmandu', + 'Asia/Khandyga', + 'Asia/Kolkata', + 'Asia/Krasnoyarsk', + 'Asia/Kuching', + 'Asia/Macau', + 'Asia/Magadan', + 'Asia/Makassar', + 'Asia/Manila', + 'Asia/Nicosia', + 'Asia/Novokuznetsk', + 'Asia/Novosibirsk', + 'Asia/Omsk', + 'Asia/Oral', + 'Asia/Pontianak', + 'Asia/Pyongyang', + 'Asia/Qatar', + 'Asia/Qostanay', + 'Asia/Qyzylorda', + 'Asia/Riyadh', + 'Asia/Sakhalin', + 'Asia/Samarkand', + 'Asia/Seoul', + 'Asia/Shanghai', + 'Asia/Singapore', + 'Asia/Srednekolymsk', + 'Asia/Taipei', + 'Asia/Tashkent', + 'Asia/Tbilisi', + 'Asia/Tehran', + 'Asia/Thimphu', + 'Asia/Tokyo', + 'Asia/Tomsk', + 'Asia/Ulaanbaatar', + 'Asia/Urumqi', + 'Asia/Ust-Nera', + 'Asia/Vladivostok', + 'Asia/Yakutsk', + 'Asia/Yangon', + 'Asia/Yekaterinburg', + 'Asia/Yerevan', + 'Atlantic/Azores', + 'Atlantic/Bermuda', + 'Atlantic/Canary', + 'Atlantic/Cape_Verde', + 'Atlantic/Faroe', + 'Atlantic/Madeira', + 'Atlantic/South_Georgia', + 'Atlantic/Stanley', + 'Australia/Adelaide', + 'Australia/Brisbane', + 'Australia/Broken_Hill', + 'Australia/Darwin', + 'Australia/Eucla', + 'Australia/Hobart', + 'Australia/Lindeman', + 'Australia/Lord_Howe', + 'Australia/Melbourne', + 'Australia/Perth', + 'Australia/Sydney', + 'CET', + 'CST6CDT', + 'EET', + 'EST', + 'EST5EDT', + 'Etc/GMT', + 'Etc/GMT+1', + 'Etc/GMT+10', + 'Etc/GMT+11', + 'Etc/GMT+12', + 'Etc/GMT+2', + 'Etc/GMT+3', + 'Etc/GMT+4', + 'Etc/GMT+5', + 'Etc/GMT+6', + 'Etc/GMT+7', + 'Etc/GMT+8', + 'Etc/GMT+9', + 'Etc/GMT-1', + 'Etc/GMT-10', + 'Etc/GMT-11', + 'Etc/GMT-12', + 'Etc/GMT-13', + 'Etc/GMT-14', + 'Etc/GMT-2', + 'Etc/GMT-3', + 'Etc/GMT-4', + 'Etc/GMT-5', + 'Etc/GMT-6', + 'Etc/GMT-7', + 'Etc/GMT-8', + 'Etc/GMT-9', + 'Etc/UTC', + 'Europe/Andorra', + 'Europe/Astrakhan', + 'Europe/Athens', + 'Europe/Belgrade', + 'Europe/Berlin', + 'Europe/Brussels', + 'Europe/Bucharest', + 'Europe/Budapest', + 'Europe/Chisinau', + 'Europe/Dublin', + 'Europe/Gibraltar', + 'Europe/Helsinki', + 'Europe/Istanbul', + 'Europe/Kaliningrad', + 'Europe/Kirov', + 'Europe/Kyiv', + 'Europe/Lisbon', + 'Europe/London', + 'Europe/Madrid', + 'Europe/Malta', + 'Europe/Minsk', + 'Europe/Moscow', + 'Europe/Paris', + 'Europe/Prague', + 'Europe/Riga', + 'Europe/Rome', + 'Europe/Samara', + 'Europe/Saratov', + 'Europe/Simferopol', + 'Europe/Sofia', + 'Europe/Tallinn', + 'Europe/Tirane', + 'Europe/Ulyanovsk', + 'Europe/Vienna', + 'Europe/Vilnius', + 'Europe/Volgograd', + 'Europe/Warsaw', + 'Europe/Zurich', + 'HST', + 'Indian/Chagos', + 'Indian/Maldives', + 'Indian/Mauritius', + 'MET', + 'MST', + 'MST7MDT', + 'PST8PDT', + 'Pacific/Apia', + 'Pacific/Auckland', + 'Pacific/Bougainville', + 'Pacific/Chatham', + 'Pacific/Easter', + 'Pacific/Efate', + 'Pacific/Fakaofo', + 'Pacific/Fiji', + 'Pacific/Galapagos', + 'Pacific/Gambier', + 'Pacific/Guadalcanal', + 'Pacific/Guam', + 'Pacific/Honolulu', + 'Pacific/Kanton', + 'Pacific/Kiritimati', + 'Pacific/Kosrae', + 'Pacific/Kwajalein', + 'Pacific/Marquesas', + 'Pacific/Nauru', + 'Pacific/Niue', + 'Pacific/Norfolk', + 'Pacific/Noumea', + 'Pacific/Pago_Pago', + 'Pacific/Palau', + 'Pacific/Pitcairn', + 'Pacific/Port_Moresby', + 'Pacific/Rarotonga', + 'Pacific/Tahiti', + 'Pacific/Tarawa', + 'Pacific/Tongatapu', + + // IANA TZDB Link names + 'WET', + 'Africa/Accra', + 'Africa/Addis_Ababa', + 'Africa/Asmara', + 'Africa/Asmera', + 'Africa/Bamako', + 'Africa/Bangui', + 'Africa/Banjul', + 'Africa/Blantyre', + 'Africa/Brazzaville', + 'Africa/Bujumbura', + 'Africa/Conakry', + 'Africa/Dakar', + 'Africa/Dar_es_Salaam', + 'Africa/Djibouti', + 'Africa/Douala', + 'Africa/Freetown', + 'Africa/Gaborone', + 'Africa/Harare', + 'Africa/Kampala', + 'Africa/Kigali', + 'Africa/Kinshasa', + 'Africa/Libreville', + 'Africa/Lome', + 'Africa/Luanda', + 'Africa/Lubumbashi', + 'Africa/Lusaka', + 'Africa/Malabo', + 'Africa/Maseru', + 'Africa/Mbabane', + 'Africa/Mogadishu', + 'Africa/Niamey', + 'Africa/Nouakchott', + 'Africa/Ouagadougou', + 'Africa/Porto-Novo', + 'Africa/Timbuktu', + 'America/Anguilla', + 'America/Antigua', + 'America/Argentina/ComodRivadavia', + 'America/Aruba', + 'America/Atikokan', + 'America/Atka', + 'America/Blanc-Sablon', + 'America/Buenos_Aires', + 'America/Catamarca', + 'America/Cayman', + 'America/Coral_Harbour', + 'America/Cordoba', + 'America/Creston', + 'America/Curacao', + 'America/Dominica', + 'America/Ensenada', + 'America/Fort_Wayne', + 'America/Godthab', + 'America/Grenada', + 'America/Guadeloupe', + 'America/Indianapolis', + 'America/Jujuy', + 'America/Knox_IN', + 'America/Kralendijk', + 'America/Louisville', + 'America/Lower_Princes', + 'America/Marigot', + 'America/Mendoza', + 'America/Montreal', + 'America/Montserrat', + 'America/Nassau', + 'America/Nipigon', + 'America/Pangnirtung', + 'America/Port_of_Spain', + 'America/Porto_Acre', + 'America/Rainy_River', + 'America/Rosario', + 'America/Santa_Isabel', + 'America/Shiprock', + 'America/St_Barthelemy', + 'America/St_Kitts', + 'America/St_Lucia', + 'America/St_Thomas', + 'America/St_Vincent', + 'America/Thunder_Bay', + 'America/Tortola', + 'America/Virgin', + 'Antarctica/DumontDUrville', + 'Antarctica/McMurdo', + 'Antarctica/South_Pole', + 'Antarctica/Syowa', + 'Antarctica/Vostok', + 'Arctic/Longyearbyen', + 'Asia/Aden', + 'Asia/Ashkhabad', + 'Asia/Bahrain', + 'Asia/Brunei', + 'Asia/Calcutta', + 'Asia/Chongqing', + 'Asia/Chungking', + 'Asia/Dacca', + 'Asia/Harbin', + 'Asia/Istanbul', + 'Asia/Kashgar', + 'Asia/Katmandu', + 'Asia/Kuala_Lumpur', + 'Asia/Kuwait', + 'Asia/Macao', + 'Asia/Muscat', + 'Asia/Phnom_Penh', + 'Asia/Rangoon', + 'Asia/Saigon', + 'Asia/Tel_Aviv', + 'Asia/Thimbu', + 'Asia/Ujung_Pandang', + 'Asia/Ulan_Bator', + 'Asia/Vientiane', + 'Atlantic/Faeroe', + 'Atlantic/Jan_Mayen', + 'Atlantic/Reykjavik', + 'Atlantic/St_Helena', + 'Australia/ACT', + 'Australia/Canberra', + 'Australia/Currie', + 'Australia/LHI', + 'Australia/NSW', + 'Australia/North', + 'Australia/Queensland', + 'Australia/South', + 'Australia/Tasmania', + 'Australia/Victoria', + 'Australia/West', + 'Australia/Yancowinna', + 'Brazil/Acre', + 'Brazil/DeNoronha', + 'Brazil/East', + 'Brazil/West', + 'Canada/Atlantic', + 'Canada/Central', + 'Canada/Eastern', + 'Canada/Mountain', + 'Canada/Newfoundland', + 'Canada/Pacific', + 'Canada/Saskatchewan', + 'Canada/Yukon', + 'Chile/Continental', + 'Chile/EasterIsland', + 'Cuba', + 'Egypt', + 'Eire', + 'Etc/GMT+0', + 'Etc/GMT-0', + 'Etc/GMT0', + 'Etc/Greenwich', + 'Etc/UCT', + 'Etc/Universal', + 'Etc/Zulu', + 'Europe/Amsterdam', + 'Europe/Belfast', + 'Europe/Bratislava', + 'Europe/Busingen', + 'Europe/Copenhagen', + 'Europe/Guernsey', + 'Europe/Isle_of_Man', + 'Europe/Jersey', + 'Europe/Kiev', + 'Europe/Ljubljana', + 'Europe/Luxembourg', + 'Europe/Mariehamn', + 'Europe/Monaco', + 'Europe/Nicosia', + 'Europe/Oslo', + 'Europe/Podgorica', + 'Europe/San_Marino', + 'Europe/Sarajevo', + 'Europe/Skopje', + 'Europe/Stockholm', + 'Europe/Tiraspol', + 'Europe/Uzhgorod', + 'Europe/Vaduz', + 'Europe/Vatican', + 'Europe/Zagreb', + 'Europe/Zaporozhye', + 'GB', + 'GB-Eire', + 'GMT', + 'GMT+0', + 'GMT-0', + 'GMT0', + 'Greenwich', + 'Hongkong', + 'Iceland', + 'Indian/Antananarivo', + 'Indian/Christmas', + 'Indian/Cocos', + 'Indian/Comoro', + 'Indian/Kerguelen', + 'Indian/Mahe', + 'Indian/Mayotte', + 'Indian/Reunion', + 'Iran', + 'Israel', + 'Jamaica', + 'Japan', + 'Kwajalein', + 'Libya', + 'Mexico/BajaNorte', + 'Mexico/BajaSur', + 'Mexico/General', + 'NZ', + 'NZ-CHAT', + 'Navajo', + 'PRC', + 'Pacific/Chuuk', + 'Pacific/Enderbury', + 'Pacific/Funafuti', + 'Pacific/Johnston', + 'Pacific/Majuro', + 'Pacific/Midway', + 'Pacific/Pohnpei', + 'Pacific/Ponape', + 'Pacific/Saipan', + 'Pacific/Samoa', + 'Pacific/Truk', + 'Pacific/Wake', + 'Pacific/Wallis', + 'Pacific/Yap', + 'Poland', + 'Portugal', + 'ROC', + 'ROK', + 'Singapore', + 'Turkey', + 'UCT', + 'US/Alaska', + 'US/Aleutian', + 'US/Arizona', + 'US/Central', + 'US/East-Indiana', + 'US/Eastern', + 'US/Hawaii', + 'US/Indiana-Starke', + 'US/Michigan', + 'US/Mountain', + 'US/Pacific', + 'US/Pacific-New', + 'US/Samoa', + 'UTC', + 'Universal', + 'W-SU', + 'Zulu' +]; + +// We want to test all available named time zone identifiers (both primary and non-primary), +// but no ECMAScript built-in API exposes that list. So we use a union of two sources: +// 1. A hard-coded list of Zone and Link identifiers from the 2022g version of IANA TZDB. +// 2. Canonical IDs exposed by Intl.supportedValuesOf('timeZone'), which ensures that IDs +// added to TZDB later than 2022g will be tested. (New IDs are almost always added as primary.) +const ids = [...new Set([...timeZoneIdentifiers, ...Intl.supportedValuesOf('timeZone')])]; +for (const id of ids) { + const lower = id.toLowerCase(); + const upper = id.toUpperCase(); + assert.sameValue(new Temporal.ZonedDateTime(0n, id).timeZoneId, id, `Time zone created from string "${id}"`); + assert.sameValue(new Temporal.ZonedDateTime(0n, upper).timeZoneId, id, `Time zone created from string "${upper}"`); + assert.sameValue(new Temporal.ZonedDateTime(0n, lower).timeZoneId, id, `Time zone created from string "${lower}"`); +} diff --git a/test/intl402/Temporal/ZonedDateTime/timezone-ids-basic.js b/test/intl402/Temporal/ZonedDateTime/timezone-ids-basic.js new file mode 100644 index 00000000000..b461240f77a --- /dev/null +++ b/test/intl402/Temporal/ZonedDateTime/timezone-ids-basic.js @@ -0,0 +1,29 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.zoneddatetime +description: Basic tests for time zone IDs +features: [Temporal] +---*/ + +const valid = [ + ["Europe/Vienna"], + ["America/New_York"], + ["Africa/CAIRO", "Africa/Cairo"], + ["africa/cairo", "Africa/Cairo"], + ["Asia/Ulaanbaatar"], + ["Asia/Ulan_Bator"], + ["UTC"], + ["GMT"] +]; +for (const [zone, id = zone] of valid) { + const result = new Temporal.ZonedDateTime(0n, zone); + assert.sameValue(typeof result, "object", `object should be created for ${zone}`); + assert.sameValue(result.timeZoneId, id, `id for ${zone} should be ${id}`); +} + +const invalid = ["+00:01.1", "-01.1"]; +for (const zone of invalid) { + assert.throws(RangeError, () => new Temporal.ZonedDateTime(0n, zone), `should throw for ${zone}`); +} diff --git a/test/staging/Temporal/ZonedDateTime/old/dst-math.js b/test/staging/Intl402/Temporal/old/dst-math.js similarity index 93% rename from test/staging/Temporal/ZonedDateTime/old/dst-math.js rename to test/staging/Intl402/Temporal/old/dst-math.js index d6bd41c2541..fa74273d518 100644 --- a/test/staging/Temporal/ZonedDateTime/old/dst-math.js +++ b/test/staging/Intl402/Temporal/old/dst-math.js @@ -4,13 +4,11 @@ /*--- esid: sec-temporal-zoneddatetime-objects description: math around DST -includes: [temporalHelpers.js] features: [Temporal] ---*/ -var tz = TemporalHelpers.springForwardFallBackTimeZone(); -var hourBeforeDstStart = new Temporal.PlainDateTime(2000, 4, 2, 1).toZonedDateTime(tz); -var dayBeforeDstStart = new Temporal.PlainDateTime(2000, 4, 1, 2, 30).toZonedDateTime(tz); +var hourBeforeDstStart = new Temporal.PlainDateTime(2000, 4, 2, 1).toZonedDateTime("America/Vancouver"); +var dayBeforeDstStart = new Temporal.PlainDateTime(2000, 4, 1, 2, 30).toZonedDateTime("America/Vancouver"); // add 1 hour to get to DST start var added = hourBeforeDstStart.add({ hours: 1 }); @@ -44,9 +42,7 @@ var undo = added.subtract(diff); assert.sameValue(`${ undo }`, `${ hourBeforeDstStart }`); // Samoa date line change (add): 10:00PM 29 Dec 2011 -> 11:00PM 31 Dec 2011 -var timeZone = TemporalHelpers.crossDateLineTimeZone(); -var dayBeforeSamoaDateLineChangeAbs = timeZone.getInstantFor(new Temporal.PlainDateTime(2011, 12, 29, 22)); -var start = dayBeforeSamoaDateLineChangeAbs.toZonedDateTimeISO(timeZone); +var start = new Temporal.PlainDateTime(2011, 12, 29, 22).toZonedDateTime("Pacific/Apia"); var added = start.add({ days: 1, hours: 1 @@ -60,8 +56,7 @@ var undo = added.subtract(diff); assert.sameValue(`${ undo }`, `${ start }`); // Samoa date line change (subtract): 11:00PM 31 Dec 2011 -> 10:00PM 29 Dec 2011 -var dayAfterSamoaDateLineChangeAbs = timeZone.getInstantFor(new Temporal.PlainDateTime(2011, 12, 31, 23)); -var start = dayAfterSamoaDateLineChangeAbs.toZonedDateTimeISO(timeZone); +var start = new Temporal.PlainDateTime(2011, 12, 31, 23).toZonedDateTime("Pacific/Apia"); var skipped = start.subtract({ days: 1, hours: 1 @@ -147,16 +142,16 @@ var undo = added.subtract(diff); assert.sameValue(`${ undo }`, `${ start }`); // Difference can return day length > 24 hours -var start = Temporal.PlainDateTime.from("2000-10-27T01:45").toZonedDateTime(tz); -var end = Temporal.PlainDateTime.from("2000-10-30T01:15").toZonedDateTime(tz); +var start = Temporal.PlainDateTime.from("2000-10-27T01:45").toZonedDateTime("America/Vancouver"); +var end = Temporal.PlainDateTime.from("2000-10-30T01:15").toZonedDateTime("America/Vancouver"); var diff = start.until(end, { largestUnit: "days" }); assert.sameValue(`${ diff }`, "P2DT24H30M"); var undo = start.add(diff); assert.sameValue(`${ undo }`, `${ end }`); // Difference rounding (nearest day) is DST-aware -var start = Temporal.PlainDateTime.from("2000-04-04T02:30").toZonedDateTime(tz); -var end = Temporal.PlainDateTime.from("2000-04-01T14:15").toZonedDateTime(tz); +var start = Temporal.PlainDateTime.from("2000-04-04T02:30").toZonedDateTime("America/Vancouver"); +var end = Temporal.PlainDateTime.from("2000-04-01T14:15").toZonedDateTime("America/Vancouver"); var diff = start.until(end, { smallestUnit: "days", roundingMode: "halfExpand" @@ -217,14 +212,14 @@ var diff = start.until(end, { assert.sameValue(`${ diff }`, "-P2DT13H"); // Difference when date portion ends inside a DST-skipped period -var start = Temporal.PlainDateTime.from("2000-04-01T02:30").toZonedDateTime(tz); -var end = Temporal.PlainDateTime.from("2000-04-02T03:15").toZonedDateTime(tz); +var start = Temporal.PlainDateTime.from("2000-04-01T02:30").toZonedDateTime("America/Vancouver"); +var end = Temporal.PlainDateTime.from("2000-04-02T03:15").toZonedDateTime("America/Vancouver"); var diff = start.until(end, { largestUnit: "days" }); assert.sameValue(`${ diff }`, "PT23H45M"); // Difference when date portion ends inside day skipped by Samoa's 24hr 2011 transition -var end = Temporal.PlainDateTime.from("2011-12-31T05:00").toZonedDateTime(timeZone); -var start = Temporal.PlainDateTime.from("2011-12-28T10:00").toZonedDateTime(timeZone); +var end = Temporal.PlainDateTime.from("2011-12-31T05:00").toZonedDateTime("Pacific/Apia"); +var start = Temporal.PlainDateTime.from("2011-12-28T10:00").toZonedDateTime("Pacific/Apia"); var diff = start.until(end, { largestUnit: "days" }); assert.sameValue(`${ diff }`, "P1DT19H"); diff --git a/test/staging/Temporal/ZonedDateTime/old/dst-properties.js b/test/staging/Intl402/Temporal/old/dst-properties.js similarity index 82% rename from test/staging/Temporal/ZonedDateTime/old/dst-properties.js rename to test/staging/Intl402/Temporal/old/dst-properties.js index ed79987dc95..622fa0613a7 100644 --- a/test/staging/Temporal/ZonedDateTime/old/dst-properties.js +++ b/test/staging/Intl402/Temporal/old/dst-properties.js @@ -4,13 +4,11 @@ /*--- esid: sec-temporal-zoneddatetime-objects description: properties around DST -includes: [temporalHelpers.js] features: [Temporal] ---*/ -var tz = TemporalHelpers.springForwardFallBackTimeZone(); -var hourBeforeDstStart = new Temporal.PlainDateTime(2000, 4, 2, 1).toZonedDateTime(tz); -var dayBeforeDstStart = new Temporal.PlainDateTime(2000, 4, 1, 2, 30).toZonedDateTime(tz); +var hourBeforeDstStart = new Temporal.PlainDateTime(2000, 4, 2, 1).toZonedDateTime("America/Vancouver"); +var dayBeforeDstStart = new Temporal.PlainDateTime(2000, 4, 1, 2, 30).toZonedDateTime("America/Vancouver"); // hoursInDay works with DST start assert.sameValue(hourBeforeDstStart.hoursInDay, 23); @@ -19,7 +17,7 @@ assert.sameValue(hourBeforeDstStart.hoursInDay, 23); assert.sameValue(dayBeforeDstStart.hoursInDay, 24); // hoursInDay works with DST end -var dstEnd = Temporal.PlainDateTime.from("2000-10-29T01:00").toZonedDateTime(tz); +var dstEnd = Temporal.PlainDateTime.from("2000-10-29T01:00").toZonedDateTime("America/Vancouver"); assert.sameValue(dstEnd.hoursInDay, 25); // startOfDay works @@ -27,9 +25,8 @@ var start = dayBeforeDstStart.startOfDay(); assert.sameValue(`${ start.toPlainDate() }`, `${ dayBeforeDstStart.toPlainDate() }`); assert.sameValue(`${ start.toPlainTime() }`, "00:00:00"); -var samoa = TemporalHelpers.crossDateLineTimeZone(); -var dayAfterSamoaDateLineChange = Temporal.PlainDateTime.from("2011-12-31T22:00").toZonedDateTime(samoa); -var dayBeforeSamoaDateLineChange = Temporal.PlainDateTime.from("2011-12-29T22:00").toZonedDateTime(samoa); +var dayAfterSamoaDateLineChange = Temporal.PlainDateTime.from("2011-12-31T22:00").toZonedDateTime("Pacific/Apia"); +var dayBeforeSamoaDateLineChange = Temporal.PlainDateTime.from("2011-12-29T22:00").toZonedDateTime("Pacific/Apia"); // startOfDay works after Samoa date line change var start = dayAfterSamoaDateLineChange.startOfDay(); diff --git a/test/staging/Intl402/Temporal/old/duration-round.js b/test/staging/Intl402/Temporal/old/duration-round.js new file mode 100644 index 00000000000..0b095a7bc04 --- /dev/null +++ b/test/staging/Intl402/Temporal/old/duration-round.js @@ -0,0 +1,155 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal-duration-objects +description: Temporal.Duration.prototype.round() works as expected +features: [Temporal] +---*/ + +// relativeTo affects days if ZonedDateTime, and duration encompasses DST change +var timeZone = "America/Vancouver"; +var skippedHourDay = Temporal.PlainDateTime.from("2000-04-02").toZonedDateTime(timeZone); +var repeatedHourDay = Temporal.PlainDateTime.from("2000-10-29").toZonedDateTime(timeZone); +var inRepeatedHour = new Temporal.ZonedDateTime(972806400_000_000_000n, timeZone); +var oneDay = new Temporal.Duration(0, 0, 0, 1); +var hours12 = new Temporal.Duration(0, 0, 0, 0, 12); +var hours25 = new Temporal.Duration(0, 0, 0, 0, 25); + +// start inside repeated hour, end after +assert.sameValue(`${ hours25.round({ + largestUnit: "days", + relativeTo: inRepeatedHour +}) }`, "P1D"); +assert.sameValue(`${ oneDay.round({ + largestUnit: "hours", + relativeTo: inRepeatedHour +}) }`, "PT25H"); + +// start after repeated hour, end inside (negative) +var relativeTo = Temporal.PlainDateTime.from("2000-10-30T01:00").toZonedDateTime(timeZone); +assert.sameValue(`${ hours25.negated().round({ + largestUnit: "days", + relativeTo +}) }`, "-P1D"); +assert.sameValue(`${ oneDay.negated().round({ + largestUnit: "hours", + relativeTo +}) }`, "-PT25H"); + +// start inside repeated hour, end in skipped hour +assert.sameValue(`${ Temporal.Duration.from({ + days: 126, + hours: 1 +}).round({ + largestUnit: "days", + relativeTo: inRepeatedHour +}) }`, "P126DT1H"); +assert.sameValue(`${ Temporal.Duration.from({ + days: 126, + hours: 1 +}).round({ + largestUnit: "hours", + relativeTo: inRepeatedHour +}) }`, "PT3026H"); + +// start in normal hour, end in skipped hour +var relativeTo = Temporal.PlainDateTime.from("2000-04-01T02:30").toZonedDateTime(timeZone); +assert.sameValue(`${ hours25.round({ + largestUnit: "days", + relativeTo +}) }`, "P1DT1H"); +assert.sameValue(`${ oneDay.round({ + largestUnit: "hours", + relativeTo +}) }`, "PT24H"); + +// start before skipped hour, end >1 day after +assert.sameValue(`${ hours25.round({ + largestUnit: "days", + relativeTo: skippedHourDay +}) }`, "P1DT2H"); +assert.sameValue(`${ oneDay.round({ + largestUnit: "hours", + relativeTo: skippedHourDay +}) }`, "PT23H"); + +// start after skipped hour, end >1 day before (negative) +var relativeTo = Temporal.PlainDateTime.from("2000-04-03T00:00").toZonedDateTime(timeZone); +assert.sameValue(`${ hours25.negated().round({ + largestUnit: "days", + relativeTo +}) }`, "-P1DT2H"); +assert.sameValue(`${ oneDay.negated().round({ + largestUnit: "hours", + relativeTo +}) }`, "-PT23H"); + +// start before skipped hour, end <1 day after +assert.sameValue(`${ hours12.round({ + largestUnit: "days", + relativeTo: skippedHourDay +}) }`, "PT12H"); + +// start after skipped hour, end <1 day before (negative) +var relativeTo = Temporal.PlainDateTime.from("2000-04-02T12:00").toZonedDateTime(timeZone); +assert.sameValue(`${ hours12.negated().round({ + largestUnit: "days", + relativeTo +}) }`, "-PT12H"); + +// start before repeated hour, end >1 day after +assert.sameValue(`${ hours25.round({ + largestUnit: "days", + relativeTo: repeatedHourDay +}) }`, "P1D"); +assert.sameValue(`${ oneDay.round({ + largestUnit: "hours", + relativeTo: repeatedHourDay +}) }`, "PT25H"); + +// start after repeated hour, end >1 day before (negative) +var relativeTo = Temporal.PlainDateTime.from("2000-10-30T00:00").toZonedDateTime(timeZone); +assert.sameValue(`${ hours25.negated().round({ + largestUnit: "days", + relativeTo +}) }`, "-P1D"); +assert.sameValue(`${ oneDay.negated().round({ + largestUnit: "hours", + relativeTo +}) }`, "-PT25H"); + +// start before repeated hour, end <1 day after +assert.sameValue(`${ hours12.round({ + largestUnit: "days", + relativeTo: repeatedHourDay +}) }`, "PT12H"); + +// start after repeated hour, end <1 day before (negative) +var relativeTo = Temporal.PlainDateTime.from("2000-10-29T12:00").toZonedDateTime(timeZone); +assert.sameValue(`${ hours12.negated().round({ + largestUnit: "days", + relativeTo +}) }`, "-PT12H"); + +// Samoa skipped 24 hours +var relativeTo = Temporal.PlainDateTime.from("2011-12-29T12:00").toZonedDateTime("Pacific/Apia"); +assert.sameValue(`${ hours25.round({ + largestUnit: "days", + relativeTo +}) }`, "P2DT1H"); +assert.sameValue(`${ Temporal.Duration.from({ hours: 48 }).round({ + largestUnit: "days", + relativeTo +}) }`, "P3D"); + +// casts relativeTo to ZonedDateTime if possible +assert.sameValue(`${ hours25.round({ + largestUnit: "days", + relativeTo: { + year: 2000, + month: 10, + day: 29, + timeZone + } +}) }`, "P1D"); diff --git a/test/staging/Intl402/Temporal/old/duration-total.js b/test/staging/Intl402/Temporal/old/duration-total.js new file mode 100644 index 00000000000..bb3da742d35 --- /dev/null +++ b/test/staging/Intl402/Temporal/old/duration-total.js @@ -0,0 +1,42 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal-duration-objects +description: Temporal.Duration.prototype.total() +features: [Temporal] +---*/ + +var oneDay = new Temporal.Duration(0, 0, 0, 1); +var hours25 = new Temporal.Duration(0, 0, 0, 0, 25); + +// Samoa skipped 24 hours +var relativeTo = Temporal.PlainDateTime.from("2011-12-29T12:00").toZonedDateTime("Pacific/Apia"); +var totalDays = hours25.total({ + unit: "days", + relativeTo +}); +assert(Math.abs(totalDays - (2 + 1 / 24)) < Number.EPSILON); +assert.sameValue(Temporal.Duration.from({ hours: 48 }).total({ + unit: "days", + relativeTo +}), 3); +assert.sameValue(Temporal.Duration.from({ days: 2 }).total({ + unit: "hours", + relativeTo +}), 24); +assert.sameValue(Temporal.Duration.from({ days: 3 }).total({ + unit: "hours", + relativeTo +}), 48); + +// casts relativeTo to ZonedDateTime if possible +assert.sameValue(oneDay.total({ + unit: "hours", + relativeTo: { + year: 2000, + month: 10, + day: 29, + timeZone: "America/Vancouver" + } +}), 25); diff --git a/test/staging/Intl402/Temporal/old/islamic-calendars.js b/test/staging/Intl402/Temporal/old/islamic-calendars.js index 47bad664c25..dc68093b251 100644 --- a/test/staging/Intl402/Temporal/old/islamic-calendars.js +++ b/test/staging/Intl402/Temporal/old/islamic-calendars.js @@ -15,53 +15,42 @@ const tests = [ inLeapYear: false, daysInYear: 354, daysInMonth12: 29, - isoYear: 2023, - isoMonth: 7, - isoDay: 18 + isoDate: "2023-07-18", }, { calendar: "islamic-umalqura", inLeapYear: false, daysInYear: 354, daysInMonth12: 30, - isoYear: 2023, - isoMonth: 7, - isoDay: 19 + isoDate: "2023-07-19", }, { calendar: "islamic-civil", inLeapYear: true, daysInYear: 355, daysInMonth12: 30, - isoYear: 2023, - isoMonth: 7, - isoDay: 19 + isoDate: "2023-07-19", }, { calendar: "islamic-rgsa", inLeapYear: false, daysInYear: 354, daysInMonth12: 29, - isoYear: 2023, - isoMonth: 7, - isoDay: 18 + isoDate: "2023-07-18", }, { calendar: "islamic-tbla", inLeapYear: true, daysInYear: 355, daysInMonth12: 30, - isoYear: 2023, - isoMonth: 7, - isoDay: 18 + isoDate: "2023-07-18", } ]; for (const test of tests) { - const { calendar, inLeapYear, daysInYear, daysInMonth12, isoYear, isoMonth, isoDay } = test; + const { calendar, inLeapYear, daysInYear, daysInMonth12, isoDate } = test; const year = 1445; const date = Temporal.PlainDate.from({ year, month: 1, day: 1, calendar }); - const isoFields = date.getISOFields(); assert.sameValue(date.calendarId, calendar); assert.sameValue(date.year, year); assert.sameValue(date.month, 1); @@ -76,7 +65,5 @@ for (const test of tests) { assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear); const dateMonth12 = date.with({ month: 12 }); assert.sameValue(dateMonth12.daysInMonth, daysInMonth12); - assert.sameValue(isoYear, isoFields.isoYear); - assert.sameValue(isoMonth, isoFields.isoMonth); - assert.sameValue(isoDay, isoFields.isoDay); + assert.sameValue(date.toString(), `${isoDate}[u-ca=${calendar}]`, "ISO reference date"); } diff --git a/test/staging/Intl402/Temporal/old/persian-calendar.js b/test/staging/Intl402/Temporal/old/persian-calendar.js index 189ccc994c8..a5020f4b54e 100644 --- a/test/staging/Intl402/Temporal/old/persian-calendar.js +++ b/test/staging/Intl402/Temporal/old/persian-calendar.js @@ -15,61 +15,48 @@ const tests = [ inLeapYear: true, daysInYear: 366, daysInMonth12: 30, - isoYear: 2016, - isoMonth: 3, - isoDay: 20 + isoDate: "2016-03-20", }, { testYear: 1396, inLeapYear: false, daysInYear: 365, daysInMonth12: 29, - isoYear: 2017, - isoMonth: 3, - isoDay: 21 + isoDate: "2017-03-21", }, { testYear: 1397, inLeapYear: false, daysInYear: 365, daysInMonth12: 29, - isoYear: 2018, - isoMonth: 3, - isoDay: 21 + isoDate: "2018-03-21", }, { testYear: 1398, inLeapYear: false, daysInYear: 365, daysInMonth12: 29, - isoYear: 2019, - isoMonth: 3, - isoDay: 21 + isoDate: "2019-03-21", }, { testYear: 1399, inLeapYear: true, daysInYear: 366, daysInMonth12: 30, - isoYear: 2020, - isoMonth: 3, - isoDay: 20 + isoDate: "2020-03-20", }, { testYear: 1400, inLeapYear: false, daysInYear: 365, daysInMonth12: 29, - isoYear: 2021, - isoMonth: 3, - isoDay: 21 + isoDate: "2021-03-21", } ]; for (const test of tests) { - const { testYear, inLeapYear, daysInYear, daysInMonth12, isoYear, isoMonth, isoDay } = test; + const { testYear, inLeapYear, daysInYear, daysInMonth12, isoDate } = test; const date = Temporal.PlainDate.from({ year: testYear, month: 1, day: 1, calendar: "persian" }); - const isoFields = date.getISOFields(); assert.sameValue(date.calendarId, "persian"); assert.sameValue(date.year, testYear); assert.sameValue(date.month, 1); @@ -84,7 +71,5 @@ for (const test of tests) { assert.sameValue(lastDayOfThisYear.dayOfYear, daysInYear); const dateMonth12 = date.with({ month: 12 }); assert.sameValue(dateMonth12.daysInMonth, daysInMonth12); - assert.sameValue(isoYear, isoFields.isoYear); - assert.sameValue(isoMonth, isoFields.isoMonth); - assert.sameValue(isoDay, isoFields.isoDay); + assert.sameValue(date.toString(), `${isoDate}[u-ca=persian]`, "ISO reference date"); } diff --git a/test/staging/Intl402/Temporal/old/property-bags.js b/test/staging/Intl402/Temporal/old/property-bags.js new file mode 100644 index 00000000000..38d26f49f46 --- /dev/null +++ b/test/staging/Intl402/Temporal/old/property-bags.js @@ -0,0 +1,154 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal-zoneddatetime-objects +description: property bags +features: [Temporal] +---*/ + +var date = { + year: 2000, + month: 10, + day: 29, + timeZone: "America/Vancouver" +}; +// { offset: 'prefer' } if offset matches time zone (first 1:30 when DST ends) +var obj = { + ...date, + hour: 1, + minute: 30, + offset: "-07:00" +}; +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "prefer" }) }`, "2000-10-29T01:30:00-07:00[America/Vancouver]"); + +// { offset: 'prefer' } if offset matches time zone (second 1:30 when DST ends) +var obj = { + ...date, + hour: 1, + minute: 30, + offset: "-08:00" +}; +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "prefer" }) }`, "2000-10-29T01:30:00-08:00[America/Vancouver]"); + +// { offset: 'prefer' } if offset does not match time zone" +var obj = { + ...date, + hour: 4, + offset: "-07:00" +}; +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "prefer" }) }`, "2000-10-29T04:00:00-08:00[America/Vancouver]"); + +// { offset: 'ignore' } uses time zone only +var obj = { + ...date, + hour: 4, + offset: "-12:00" +}; +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "ignore" }) }`, "2000-10-29T04:00:00-08:00[America/Vancouver]"); + +// { offset: 'use' } uses offset only +var obj = { + ...date, + hour: 4, + offset: "-07:00" +}; +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "use" }) }`, "2000-10-29T03:00:00-08:00[America/Vancouver]"); + +// Disambiguation options + +// plain datetime with multiple instants - Fall DST +var obj = { + year: 2000, + month: 10, + day: 29, + hour: 1, + minute: 45, + timeZone: "America/Vancouver" +}; +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj) }`, "2000-10-29T01:45:00-07:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "compatible" }) }`, "2000-10-29T01:45:00-07:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "earlier" }) }`, "2000-10-29T01:45:00-07:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "later" }) }`, "2000-10-29T01:45:00-08:00[America/Vancouver]"); +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { disambiguation: "reject" })); + +// plain datetime with multiple instants - Spring DST +var obj = { + year: 2000, + month: 4, + day: 2, + hour: 2, + minute: 30, + timeZone: "America/Vancouver" +}; +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj) }`, "2000-04-02T03:30:00-07:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "compatible" }) }`, "2000-04-02T03:30:00-07:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "earlier" }) }`, "2000-04-02T01:30:00-08:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "later" }) }`, "2000-04-02T03:30:00-07:00[America/Vancouver]"); +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { disambiguation: "reject" })); + +// uses disambiguation if offset is ignored +var obj = { + year: 2000, + month: 4, + day: 2, + hour: 2, + minute: 30, + timeZone: "America/Vancouver" +}; +var offset = "ignore"; +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset }) }`, "2000-04-02T03:30:00-07:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { + offset, + disambiguation: "compatible" +}) }`, "2000-04-02T03:30:00-07:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { + offset, + disambiguation: "earlier" +}) }`, "2000-04-02T01:30:00-08:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { + offset, + disambiguation: "later" +}) }`, "2000-04-02T03:30:00-07:00[America/Vancouver]"); +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { disambiguation: "reject" })); + +// uses disambiguation if offset is wrong and option is prefer +var obj = { + year: 2000, + month: 4, + day: 2, + hour: 2, + minute: 30, + offset: "-23:59", + timeZone: "America/Vancouver" +}; +var offset = "prefer"; +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset }) }`, "2000-04-02T03:30:00-07:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { + offset, + disambiguation: "compatible" +}) }`, "2000-04-02T03:30:00-07:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { + offset, + disambiguation: "earlier" +}) }`, "2000-04-02T01:30:00-08:00[America/Vancouver]"); +assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { + offset, + disambiguation: "later" +}) }`, "2000-04-02T03:30:00-07:00[America/Vancouver]"); +assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { + offset, + disambiguation: "reject" +})); + +// sub-minute time zone offsets + +// does not truncate offset property to minutes +var zdt = Temporal.ZonedDateTime.from({ + year: 1971, + month: 1, + day: 1, + hour: 12, + timeZone: "Africa/Monrovia" +}); +assert.sameValue(zdt.offset, "-00:44:30"); diff --git a/test/staging/Intl402/Temporal/old/timezone-america-la.js b/test/staging/Intl402/Temporal/old/timezone-america-la.js deleted file mode 100644 index 5ed6a2b3adf..00000000000 --- a/test/staging/Intl402/Temporal/old/timezone-america-la.js +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: America/Los_Angeles -features: [Temporal] ----*/ - -var zone = new Temporal.TimeZone("America/Los_Angeles"); -var inst = new Temporal.Instant(0n); -var dtm = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789); -assert.sameValue(zone.id, `${ zone }`) -assert.sameValue(zone.getOffsetNanosecondsFor(inst), -8 * 3600000000000) -assert.sameValue(zone.getOffsetStringFor(inst), "-08:00") -assert(zone.getInstantFor(dtm) instanceof Temporal.Instant) -for (var i = 0, txn = inst; i < 4; i++) { - var transition = zone.getNextTransition(txn); - assert(transition instanceof Temporal.Instant); - assert(!transition.equals(txn)); - txn = transition; -} -for (var i = 0, txn = inst; i < 4; i++) { - var transition = zone.getPreviousTransition(txn); - assert(transition instanceof Temporal.Instant); - assert(!transition.equals(txn)); - txn = transition; -} diff --git a/test/staging/Intl402/Temporal/old/tzdb-transitions.js b/test/staging/Intl402/Temporal/old/tzdb-transitions.js deleted file mode 100644 index 441de4e29ab..00000000000 --- a/test/staging/Intl402/Temporal/old/tzdb-transitions.js +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: Tests that are impractical to do without a TZDB -features: [Temporal] ----*/ - -// getNextTransition() - -var nyc = Temporal.TimeZone.from("America/New_York"); - -// should not have bug #510 -var a1 = Temporal.Instant.from("2019-04-16T21:01Z"); -var a2 = Temporal.Instant.from("1800-01-01T00:00Z"); -assert.sameValue(nyc.getNextTransition(a1).toString(), "2019-11-03T06:00:00Z"); -assert.sameValue(nyc.getNextTransition(a2).toString(), "1883-11-18T17:00:00Z"); - -// should not return the same as its input if the input is a transition point -var inst = Temporal.Instant.from("2019-01-01T00:00Z"); -assert.sameValue(`${ nyc.getNextTransition(inst) }`, "2019-03-10T07:00:00Z"); -assert.sameValue(`${ nyc.getNextTransition(nyc.getNextTransition(inst)) }`, "2019-11-03T06:00:00Z"); - -// casts argument -assert.sameValue(`${ nyc.getNextTransition("2019-04-16T21:01Z") }`, "2019-11-03T06:00:00Z"); - -// getPreviousTransition() - -var london = Temporal.TimeZone.from("Europe/London"); - -// should return first and last transition -var a1 = Temporal.Instant.from("2020-06-11T21:01Z"); -var a2 = Temporal.Instant.from("1848-01-01T00:00Z"); -assert.sameValue(london.getPreviousTransition(a1).toString(), "2020-03-29T01:00:00Z"); -assert.sameValue(london.getPreviousTransition(a2).toString(), "1847-12-01T00:01:15Z"); - -// should not return the same as its input if the input is a transition point -var inst = Temporal.Instant.from("2020-06-01T00:00Z"); -assert.sameValue(`${ london.getPreviousTransition(inst) }`, "2020-03-29T01:00:00Z"); -assert.sameValue(`${ london.getPreviousTransition(london.getPreviousTransition(inst)) }`, "2019-10-27T01:00:00Z"); - -// casts argument -assert.sameValue(`${ london.getPreviousTransition("2020-06-11T21:01Z") }`, "2020-03-29T01:00:00Z"); diff --git a/test/staging/Intl402/Temporal/old/zdt-round.js b/test/staging/Intl402/Temporal/old/zdt-round.js new file mode 100644 index 00000000000..209fcd6d33b --- /dev/null +++ b/test/staging/Intl402/Temporal/old/zdt-round.js @@ -0,0 +1,33 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal-zoneddatetime-objects +description: Temporal.ZonedDateTime.prototype.round() +features: [Temporal] +---*/ + +// rounds correctly to a 25-hour day +// (the 12.5 hour is the halfway point, which is 11:30 local time, since 2:00-2:59 repeats) +var roundTo = { smallestUnit: "day" }; +var roundMeDown = Temporal.PlainDateTime.from("2000-10-29T11:29:59").toZonedDateTime("America/Vancouver"); +assert.sameValue(`${ roundMeDown.round(roundTo) }`, "2000-10-29T00:00:00-07:00[America/Vancouver]"); +var roundMeUp = Temporal.PlainDateTime.from("2000-10-29T11:30:01").toZonedDateTime("America/Vancouver"); +assert.sameValue(`${ roundMeUp.round(roundTo) }`, "2000-10-30T00:00:00-08:00[America/Vancouver]"); + +// rounds correctly to a 23-hour day +// (the 11.5 hour is the halfway point, which is 12:30 local time, since 2:00-2:59 skips) +var roundTo = { smallestUnit: "day" }; +var roundMeDown = Temporal.PlainDateTime.from("2000-04-02T12:29:59").toZonedDateTime("America/Vancouver"); +assert.sameValue(`${ roundMeDown.round(roundTo) }`, "2000-04-02T00:00:00-08:00[America/Vancouver]"); +var roundMeUp = Temporal.PlainDateTime.from("2000-04-02T12:30:01").toZonedDateTime("America/Vancouver"); +assert.sameValue(`${ roundMeUp.round(roundTo) }`, "2000-04-03T00:00:00-07:00[America/Vancouver]"); + +// rounding up to a nonexistent wall-clock time +var almostSkipped = Temporal.PlainDateTime.from("2000-04-02T01:59:59.999999999").toZonedDateTime("America/Vancouver"); +var rounded = almostSkipped.round({ + smallestUnit: "microsecond", + roundingMode: "halfExpand" +}); +assert.sameValue(`${ rounded }`, "2000-04-02T03:00:00-07:00[America/Vancouver]"); +assert.sameValue(rounded.epochNanoseconds - almostSkipped.epochNanoseconds, 1n); diff --git a/test/staging/Intl402/Temporal/old/zdt-tostring.js b/test/staging/Intl402/Temporal/old/zdt-tostring.js new file mode 100644 index 00000000000..ef76fa65d04 --- /dev/null +++ b/test/staging/Intl402/Temporal/old/zdt-tostring.js @@ -0,0 +1,40 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal-zoneddatetime-objects +description: Temporal.ZonedDateTime.prototype.toString() +features: [Temporal] +---*/ + +var zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]"); + +// combinations of calendar, time zone, and offset +var zdt = zdt1.withCalendar("gregory"); +assert.sameValue(zdt.toString({ + timeZoneName: "never", + calendarName: "never" +}), "1976-11-18T15:23:00+00:00"); +assert.sameValue(zdt.toString({ + offset: "never", + calendarName: "never" +}), "1976-11-18T15:23:00[UTC]"); +assert.sameValue(zdt.toString({ + offset: "never", + timeZoneName: "never" +}), "1976-11-18T15:23:00[u-ca=gregory]"); +assert.sameValue(zdt.toString({ + offset: "never", + timeZoneName: "never", + calendarName: "never" +}), "1976-11-18T15:23:00"); + +// rounding up to a nonexistent wall-clock time +var zdt5 = Temporal.PlainDateTime.from("2000-04-02T01:59:59.999999999").toZonedDateTime("America/Vancouver"); +var roundedString = zdt5.toString({ + fractionalSecondDigits: 8, + roundingMode: "halfExpand" +}); +assert.sameValue(roundedString, "2000-04-02T03:00:00.00000000-07:00[America/Vancouver]"); +var zdt6 = Temporal.Instant.from(roundedString); +assert.sameValue(zdt6.epochNanoseconds - zdt5.epochNanoseconds, 1n); diff --git a/test/staging/Intl402/Temporal/old/zdt-with.js b/test/staging/Intl402/Temporal/old/zdt-with.js new file mode 100644 index 00000000000..9a770faa72d --- /dev/null +++ b/test/staging/Intl402/Temporal/old/zdt-with.js @@ -0,0 +1,155 @@ +// Copyright (C) 2018 Bloomberg LP. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal-zoneddatetime-objects +description: Temporal.ZonedDateTime.prototype.with() +features: [Temporal] +---*/ + +var dstStartDay = Temporal.PlainDateTime.from("2000-04-02T12:00:01").toZonedDateTime("America/Vancouver"); +var dstEndDay = Temporal.PlainDateTime.from("2000-10-29T12:00:01").toZonedDateTime("America/Vancouver"); +var oneThirty = { + hour: 1, + minute: 30 +}; +var twoThirty = { + hour: 2, + minute: 30 +}; + +// Disambiguation options +var offset = "ignore"; +// compatible, skipped wall time +assert.sameValue(`${ dstStartDay.with(twoThirty, { + offset, + disambiguation: "compatible" +}) }`, "2000-04-02T03:30:01-07:00[America/Vancouver]"); + +// earlier, skipped wall time +assert.sameValue(`${ dstStartDay.with(twoThirty, { + offset, + disambiguation: "earlier" +}) }`, "2000-04-02T01:30:01-08:00[America/Vancouver]"); + +// later, skipped wall time +assert.sameValue(`${ dstStartDay.with(twoThirty, { + offset, + disambiguation: "later" +}) }`, "2000-04-02T03:30:01-07:00[America/Vancouver]"); + +// compatible, repeated wall time +assert.sameValue(`${ dstEndDay.with(oneThirty, { + offset, + disambiguation: "compatible" +}) }`, "2000-10-29T01:30:01-07:00[America/Vancouver]"); + +// earlier, repeated wall time +assert.sameValue(`${ dstEndDay.with(oneThirty, { + offset, + disambiguation: "earlier" +}) }`, "2000-10-29T01:30:01-07:00[America/Vancouver]"); + +// later, repeated wall time +assert.sameValue(`${ dstEndDay.with(oneThirty, { + offset, + disambiguation: "later" +}) }`, "2000-10-29T01:30:01-08:00[America/Vancouver]"); + +// reject +assert.throws(RangeError, () => dstStartDay.with(twoThirty, { + offset, + disambiguation: "reject" +})); +assert.throws(RangeError, () => dstEndDay.with(oneThirty, { + offset, + disambiguation: "reject" +})); + +// compatible is the default +assert.sameValue(`${ dstStartDay.with(twoThirty, { offset }) }`, `${ dstStartDay.with(twoThirty, { + offset, + disambiguation: "compatible" +}) }`); +assert.sameValue(`${ dstEndDay.with(twoThirty, { offset }) }`, `${ dstEndDay.with(twoThirty, { + offset, + disambiguation: "compatible" +}) }`); + +// Offset options +var bogus = { + ...twoThirty, + offset: "+23:59" +}; +// use, with bogus offset, changes to the exact time with the offset +var preserveExact = dstStartDay.with(bogus, { offset: "use" }); +assert.sameValue(`${ preserveExact }`, "2000-03-31T18:31:01-08:00[America/Vancouver]"); +assert.sameValue(preserveExact.epochNanoseconds, Temporal.Instant.from("2000-04-02T02:30:01+23:59").epochNanoseconds); + +// ignore, with bogus offset, defers to disambiguation option +var offset = "ignore"; +assert.sameValue(`${ dstStartDay.with(bogus, { + offset, + disambiguation: "earlier" +}) }`, "2000-04-02T01:30:01-08:00[America/Vancouver]"); +assert.sameValue(`${ dstStartDay.with(bogus, { + offset, + disambiguation: "later" +}) }`, "2000-04-02T03:30:01-07:00[America/Vancouver]"); + +// prefer, with bogus offset, defers to disambiguation option +var offset = "prefer"; +assert.sameValue(`${ dstStartDay.with(bogus, { + offset, + disambiguation: "earlier" +}) }`, "2000-04-02T01:30:01-08:00[America/Vancouver]"); +assert.sameValue(`${ dstStartDay.with(bogus, { + offset, + disambiguation: "later" +}) }`, "2000-04-02T03:30:01-07:00[America/Vancouver]"); + +// reject, with bogus offset, throws +assert.throws(RangeError, () => dstStartDay.with({ + ...twoThirty, + offset: "+23:59" +}, { offset: "reject" })); + +var doubleTime = new Temporal.ZonedDateTime(972811801_000_000_000n, "America/Vancouver"); +// use changes to the exact time with the offset +var preserveExact = doubleTime.with({ offset: "-07:00" }, { offset: "use" }); +assert.sameValue(preserveExact.offset, "-07:00"); +assert.sameValue(preserveExact.epochNanoseconds, Temporal.Instant.from("2000-10-29T01:30:01-07:00").epochNanoseconds); + +// ignore defers to disambiguation option +var offset = "ignore"; +assert.sameValue(doubleTime.with({ offset: "-07:00" }, { + offset, + disambiguation: "earlier" +}).offset, "-07:00"); +assert.sameValue(doubleTime.with({ offset: "-07:00" }, { + offset, + disambiguation: "later" +}).offset, "-08:00"); + +// prefer adjusts offset of repeated clock time +assert.sameValue(doubleTime.with({ offset: "-07:00" }, { offset: "prefer" }).offset, "-07:00"); + +// reject adjusts offset of repeated clock time +assert.sameValue(doubleTime.with({ offset: "-07:00" }, { offset: "reject" }).offset, "-07:00"); + +// use does not cause the offset to change when adjusting repeated clock time +assert.sameValue(doubleTime.with({ minute: 31 }, { offset: "use" }).offset, "-08:00"); + +// ignore may cause the offset to change when adjusting repeated clock time +assert.sameValue(doubleTime.with({ minute: 31 }, { offset: "ignore" }).offset, "-07:00"); + +// prefer does not cause the offset to change when adjusting repeated clock time +assert.sameValue(doubleTime.with({ minute: 31 }, { offset: "prefer" }).offset, "-08:00"); + +// reject does not cause the offset to change when adjusting repeated clock time +assert.sameValue(doubleTime.with({ minute: 31 }, { offset: "reject" }).offset, "-08:00"); + +// prefer is the default +assert.sameValue(`${ dstStartDay.with(twoThirty) }`, `${ dstStartDay.with(twoThirty, { offset: "prefer" }) }`); +assert.sameValue(`${ dstEndDay.with(twoThirty) }`, `${ dstEndDay.with(twoThirty, { offset: "prefer" }) }`); +assert.sameValue(`${ doubleTime.with({ minute: 31 }) }`, `${ doubleTime.with({ minute: 31 }, { offset: "prefer" }) }`); diff --git a/test/staging/Temporal/Duration/old/round.js b/test/staging/Temporal/Duration/old/round.js index edfc1128ff3..6191db67993 100644 --- a/test/staging/Temporal/Duration/old/round.js +++ b/test/staging/Temporal/Duration/old/round.js @@ -4,7 +4,6 @@ /*--- esid: sec-temporal-duration-objects description: Temporal.Duration.prototype.round() works as expected -includes: [temporalHelpers.js] features: [Temporal] ---*/ @@ -33,153 +32,6 @@ assert.sameValue(`${ hours25.round({ relativeTo }) }`, "P1DT1H"); -// relativeTo affects days if ZonedDateTime, and duration encompasses DST change -var timeZone = TemporalHelpers.springForwardFallBackTimeZone(); -var skippedHourDay = Temporal.PlainDateTime.from("2000-04-02").toZonedDateTime(timeZone); -var repeatedHourDay = Temporal.PlainDateTime.from("2000-10-29").toZonedDateTime(timeZone); -var inRepeatedHour = new Temporal.ZonedDateTime(972806400_000_000_000n, timeZone); -var oneDay = new Temporal.Duration(0, 0, 0, 1); -var hours12 = new Temporal.Duration(0, 0, 0, 0, 12); - -// start inside repeated hour, end after -assert.sameValue(`${ hours25.round({ - largestUnit: "days", - relativeTo: inRepeatedHour -}) }`, "P1D"); -assert.sameValue(`${ oneDay.round({ - largestUnit: "hours", - relativeTo: inRepeatedHour -}) }`, "PT25H"); - -// start after repeated hour, end inside (negative) -var relativeTo = Temporal.PlainDateTime.from("2000-10-30T01:00").toZonedDateTime(timeZone); -assert.sameValue(`${ hours25.negated().round({ - largestUnit: "days", - relativeTo -}) }`, "-P1D"); -assert.sameValue(`${ oneDay.negated().round({ - largestUnit: "hours", - relativeTo -}) }`, "-PT25H"); - -// start inside repeated hour, end in skipped hour -assert.sameValue(`${ Temporal.Duration.from({ - days: 126, - hours: 1 -}).round({ - largestUnit: "days", - relativeTo: inRepeatedHour -}) }`, "P126DT1H"); -assert.sameValue(`${ Temporal.Duration.from({ - days: 126, - hours: 1 -}).round({ - largestUnit: "hours", - relativeTo: inRepeatedHour -}) }`, "PT3026H"); - -// start in normal hour, end in skipped hour -var relativeTo = Temporal.PlainDateTime.from("2000-04-01T02:30").toZonedDateTime(timeZone); -assert.sameValue(`${ hours25.round({ - largestUnit: "days", - relativeTo -}) }`, "P1DT1H"); -assert.sameValue(`${ oneDay.round({ - largestUnit: "hours", - relativeTo -}) }`, "PT24H"); - -// start before skipped hour, end >1 day after -assert.sameValue(`${ hours25.round({ - largestUnit: "days", - relativeTo: skippedHourDay -}) }`, "P1DT2H"); -assert.sameValue(`${ oneDay.round({ - largestUnit: "hours", - relativeTo: skippedHourDay -}) }`, "PT23H"); - -// start after skipped hour, end >1 day before (negative) -var relativeTo = Temporal.PlainDateTime.from("2000-04-03T00:00").toZonedDateTime(timeZone); -assert.sameValue(`${ hours25.negated().round({ - largestUnit: "days", - relativeTo -}) }`, "-P1DT2H"); -assert.sameValue(`${ oneDay.negated().round({ - largestUnit: "hours", - relativeTo -}) }`, "-PT23H"); - -// start before skipped hour, end <1 day after -assert.sameValue(`${ hours12.round({ - largestUnit: "days", - relativeTo: skippedHourDay -}) }`, "PT12H"); - -// start after skipped hour, end <1 day before (negative) -var relativeTo = Temporal.PlainDateTime.from("2000-04-02T12:00").toZonedDateTime(timeZone); -assert.sameValue(`${ hours12.negated().round({ - largestUnit: "days", - relativeTo -}) }`, "-PT12H"); - -// start before repeated hour, end >1 day after -assert.sameValue(`${ hours25.round({ - largestUnit: "days", - relativeTo: repeatedHourDay -}) }`, "P1D"); -assert.sameValue(`${ oneDay.round({ - largestUnit: "hours", - relativeTo: repeatedHourDay -}) }`, "PT25H"); - -// start after repeated hour, end >1 day before (negative) -var relativeTo = Temporal.PlainDateTime.from("2000-10-30T00:00").toZonedDateTime(timeZone); -assert.sameValue(`${ hours25.negated().round({ - largestUnit: "days", - relativeTo -}) }`, "-P1D"); -assert.sameValue(`${ oneDay.negated().round({ - largestUnit: "hours", - relativeTo -}) }`, "-PT25H"); - -// start before repeated hour, end <1 day after -assert.sameValue(`${ hours12.round({ - largestUnit: "days", - relativeTo: repeatedHourDay -}) }`, "PT12H"); - -// start after repeated hour, end <1 day before (negative) -var relativeTo = Temporal.PlainDateTime.from("2000-10-29T12:00").toZonedDateTime(timeZone); -assert.sameValue(`${ hours12.negated().round({ - largestUnit: "days", - relativeTo -}) }`, "-PT12H"); - -// Samoa skipped 24 hours -var fakeSamoa = TemporalHelpers.crossDateLineTimeZone(); -var relativeTo = Temporal.PlainDateTime.from("2011-12-29T12:00").toZonedDateTime(fakeSamoa); -assert.sameValue(`${ hours25.round({ - largestUnit: "days", - relativeTo -}) }`, "P2DT1H"); -assert.sameValue(`${ Temporal.Duration.from({ hours: 48 }).round({ - largestUnit: "days", - relativeTo -}) }`, "P3D"); - -// casts relativeTo to ZonedDateTime if possible -assert.sameValue(`${ hours25.round({ - largestUnit: "days", - relativeTo: { - year: 2000, - month: 10, - day: 29, - timeZone - } -}) }`, "P1D"); - // casts relativeTo to PlainDate if possible assert.sameValue(`${ hours25.round({ largestUnit: "days", diff --git a/test/staging/Temporal/Duration/old/total.js b/test/staging/Temporal/Duration/old/total.js index 6fb8e009a5a..f0c57a2da5d 100644 --- a/test/staging/Temporal/Duration/old/total.js +++ b/test/staging/Temporal/Duration/old/total.js @@ -4,7 +4,6 @@ /*--- esid: sec-temporal-duration-objects description: Temporal.Duration.prototype.total() -includes: [temporalHelpers.js] features: [Temporal] ---*/ @@ -195,42 +194,6 @@ assert.sameValue(negativeFortyDays.total({ relativeTo: "2020-04-01" }).toPrecision(16), (-(1 + 9 / 29)).toPrecision(16)); -var oneDay = new Temporal.Duration(0, 0, 0, 1); -var timeZone = TemporalHelpers.springForwardFallBackTimeZone(); -var hours25 = new Temporal.Duration(0, 0, 0, 0, 25); - -// Samoa skipped 24 hours -var fakeSamoa = TemporalHelpers.crossDateLineTimeZone(); -var relativeTo = Temporal.PlainDateTime.from("2011-12-29T12:00").toZonedDateTime(fakeSamoa); -var totalDays = hours25.total({ - unit: "days", - relativeTo -}); -assert(Math.abs(totalDays - (2 + 1 / 24)) < Number.EPSILON); -assert.sameValue(Temporal.Duration.from({ hours: 48 }).total({ - unit: "days", - relativeTo -}), 3); -assert.sameValue(Temporal.Duration.from({ days: 2 }).total({ - unit: "hours", - relativeTo -}), 24); -assert.sameValue(Temporal.Duration.from({ days: 3 }).total({ - unit: "hours", - relativeTo -}), 48); - -// casts relativeTo to ZonedDateTime if possible -assert.sameValue(oneDay.total({ - unit: "hours", - relativeTo: { - year: 2000, - month: 10, - day: 29, - timeZone - } -}), 25); - // balances up to the next unit after rounding var almostWeek = Temporal.Duration.from({ days: 6, diff --git a/test/staging/Temporal/Instant/old/limits.js b/test/staging/Temporal/Instant/old/limits.js index 408bbce1ca7..d7818426a00 100644 --- a/test/staging/Temporal/Instant/old/limits.js +++ b/test/staging/Temporal/Instant/old/limits.js @@ -21,10 +21,3 @@ assert.throws(RangeError, () => Temporal.Instant.fromEpochMilliseconds(-limit - assert.throws(RangeError, () => Temporal.Instant.fromEpochMilliseconds(limit + 1)); assert.sameValue(`${ Temporal.Instant.fromEpochMilliseconds(-limit) }`, "-271821-04-20T00:00:00Z"); assert.sameValue(`${ Temporal.Instant.fromEpochMilliseconds(limit) }`, "+275760-09-13T00:00:00Z"); - -// converting from DateTime -var min = Temporal.PlainDateTime.from("-271821-04-19T00:00:00.000000001"); -var max = Temporal.PlainDateTime.from("+275760-09-13T23:59:59.999999999"); -var utc = Temporal.TimeZone.from("UTC"); -assert.throws(RangeError, () => utc.getInstantFor(min)); -assert.throws(RangeError, () => utc.getInstantFor(max)); diff --git a/test/staging/Temporal/Instant/old/toZonedDateTimeISO.js b/test/staging/Temporal/Instant/old/toZonedDateTimeISO.js index 95986c44dd0..6f50c107716 100644 --- a/test/staging/Temporal/Instant/old/toZonedDateTimeISO.js +++ b/test/staging/Temporal/Instant/old/toZonedDateTimeISO.js @@ -13,13 +13,11 @@ var inst = Temporal.Instant.from("1976-11-18T14:23:30.123456789Z"); assert.throws(TypeError, () => inst.toZonedDateTimeISO()); // time zone parameter UTC -var tz = Temporal.TimeZone.from("UTC"); -var zdt = inst.toZonedDateTimeISO(tz); +var zdt = inst.toZonedDateTimeISO("UTC"); assert.sameValue(inst.epochNanoseconds, zdt.epochNanoseconds); assert.sameValue(`${ zdt }`, "1976-11-18T14:23:30.123456789+00:00[UTC]"); // time zone parameter non-UTC -var tz = Temporal.TimeZone.from("-05:00"); -var zdt = inst.toZonedDateTimeISO(tz); +var zdt = inst.toZonedDateTimeISO("-05:00"); assert.sameValue(inst.epochNanoseconds, zdt.epochNanoseconds); assert.sameValue(`${ zdt }`, "1976-11-18T09:23:30.123456789-05:00[-05:00]"); diff --git a/test/staging/Temporal/Regex/old/instant.js b/test/staging/Temporal/Regex/old/instant.js index 09e810ea550..aebde59ffad 100644 --- a/test/staging/Temporal/Regex/old/instant.js +++ b/test/staging/Temporal/Regex/old/instant.js @@ -10,8 +10,7 @@ features: [Temporal] function test(isoString, components) { var [y, mon, d, h = 0, min = 0, s = 0, ms = 0, µs = 0, ns = 0] = components; var instant = Temporal.Instant.from(isoString); - var utc = Temporal.TimeZone.from("UTC"); - var datetime = utc.getPlainDateTimeFor(instant); + var datetime = instant.toZonedDateTimeISO("UTC"); assert.sameValue(datetime.year, y); assert.sameValue(datetime.month, mon); assert.sameValue(datetime.day, d); diff --git a/test/staging/Temporal/Regex/old/timezone.js b/test/staging/Temporal/Regex/old/timezone.js deleted file mode 100644 index fb5efe10d58..00000000000 --- a/test/staging/Temporal/Regex/old/timezone.js +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: Temporal.TimeZone works as expected -features: [Temporal] ----*/ - -function test(offsetString, expectedName) { - var timeZone = Temporal.TimeZone.from(offsetString); - assert.sameValue(timeZone.id, expectedName); -} -function generateTest(dateTimeString, zoneString, expectedName) { - test(`${ dateTimeString }${ zoneString }`, expectedName); - test(`${ dateTimeString }:30${ zoneString }`, expectedName); - test(`${ dateTimeString }:30.123456789${ zoneString }`, expectedName); -} -[ - "+00:00", - "+00", - "+0000" -].forEach(zoneString => { - generateTest("1976-11-18T15:23", `${ zoneString }[UTC]`, "UTC"); - generateTest("1976-11-18T15:23", `+00:00[${ zoneString }]`, "+00:00"); -}); -[ - "-04:00", - "-04", - "-0400" -].forEach(zoneString => generateTest("1976-11-18T15:23", zoneString, "-04:00")); -[ - "1", - "12", - "123", - "1234", - "12345", - "123456", - "1234567", - "12345678" -].forEach(decimals => { - test(`1976-11-18T15:23:30.${ decimals }Z`, "UTC"); -}); -generateTest("1976-11-18T15:23", "z", "UTC"); -test("1976-11-18T15:23:30,1234Z", "UTC"); -test("1976-11-18T15:23+000000,0[UTC]", "UTC"); -[ - "1976-11-18T152330", - "1976-11-18T152330.1234", - "19761118T15:23:30", - "19761118T152330", - "19761118T152330.1234", - "1976-11-18T15" -].forEach(dateTimeString => { - [ - "+00:00", - "+00", - "+0000", - "" - ].forEach(zoneString => test(`${ dateTimeString }${ zoneString }[UTC]`, "UTC")); - [ - "-04:00", - "-04", - "-0400" - ].forEach(zoneString => test(`${ dateTimeString }${ zoneString }`, "-04:00")); - test(`${ dateTimeString }Z`, "UTC"); -}); -test("-0000", "+00:00"); -test("-00:00", "+00:00"); -test("+00", "+00:00"); -test("-00", "+00:00"); -test("+03", "+03:00"); -test("-03", "-03:00"); -test("-0300", "-03:00"); -test("-03:00", "-03:00"); -test("1976-11-18T15:23:30.123456789Z[u-ca=iso8601]", "UTC"); -test("1976-11-18T15:23:30.123456789-04:00[u-ca=iso8601]", "-04:00"); -test("1976-11-18T15:23:30.123456789[UTC][u-ca=iso8601]", "UTC"); -test("1976-11-18T15:23:30.123456789+00:00[UTC][u-ca=iso8601]", "UTC"); diff --git a/test/staging/Temporal/TimeZone/old/dst-change.js b/test/staging/Temporal/TimeZone/old/dst-change.js deleted file mode 100644 index ca568317681..00000000000 --- a/test/staging/Temporal/TimeZone/old/dst-change.js +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: with DST change -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -// clock moving forward -var zone = TemporalHelpers.springForwardFallBackTimeZone(); -var dtm = new Temporal.PlainDateTime(2000, 4, 2, 2, 45); -assert.sameValue(`${ zone.getInstantFor(dtm) }`, "2000-04-02T10:45:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtm, { disambiguation: "earlier" }) }`, "2000-04-02T09:45:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtm, { disambiguation: "later" }) }`, "2000-04-02T10:45:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtm, { disambiguation: "compatible" }) }`, "2000-04-02T10:45:00Z"); -assert.throws(RangeError, () => zone.getInstantFor(dtm, { disambiguation: "reject" })); - -// clock moving backward -var dtm = new Temporal.PlainDateTime(2000, 10, 29, 1, 45); -assert.sameValue(`${ zone.getInstantFor(dtm) }`, "2000-10-29T08:45:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtm, { disambiguation: "earlier" }) }`, "2000-10-29T08:45:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtm, { disambiguation: "later" }) }`, "2000-10-29T09:45:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtm, { disambiguation: "compatible" }) }`, "2000-10-29T08:45:00Z"); -assert.throws(RangeError, () => zone.getInstantFor(dtm, { disambiguation: "reject" })); diff --git a/test/staging/Temporal/TimeZone/old/getInstantFor-disambiguation.js b/test/staging/Temporal/TimeZone/old/getInstantFor-disambiguation.js deleted file mode 100644 index 643c9ba707d..00000000000 --- a/test/staging/Temporal/TimeZone/old/getInstantFor-disambiguation.js +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: getInstantFor disambiguation -includes: [temporalHelpers.js] -features: [Temporal] ----*/ - -var dtm = new Temporal.PlainDateTime(2000, 10, 29, 1, 45); - -// with constant offset -var zone = Temporal.TimeZone.from("+03:30"); -for (var disambiguation of [ - undefined, - "compatible", - "earlier", - "later", - "reject" - ]) { - assert(zone.getInstantFor(dtm, { disambiguation }) instanceof Temporal.Instant); -} - -// with daylight saving change - Fall -var zone = TemporalHelpers.springForwardFallBackTimeZone(); -assert.sameValue(`${ zone.getInstantFor(dtm) }`, "2000-10-29T08:45:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtm, { disambiguation: "earlier" }) }`, "2000-10-29T08:45:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtm, { disambiguation: "later" }) }`, "2000-10-29T09:45:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtm, { disambiguation: "compatible" }) }`, "2000-10-29T08:45:00Z"); -assert.throws(RangeError, () => zone.getInstantFor(dtm, { disambiguation: "reject" })); - -// with daylight saving change - Spring -var dtmLA = new Temporal.PlainDateTime(2000, 4, 2, 2, 30); -assert.sameValue(`${ zone.getInstantFor(dtmLA) }`, "2000-04-02T10:30:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtmLA, { disambiguation: "earlier" }) }`, "2000-04-02T09:30:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtmLA, { disambiguation: "later" }) }`, "2000-04-02T10:30:00Z"); -assert.sameValue(`${ zone.getInstantFor(dtmLA, { disambiguation: "compatible" }) }`, "2000-04-02T10:30:00Z"); -assert.throws(RangeError, () => zone.getInstantFor(dtmLA, { disambiguation: "reject" })); - -// throws on bad disambiguation -var zone = Temporal.TimeZone.from("+03:30"); -[ - "", - "EARLIER", - "test", -].forEach(disambiguation => assert.throws(RangeError, () => zone.getInstantFor(dtm, { disambiguation }))); diff --git a/test/staging/Temporal/TimeZone/old/getInstantFor.js b/test/staging/Temporal/TimeZone/old/getInstantFor.js deleted file mode 100644 index 4569e2213b9..00000000000 --- a/test/staging/Temporal/TimeZone/old/getInstantFor.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: Temporal.TimeZone.prototype.getInstantFor() works -features: [Temporal] ----*/ - - -// recent date -var dt = Temporal.PlainDateTime.from("2019-10-29T10:46:38.271986102"); -var tz = Temporal.TimeZone.from("+01:00"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "2019-10-29T09:46:38.271986102Z"); - -// year ≤ 99 -var dt = Temporal.PlainDateTime.from("0098-10-29T10:46:38.271986102"); -var tz = Temporal.TimeZone.from("+06:00"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "0098-10-29T04:46:38.271986102Z"); -dt = Temporal.PlainDateTime.from("+000098-10-29T10:46:38.271986102"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "0098-10-29T04:46:38.271986102Z"); - -// year < 1 -var dt = Temporal.PlainDateTime.from("0000-10-29T10:46:38.271986102"); -var tz = Temporal.TimeZone.from("+06:00"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "0000-10-29T04:46:38.271986102Z"); -dt = Temporal.PlainDateTime.from("+000000-10-29T10:46:38.271986102"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "0000-10-29T04:46:38.271986102Z"); -dt = Temporal.PlainDateTime.from("-001000-10-29T10:46:38.271986102"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "-001000-10-29T04:46:38.271986102Z"); - -// year 0 leap day -var dt = Temporal.PlainDateTime.from("0000-02-29T00:00"); -var tz = Temporal.TimeZone.from("-00:01"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "0000-02-29T00:01:00Z"); -dt = Temporal.PlainDateTime.from("+000000-02-29T00:00"); -assert.sameValue(`${ tz.getInstantFor(dt) }`, "0000-02-29T00:01:00Z"); - -// outside of Instant range -var max = Temporal.PlainDateTime.from("+275760-09-13T23:59:59.999999999"); -var offsetTz = Temporal.TimeZone.from("-01:00"); -assert.throws(RangeError, () => offsetTz.getInstantFor(max)); -var namedTz = Temporal.TimeZone.from("Etc/GMT+12"); -assert.throws(RangeError, () => namedTz.getInstantFor(max)); - -// casts argument -var tz = Temporal.TimeZone.from("+01:00"); -assert.sameValue(`${ tz.getInstantFor("2019-10-29T10:46:38.271986102") }`, "2019-10-29T09:46:38.271986102Z"); -assert.sameValue(`${ tz.getInstantFor({ - year: 2019, - month: 10, - day: 29, - hour: 10, - minute: 46, - second: 38 -}) }`, "2019-10-29T09:46:38Z"); - - diff --git a/test/staging/Temporal/TimeZone/old/getNextTransition.js b/test/staging/Temporal/TimeZone/old/getNextTransition.js deleted file mode 100644 index 6aef8533675..00000000000 --- a/test/staging/Temporal/TimeZone/old/getNextTransition.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: Temporal.TimeZone.prototype.getNextTransition() works as expected -features: [Temporal] ----*/ - -var noTransitionTZ = Temporal.TimeZone.from("Etc/GMT+10"); - -// should work for timezones with no scheduled transitions in the near future -var start = Temporal.Instant.from("1945-10-15T13:00:00Z"); -assert.sameValue(noTransitionTZ.getNextTransition(start), null); - -// accepts string as argument -assert.sameValue(noTransitionTZ.getNextTransition("2019-04-16T21:01Z"), null); diff --git a/test/staging/Temporal/TimeZone/old/getPossibleInstantsFor.js b/test/staging/Temporal/TimeZone/old/getPossibleInstantsFor.js deleted file mode 100644 index f42050bd8c0..00000000000 --- a/test/staging/Temporal/TimeZone/old/getPossibleInstantsFor.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: Temporal.TimeZone.prototype.getPossibleInstantsFor() works as expected -includes: [deepEqual.js, temporalHelpers.js] -features: [Temporal] ----*/ - - -// with constant offset -var zone = Temporal.TimeZone.from("+03:30"); -var dt = Temporal.PlainDateTime.from("2019-02-16T23:45"); -assert.deepEqual(zone.getPossibleInstantsFor(dt).map(a => `${ a }`), ["2019-02-16T20:15:00Z"]); - -// with clock moving forward -var zone = TemporalHelpers.springForwardFallBackTimeZone(); -var dt = Temporal.PlainDateTime.from("2000-04-02T02:45"); -assert.deepEqual(zone.getPossibleInstantsFor(dt), []); - -// with clock moving backward -var dt = Temporal.PlainDateTime.from("2000-10-29T01:45"); -assert.deepEqual(zone.getPossibleInstantsFor(dt).map(a => `${ a }`), [ - "2000-10-29T08:45:00Z", - "2000-10-29T09:45:00Z" -]); - -// casts argument -var tz = Temporal.TimeZone.from("+03:30"); -assert.deepEqual(tz.getPossibleInstantsFor({ - year: 2019, - month: 2, - day: 16, - hour: 23, - minute: 45, - second: 30 -}).map(a => `${ a }`), ["2019-02-16T20:15:30Z"]); -assert.deepEqual(tz.getPossibleInstantsFor("2019-02-16T23:45:30").map(a => `${ a }`), ["2019-02-16T20:15:30Z"]); - -// object must contain at least the required properties -var tz = Temporal.TimeZone.from("UTC"); -assert.throws(TypeError, () => tz.getPossibleInstantsFor({ year: 2019 })); diff --git a/test/staging/Temporal/TimeZone/old/getPreviousTransition.js b/test/staging/Temporal/TimeZone/old/getPreviousTransition.js deleted file mode 100644 index 371f7fc1f58..00000000000 --- a/test/staging/Temporal/TimeZone/old/getPreviousTransition.js +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: Temporal.TimeZone.prototype.getPreviousTransition() works -features: [Temporal] ----*/ - -var utc = Temporal.TimeZone.from("UTC"); - -// no transitions without a TZDB -var instant = Temporal.Instant.from("2020-06-11T21:01Z"); -assert.sameValue(utc.getPreviousTransition(instant), null); - -// accepts string as argument -assert.sameValue(utc.getPreviousTransition("2020-06-11T21:01Z"), null); diff --git a/test/staging/Temporal/TimeZone/old/timezone-offset.js b/test/staging/Temporal/TimeZone/old/timezone-offset.js deleted file mode 100644 index 21b0c0798c9..00000000000 --- a/test/staging/Temporal/TimeZone/old/timezone-offset.js +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: +01:00 -features: [Temporal] ----*/ - -var zone = new Temporal.TimeZone("+01:00"); -var inst = Temporal.Instant.fromEpochMilliseconds(Math.floor(Math.random() * 1_000_000_000_000)); -var dtm = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789); -assert.sameValue(zone.id, `${ zone }`) -assert.sameValue(zone.getOffsetNanosecondsFor(inst), 3600000000000) -assert(zone.getPlainDateTimeFor(inst) instanceof Temporal.PlainDateTime) -assert(zone.getInstantFor(dtm) instanceof Temporal.Instant) -assert.sameValue(zone.getNextTransition(inst), null) -assert.sameValue(zone.getPreviousTransition(inst), null) - -// wraps around to the next day -assert.sameValue(`${ zone.getPlainDateTimeFor(Temporal.Instant.from("2020-02-06T23:59Z")) }`, "2020-02-07T00:59:00") diff --git a/test/staging/Temporal/TimeZone/old/timezone-utc-offset.js b/test/staging/Temporal/TimeZone/old/timezone-utc-offset.js deleted file mode 100644 index b6421c7910e..00000000000 --- a/test/staging/Temporal/TimeZone/old/timezone-utc-offset.js +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-timezone-objects -description: UTC -features: [Temporal] ----*/ - -var zone = new Temporal.TimeZone("UTC"); -var inst = Temporal.Instant.fromEpochMilliseconds(Math.floor(Math.random() * 1_000_000_000_000)); -var dtm = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789); -assert.sameValue(zone.id, `${ zone }`) -assert.sameValue(zone.getOffsetNanosecondsFor(inst), 0) -assert(zone.getPlainDateTimeFor(inst) instanceof Temporal.PlainDateTime) -assert(zone.getInstantFor(dtm) instanceof Temporal.Instant) -assert.sameValue(zone.getNextTransition(inst), null) -assert.sameValue(zone.getPreviousTransition(inst), null) diff --git a/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js b/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js deleted file mode 100644 index 669bcc21d27..00000000000 --- a/test/staging/Temporal/UserCalendar/old/calendar-extra-fields.js +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: calendar with extra fields -features: [Temporal, Array.prototype.includes] ----*/ - -class SeasonCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - get id() { - return "season"; - } - toString() { - return "season"; - } - month(date) { - var {isoMonth} = date.getISOFields(); - return (isoMonth - 1) % 3 + 1; - } - monthCode(date) { - return `M${ this.month(date).toString().padStart(2, "0") }`; - } - season(date) { - var {isoMonth} = date.getISOFields(); - return Math.floor((isoMonth - 1) / 3) + 1; - } - _isoMonthCode(fields) { - var month = fields.month || +fields.monthCode.slice(1); - return `M${ ((fields.season - 1) * 3 + month).toString().padStart(2, "0") }`; - } - dateFromFields(fields, options) { - var monthCode = this._isoMonthCode(fields); - delete fields.month; - return super.dateFromFields({ - ...fields, - monthCode - }, options).withCalendar(this); - } - yearMonthFromFields(fields, options) { - var monthCode = this._isoMonthCode(fields); - delete fields.month; - const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields({ - ...fields, - monthCode - }, options).getISOFields(); - return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); - } - monthDayFromFields(fields, options) { - var monthCode = this._isoMonthCode(fields); - delete fields.month; - const { isoYear, isoMonth, isoDay } = super.monthDayFromFields({ - ...fields, - monthCode - }, options).getISOFields(); - return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); - } - fields(fields) { - fields = fields.slice(); - if (fields.includes("month") || fields.includes("monthCode")) - fields.push("season"); - return fields; - } -} -var calendar = new SeasonCalendar(); -var datetime = new Temporal.PlainDateTime(2019, 9, 15, 0, 0, 0, 0, 0, 0, calendar); -var date = new Temporal.PlainDate(2019, 9, 15, calendar); -var yearmonth = new Temporal.PlainYearMonth(2019, 9, calendar); -var monthday = new Temporal.PlainMonthDay(9, 15, calendar); -var zoned = new Temporal.ZonedDateTime(1568505600000000000n, "UTC", calendar); -var propDesc = { - get() { - return this.getCalendar().season(this); - }, - configurable: true -}; -Object.defineProperty(Temporal.PlainDateTime.prototype, "season", propDesc); -Object.defineProperty(Temporal.PlainDate.prototype, "season", propDesc); -Object.defineProperty(Temporal.PlainYearMonth.prototype, "season", propDesc); -Object.defineProperty(Temporal.PlainMonthDay.prototype, "season", propDesc); -Object.defineProperty(Temporal.ZonedDateTime.prototype, "season", propDesc); - -// property getter works -assert.sameValue(datetime.season, 3); -assert.sameValue(datetime.month, 3); -assert.sameValue(datetime.monthCode, "M03"); -assert.sameValue(date.season, 3); -assert.sameValue(date.month, 3); -assert.sameValue(date.monthCode, "M03"); -assert.sameValue(yearmonth.season, 3); -assert.sameValue(yearmonth.month, 3); -assert.sameValue(yearmonth.monthCode, "M03"); -assert.sameValue(monthday.season, 3); -assert.sameValue(monthday.monthCode, "M03"); -assert.sameValue(zoned.season, 3); -assert.sameValue(zoned.month, 3); -assert.sameValue(zoned.monthCode, "M03"); - -// accepts season in from() -assert.sameValue(`${ Temporal.PlainDateTime.from({ - year: 2019, - season: 3, - month: 3, - day: 15, - calendar -}) }`, "2019-09-15T00:00:00[u-ca=season]"); -assert.sameValue(`${ Temporal.PlainDate.from({ - year: 2019, - season: 3, - month: 3, - day: 15, - calendar -}) }`, "2019-09-15[u-ca=season]"); -assert.sameValue(`${ Temporal.PlainYearMonth.from({ - year: 2019, - season: 3, - month: 3, - calendar -}) }`, "2019-09-01[u-ca=season]"); -assert.sameValue(`${ Temporal.PlainMonthDay.from({ - season: 3, - monthCode: "M03", - day: 15, - calendar -}) }`, "1972-09-15[u-ca=season]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from({ - year: 2019, - season: 3, - month: 3, - day: 15, - timeZone: "UTC", - calendar -}) }`, "2019-09-15T00:00:00+00:00[UTC][u-ca=season]"); - -// accepts season in with() -assert.sameValue(`${ datetime.with({ season: 2 }) }`, "2019-06-15T00:00:00[u-ca=season]"); -assert.sameValue(`${ date.with({ season: 2 }) }`, "2019-06-15[u-ca=season]"); -assert.sameValue(`${ yearmonth.with({ season: 2 }) }`, "2019-06-01[u-ca=season]"); -assert.sameValue(`${ monthday.with({ season: 2 }) }`, "1972-06-15[u-ca=season]"); -assert.sameValue(`${ zoned.with({ season: 2 }) }`, "2019-06-15T00:00:00+00:00[UTC][u-ca=season]"); - -// translates month correctly in with() -assert.sameValue(`${ datetime.with({ month: 2 }) }`, "2019-08-15T00:00:00[u-ca=season]"); -assert.sameValue(`${ date.with({ month: 2 }) }`, "2019-08-15[u-ca=season]"); -assert.sameValue(`${ yearmonth.with({ month: 2 }) }`, "2019-08-01[u-ca=season]"); -assert.sameValue(`${ monthday.with({ monthCode: "M02" }) }`, "1972-08-15[u-ca=season]"); -assert.sameValue(`${ zoned.with({ month: 2 }) }`, "2019-08-15T00:00:00+00:00[UTC][u-ca=season]"); - -delete Temporal.PlainDateTime.prototype.season; -delete Temporal.PlainDate.prototype.season; -delete Temporal.PlainYearMonth.prototype.season; -delete Temporal.PlainMonthDay.prototype.season; -delete Temporal.ZonedDateTime.prototype.season; - diff --git a/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js b/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js deleted file mode 100644 index 8c41d56b7b5..00000000000 --- a/test/staging/Temporal/UserCalendar/old/calendar-non-trivial-mergefields.js +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: calendar with nontrivial mergeFields implementation -features: [Temporal, Array.prototype.includes] ----*/ - -class CenturyCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - get id() { - return 'century'; - } - toString() { - return "century"; - } - century(date) { - var {isoYear} = date.getISOFields(); - return Math.ceil(isoYear / 100); - } - centuryYear(date) { - var {isoYear} = date.getISOFields(); - return isoYear % 100; - } - _validateFields(fields) { - var {year, century, centuryYear} = fields; - if (century === undefined !== (centuryYear === undefined)) { - throw new TypeError("pass either both or neither of century and centuryYear"); - } - if (year === undefined) - return (century - 1) * 100 + centuryYear; - if (century !== undefined) { - var centuryCalculatedYear = (century - 1) * 100 + centuryYear; - if (year !== centuryCalculatedYear) { - throw new RangeError("year must agree with century/centuryYear if both given"); - } - } - return year; - } - dateFromFields(fields, options) { - var isoYear = this._validateFields(fields); - return super.dateFromFields({ - ...fields, - year: isoYear - }, options).withCalendar(this); - } - yearMonthFromFields(fields, options) { - var year = this._validateFields(fields); - const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields({ - ...fields, - year, - }, options).getISOFields(); - return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); - } - monthDayFromFields(fields, options) { - var year = this._validateFields(fields); - const { isoYear, isoMonth, isoDay } = super.monthDayFromFields({ - ...fields, - year, - }, options).getISOFields(); - return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); - } - fields(fields) { - fields = fields.slice(); - if (fields.includes("year")) - fields.push("century", "centuryYear"); - return fields; - } - mergeFields(fields, additionalFields) { - var {year, century, centuryYear, ...original} = fields; - var { - year: newYear, - century: newCentury, - centuryYear: newCenturyYear - } = additionalFields; - if (newYear === undefined) { - original.century = century; - original.centuryYear = centuryYear; - } - if (newCentury === undefined && newCenturyYear === undefined) { - original.year === year; - } - return { - ...original, - ...additionalFields - }; - } -} -var calendar = new CenturyCalendar(); -var datetime = new Temporal.PlainDateTime(2019, 9, 15, 0, 0, 0, 0, 0, 0, calendar); -var date = new Temporal.PlainDate(2019, 9, 15, calendar); -var yearmonth = new Temporal.PlainYearMonth(2019, 9, calendar); -var zoned = new Temporal.ZonedDateTime(1568505600000000000n, "UTC", calendar); -var propDesc = { - century: { - get() { - return this.getCalendar().century(this); - }, - configurable: true - }, - centuryYear: { - get() { - return this.getCalendar().centuryYear(this); - }, - configurable: true - } -}; -Object.defineProperties(Temporal.PlainDateTime.prototype, propDesc); -Object.defineProperties(Temporal.PlainDate.prototype, propDesc); -Object.defineProperties(Temporal.PlainYearMonth.prototype, propDesc); -Object.defineProperties(Temporal.ZonedDateTime.prototype, propDesc); - -// property getters work -assert.sameValue(datetime.century, 21); -assert.sameValue(datetime.centuryYear, 19); -assert.sameValue(date.century, 21); -assert.sameValue(date.centuryYear, 19); -assert.sameValue(yearmonth.century, 21); -assert.sameValue(yearmonth.centuryYear, 19); -assert.sameValue(zoned.century, 21); -assert.sameValue(zoned.centuryYear, 19); - -// correctly resolves century in with() -assert.sameValue(`${ datetime.with({ century: 20 }) }`, "1919-09-15T00:00:00[u-ca=century]"); -assert.sameValue(`${ date.with({ century: 20 }) }`, "1919-09-15[u-ca=century]"); -assert.sameValue(`${ yearmonth.with({ century: 20 }) }`, "1919-09-01[u-ca=century]"); -assert.sameValue(`${ zoned.with({ century: 20 }) }`, "1919-09-15T00:00:00+00:00[UTC][u-ca=century]"); - -// correctly resolves centuryYear in with() -assert.sameValue(`${ datetime.with({ centuryYear: 5 }) }`, "2005-09-15T00:00:00[u-ca=century]"); -assert.sameValue(`${ date.with({ centuryYear: 5 }) }`, "2005-09-15[u-ca=century]"); -assert.sameValue(`${ yearmonth.with({ centuryYear: 5 }) }`, "2005-09-01[u-ca=century]"); -assert.sameValue(`${ zoned.with({ centuryYear: 5 }) }`, "2005-09-15T00:00:00+00:00[UTC][u-ca=century]"); - -// correctly resolves year in with() -assert.sameValue(`${ datetime.with({ year: 1974 }) }`, "1974-09-15T00:00:00[u-ca=century]"); -assert.sameValue(`${ date.with({ year: 1974 }) }`, "1974-09-15[u-ca=century]"); -assert.sameValue(`${ yearmonth.with({ year: 1974 }) }`, "1974-09-01[u-ca=century]"); -assert.sameValue(`${ zoned.with({ year: 1974 }) }`, "1974-09-15T00:00:00+00:00[UTC][u-ca=century]"); - -delete Temporal.PlainDateTime.prototype.century; -delete Temporal.PlainDateTime.prototype.centuryYear; -delete Temporal.PlainDate.prototype.century; -delete Temporal.PlainDate.prototype.centuryYear; -delete Temporal.PlainYearMonth.prototype.century; -delete Temporal.PlainYearMonth.prototype.centuryYear; -delete Temporal.ZonedDateTime.prototype.century; -delete Temporal.ZonedDateTime.prototype.centuryYear; diff --git a/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js b/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js deleted file mode 100644 index de1a92360aa..00000000000 --- a/test/staging/Temporal/UserCalendar/old/trivial-protocol-implementation.js +++ /dev/null @@ -1,220 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: Trivial protocol implementation -features: [Temporal] ----*/ - -function decimalToISO(year, month, day, overflow = "constrain") { - if (overflow === "constrain") { - if (month < 1) - month = 1; - if (month > 10) - month = 10; - if (day < 1) - day = 1; - if (day > 10) - day = 10; - } else if (overflow === "reject") { - if (month < 1 || month > 10 || day < 1 || day > 10) { - throw new RangeError("invalid value"); - } - } - var days = year * 100 + (month - 1) * 10 + (day - 1); - return new Temporal.PlainDate(1970, 1, 1, "iso8601").add({ days }); -} -function isoToDecimal(date) { - var {isoYear, isoMonth, isoDay} = date.getISOFields(); - var isoDate = new Temporal.PlainDate(isoYear, isoMonth, isoDay); - var {days} = isoDate.since(new Temporal.PlainDate(1970, 1, 1), { largestUnit: "days" }); - var year = Math.floor(days / 100); - days %= 100; - return { - year, - days - }; -} -var obj = { - id: 'decimal', - toString() { - return "decimal"; - }, - fields(fieldNames) { return fieldNames; }, - dateFromFields(fields, options) { - var { - overflow = "constrain" - } = options ? options : {}; - var {month, monthCode} = fields; - if (month === undefined) - month = +monthCode.slice(1); - var isoDate = decimalToISO(fields.year, month, fields.day, 0, 0, 0, overflow); - return new Temporal.PlainDate(isoDate.year, isoDate.month, isoDate.day, this); - }, - yearMonthFromFields(fields, options) { - var { - overflow = "constrain" - } = options ? options : {}; - var {month, monthCode} = fields; - if (month === undefined) - month = +monthCode.slice(1); - var isoDate = decimalToISO(fields.year, month, 1, 0, 0, 0, overflow); - return new Temporal.PlainYearMonth(isoDate.year, isoDate.month, this, isoDate.day); - }, - monthDayFromFields(fields, options) { - var { - overflow = "constrain" - } = options ? options : {}; - var {month, monthCode} = fields; - if (month === undefined) - month = +monthCode.slice(1); - var isoDate = decimalToISO(0, month, fields.day, 0, 0, 0, overflow); - return new Temporal.PlainMonthDay(isoDate.month, isoDate.day, this, isoDate.year); - }, - year(date) { - return isoToDecimal(date).year; - }, - month(date) { - var {days} = isoToDecimal(date); - return Math.floor(days / 10) + 1; - }, - monthCode(date) { - return `M${ this.month(date).toString().padStart(2, "0") }`; - }, - day(date) { - var {days} = isoToDecimal(date); - return days % 10 + 1; - }, - dateAdd() {}, // left as an exercise for the reader - dateUntil() {}, // ditto - dayOfWeek() { - throw new Error('no weeks'); - }, - dayOfYear(date) { - return isoToDecimal(date).days; - }, - daysInMonth() { - return 10; - }, - daysInWeek() { - throw new Error('no weeks'); - }, - daysInYear() { - return 100; - }, - fields(fields) { - return fields; - }, - inLeapYear() { - return false; - }, - mergeFields(fields, additional) { - return new Temporal.Calendar("iso8601").mergeFields(fields, additional) - }, - monthsInYear() { - return 10; - }, - weekOfYear() { - throw new Error('no weeks'); - }, - yearOfWeek(date) { - throw new Error('no weeks'); - }, -}; -var date = Temporal.PlainDate.from({ - year: 184, - month: 2, - day: 9, - calendar: obj -}); -var dt = Temporal.PlainDateTime.from({ - year: 184, - month: 2, - day: 9, - hour: 12, - calendar: obj -}); -var ym = Temporal.PlainYearMonth.from({ - year: 184, - month: 2, - calendar: obj -}); -var md = Temporal.PlainMonthDay.from({ - monthCode: "M02", - day: 9, - calendar: obj -}); - -// is a calendar -assert.sameValue(typeof obj, "object") - -// .id is not available in from() -assert.throws(RangeError, () => Temporal.Calendar.from("decimal")); -assert.throws(RangeError, () => Temporal.Calendar.from("2020-06-05T09:34-00:00[UTC][u-ca=decimal]")); - -// Temporal.PlainDate.from() -assert.sameValue(`${ date }`, "2020-06-05[u-ca=decimal]") - -// Temporal.PlainDate fields -assert.sameValue(date.year, 184); -assert.sameValue(date.month, 2); -assert.sameValue(date.day, 9); - -// date.with() -var date2 = date.with({ year: 0 }); -assert.sameValue(date2.year, 0); - -// date.withCalendar() -var date2 = Temporal.PlainDate.from("2020-06-05T12:00"); -assert(date2.withCalendar(obj).equals(date)); - -// Temporal.PlainDateTime.from() -assert.sameValue(`${ dt }`, "2020-06-05T12:00:00[u-ca=decimal]") - -// Temporal.PlainDateTime fields -assert.sameValue(dt.year, 184); -assert.sameValue(dt.month, 2); -assert.sameValue(dt.day, 9); -assert.sameValue(dt.hour, 12); -assert.sameValue(dt.minute, 0); -assert.sameValue(dt.second, 0); -assert.sameValue(dt.millisecond, 0); -assert.sameValue(dt.microsecond, 0); -assert.sameValue(dt.nanosecond, 0); - -// datetime.with() -var dt2 = dt.with({ year: 0 }); -assert.sameValue(dt2.year, 0); - -// datetime.withCalendar() -var dt2 = Temporal.PlainDateTime.from("2020-06-05T12:00"); -assert(dt2.withCalendar(obj).equals(dt)); - -// Temporal.PlainYearMonth.from() -assert.sameValue(`${ ym }`, "2020-05-28[u-ca=decimal]") - -// Temporal.PlainYearMonth fields -assert.sameValue(dt.year, 184); -assert.sameValue(dt.month, 2); - -// yearmonth.with() -var ym2 = ym.with({ year: 0 }); -assert.sameValue(ym2.year, 0); - -// Temporal.PlainMonthDay.from() -assert.sameValue(`${ md }`, "1970-01-19[u-ca=decimal]") - -// Temporal.PlainMonthDay fields -assert.sameValue(md.monthCode, "M02"); -assert.sameValue(md.day, 9); - -// monthday.with() -var md2 = md.with({ monthCode: "M01" }); -assert.sameValue(md2.monthCode, "M01"); - -// timezone.getPlainDateTimeFor() -var tz = Temporal.TimeZone.from("UTC"); -var inst = Temporal.Instant.fromEpochMilliseconds(0); -var dt = tz.getPlainDateTimeFor(inst, obj); -assert.sameValue(dt.getCalendar(), obj); diff --git a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js b/test/staging/Temporal/UserCalendar/old/trivial-subclass.js deleted file mode 100644 index 36b87e38c8e..00000000000 --- a/test/staging/Temporal/UserCalendar/old/trivial-subclass.js +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: Trivial subclass -features: [Temporal] ----*/ - -class TwoBasedCalendar extends Temporal.Calendar { - constructor() { - super("iso8601"); - } - get id() { - return "two-based"; - } - toString() { - return "two-based"; - } - dateFromFields(fields, options) { - var {year, month, monthCode, day} = fields; - if (month === undefined) - month = +monthCode.slice(1); - return super.dateFromFields({ - year, - monthCode: `M${ (month - 1).toString().padStart(2, "0") }`, - day - }, options).withCalendar(this); - } - yearMonthFromFields(fields, options) { - var {year, month, monthCode} = fields; - if (month === undefined) - month = +monthCode.slice(1); - const { isoYear, isoMonth, isoDay } = super.yearMonthFromFields({ - year, - monthCode: `M${ (month - 1).toString().padStart(2, "0") }` - }, options).getISOFields(); - return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay); - } - monthDayFromFields(fields, options) { - var {month, monthCode, day} = fields; - if (month === undefined) - month = +monthCode.slice(1); - const { isoYear, isoMonth, isoDay } = super.monthDayFromFields({ - monthCode: `M${ (month - 1).toString().padStart(2, "0") }`, - day - }, options).getISOFields(); - return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear); - } - month(date) { - return date.getISOFields().isoMonth + 1; - } - monthCode(date) { - return `M${ this.month(date).toString().padStart(2, "0") }`; - } -} -var obj = new TwoBasedCalendar(); -var date = Temporal.PlainDate.from({ - year: 2020, - month: 5, - day: 5, - calendar: obj -}); -var dt = Temporal.PlainDateTime.from({ - year: 2020, - month: 5, - day: 5, - hour: 12, - calendar: obj -}); -var ym = Temporal.PlainYearMonth.from({ - year: 2020, - month: 5, - calendar: obj -}); -var md = Temporal.PlainMonthDay.from({ - monthCode: "M05", - day: 5, - calendar: obj -}); - -// is a calendar -assert.sameValue(typeof obj, "object") - -// .id property -assert.sameValue(obj.id, "two-based") - -// .id is not available in from() -assert.throws(RangeError, () => Temporal.Calendar.from("two-based")); -assert.throws(RangeError, () => Temporal.Calendar.from("2020-06-05T09:34-00:00[UTC][u-ca=two-based]")); - -// Temporal.PlainDate.from() -assert.sameValue(`${ date }`, "2020-04-05[u-ca=two-based]") - -// Temporal.PlainDate fields -assert.sameValue(date.year, 2020); -assert.sameValue(date.month, 5); -assert.sameValue(date.day, 5); - -// date.with() -var date2 = date.with({ month: 2 }); -assert.sameValue(date2.month, 2); - -// date.withCalendar() -var date2 = Temporal.PlainDate.from("2020-04-05"); -assert(date2.withCalendar(obj).equals(date)); - -// Temporal.PlainDateTime.from() -assert.sameValue(`${ dt }`, "2020-04-05T12:00:00[u-ca=two-based]") - -// Temporal.PlainDateTime fields -assert.sameValue(dt.year, 2020); -assert.sameValue(dt.month, 5); -assert.sameValue(dt.day, 5); -assert.sameValue(dt.hour, 12); -assert.sameValue(dt.minute, 0); -assert.sameValue(dt.second, 0); -assert.sameValue(dt.millisecond, 0); -assert.sameValue(dt.microsecond, 0); -assert.sameValue(dt.nanosecond, 0); - -// datetime.with() -var dt2 = dt.with({ month: 2 }); -assert.sameValue(dt2.month, 2); - -// datetime.withCalendar() -var dt2 = Temporal.PlainDateTime.from("2020-04-05T12:00"); -assert(dt2.withCalendar(obj).equals(dt)); - -// Temporal.PlainYearMonth.from() -assert.sameValue(`${ ym }`, "2020-04-01[u-ca=two-based]") - -// Temporal.PlainYearMonth fields -assert.sameValue(dt.year, 2020); -assert.sameValue(dt.month, 5); - -// yearmonth.with() -var ym2 = ym.with({ month: 2 }); -assert.sameValue(ym2.month, 2); - -// Temporal.PlainMonthDay.from() -assert.sameValue(`${ md }`, "1972-04-05[u-ca=two-based]") - -// Temporal.PlainMonthDay fields -assert.sameValue(md.monthCode, "M05"); -assert.sameValue(md.day, 5); - -// monthday.with() -var md2 = md.with({ monthCode: "M02" }); -assert.sameValue(md2.monthCode, "M02"); - -// timezone.getPlainDateTimeFor() -var tz = Temporal.TimeZone.from("UTC"); -var instant = Temporal.Instant.fromEpochMilliseconds(0); -var dt = tz.getPlainDateTimeFor(instant, obj); -assert.sameValue(dt.getCalendar(), obj); diff --git a/test/staging/Temporal/UserTimezone/old/subminute-offset.js b/test/staging/Temporal/UserTimezone/old/subminute-offset.js deleted file mode 100644 index 21f967dd3af..00000000000 --- a/test/staging/Temporal/UserTimezone/old/subminute-offset.js +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: sub-minute offset -features: [Temporal] ----*/ - -class SubminuteTimeZone extends Temporal.TimeZone { - constructor() { - super("UTC"); - } - get id() { - return "Custom/Subminute"; - } - toString() { - return "Custom/Subminute"; - } - getOffsetNanosecondsFor() { - return -1111111111; - } - getPossibleInstantsFor(dateTime) { - var utc = Temporal.TimeZone.from("UTC"); - var instant = utc.getInstantFor(dateTime); - return [instant.add({ nanoseconds: 1111111111 })]; - } - getNextTransition() { - return null; - } - getPreviousTransition() { - return null; - } -} -var obj = new SubminuteTimeZone(); -var inst = Temporal.Instant.fromEpochNanoseconds(0n); -var dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789); - -// is a time zone -assert.sameValue(typeof obj, "object") - -// .id property -assert.sameValue(obj.id, "Custom/Subminute") - -// .id is not available in from() -assert.throws(RangeError, () => Temporal.TimeZone.from("Custom/Subminute")); -assert.throws(RangeError, () => Temporal.TimeZone.from("2020-05-26T16:02:46.251163036-00:00:01.111111111[Custom/Subminute]")); - -// has offset string -00:00:01.111111111 -assert.sameValue(obj.getOffsetStringFor(inst), "-00:00:01.111111111") - -// converts to DateTime -var fakeGregorian = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "gregory", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert.sameValue(`${ obj.getPlainDateTimeFor(inst) }`, "1969-12-31T23:59:58.888888889"); -assert.sameValue(`${ obj.getPlainDateTimeFor(inst, fakeGregorian) }`, "1969-12-31T23:59:58.888888889[u-ca=gregory]"); - -// converts to Instant -assert.sameValue(`${ obj.getInstantFor(dt) }`, "1976-11-18T15:23:31.2345679Z"); - -// converts to string -assert.sameValue(`${ obj }`, obj.id) - -// offset prints with minute precision in instant.toString -assert.sameValue(inst.toString({ timeZone: obj }), "1969-12-31T23:59:58.888888889+00:00") - -// offset prints with minute precision prints in zdt.toString -var zdt = new Temporal.ZonedDateTime(0n, obj); -assert.sameValue(zdt.toString(), "1969-12-31T23:59:58.888888889+00:00[Custom/Subminute]"); - -// has no next transitions -assert.sameValue(obj.getNextTransition(), null) - -// has no previous transitions -assert.sameValue(obj.getPreviousTransition(), null) - -// works in Temporal.Now -assert(Temporal.Now.plainDateTimeISO(obj) instanceof Temporal.PlainDateTime); -assert(Temporal.Now.plainDateISO(obj) instanceof Temporal.PlainDate); -assert(Temporal.Now.plainTimeISO(obj) instanceof Temporal.PlainTime); diff --git a/test/staging/Temporal/UserTimezone/old/trivial-protocol.js b/test/staging/Temporal/UserTimezone/old/trivial-protocol.js deleted file mode 100644 index 4e58c47ca34..00000000000 --- a/test/staging/Temporal/UserTimezone/old/trivial-protocol.js +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: Trivial protocol implementation -features: [Temporal] ----*/ - -var obj = { - getOffsetNanosecondsFor() { - return 0; - }, - getPossibleInstantsFor(dateTime) { - var {year, month, day, hour, minute, second, millisecond, microsecond, nanosecond} = dateTime; - var dayNum = MakeDay(year, month, day); - var time = MakeTime(hour, minute, second, millisecond, microsecond, nanosecond); - var epochNs = MakeDate(dayNum, time); - return [new Temporal.Instant(epochNs)]; - }, - id: "Etc/Custom/UTC_Protocol", -}; -var inst = Temporal.Instant.fromEpochNanoseconds(0n); - -// offset prints in instant.toString -assert.sameValue(inst.toString({ timeZone: obj }), "1970-01-01T00:00:00+00:00") - -// prints in zdt.toString -var zdt = new Temporal.ZonedDateTime(0n, obj); -assert.sameValue(zdt.toString(), "1970-01-01T00:00:00+00:00[Etc/Custom/UTC_Protocol]"); - -// works in Temporal.Now -var fakeGregorian = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "gregory", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert(Temporal.Now.plainDateTimeISO(obj) instanceof Temporal.PlainDateTime); -assert(Temporal.Now.plainDateISO(obj) instanceof Temporal.PlainDate); -assert(Temporal.Now.plainTimeISO(obj) instanceof Temporal.PlainTime); diff --git a/test/staging/Temporal/UserTimezone/old/trivial-subclass.js b/test/staging/Temporal/UserTimezone/old/trivial-subclass.js deleted file mode 100644 index fe472774a85..00000000000 --- a/test/staging/Temporal/UserTimezone/old/trivial-subclass.js +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: Trivial subclass -features: [Temporal] ----*/ - -class CustomUTCSubclass extends Temporal.TimeZone { - constructor() { - super("UTC"); - } - get id() { - return "Etc/Custom/UTC_Subclass"; - } - toString() { - return "Etc/Custom/UTC_Subclass"; - } - getOffsetNanosecondsFor() { - return 0; - } - getPossibleInstantsFor(dateTime) { - var {year, month, day, hour, minute, second, millisecond, microsecond, nanosecond} = dateTime; - var dayNum = MakeDay(year, month, day); - var time = MakeTime(hour, minute, second, millisecond, microsecond, nanosecond); - var epochNs = MakeDate(dayNum, time); - return [new Temporal.Instant(epochNs)]; - } - getNextTransition() { - return null; - } - getPreviousTransition() { - return null; - } -} - -const nsPerDay = 86400_000_000_000n; -const nsPerMillisecond = 1_000_000n; - -function Day(t) { - return t / nsPerDay; -} - -function MakeDate(day, time) { - return day * nsPerDay + time; -} - -function MakeDay(year, month, day) { - const m = month - 1; - const ym = year + Math.floor(m / 12); - const mn = m % 12; - const t = BigInt(Date.UTC(ym, mn, 1)) * nsPerMillisecond; - return Day(t) + BigInt(day) - 1n; -} - -function MakeTime(h, min, s, ms, µs, ns) { - const MinutesPerHour = 60n; - const SecondsPerMinute = 60n; - const nsPerSecond = 1_000_000_000n; - const nsPerMinute = nsPerSecond * SecondsPerMinute; - const nsPerHour = nsPerMinute * MinutesPerHour; - return ( - BigInt(h) * nsPerHour + - BigInt(min) * nsPerMinute + - BigInt(s) * nsPerSecond + - BigInt(ms) * nsPerMillisecond + - BigInt(µs) * 1000n + - BigInt(ns) - ); -} - -var obj = new CustomUTCSubclass(); -var inst = Temporal.Instant.fromEpochNanoseconds(0n); -var dt = new Temporal.PlainDateTime(1976, 11, 18, 15, 23, 30, 123, 456, 789); - -// is a time zone -assert.sameValue(typeof obj, "object") - -// .id property -assert.sameValue(obj.id, "Etc/Custom/UTC_Subclass") - -// .id is not available in from() -assert.throws(RangeError, () => Temporal.TimeZone.from("Etc/Custom/UTC_Subclass")); -assert.throws(RangeError, () => Temporal.TimeZone.from("2020-05-26T16:02:46.251163036+00:00[Etc/Custom/UTC_Subclass]")); - -// has offset string +00:00 -assert.sameValue(obj.getOffsetStringFor(inst), "+00:00") - -// converts to DateTime -var fakeGregorian = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "gregory", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert.sameValue(`${ obj.getPlainDateTimeFor(inst) }`, "1970-01-01T00:00:00"); -assert.sameValue(`${ obj.getPlainDateTimeFor(inst, fakeGregorian) }`, "1970-01-01T00:00:00[u-ca=gregory]"); - -// converts to Instant -assert.sameValue(`${ obj.getInstantFor(dt) }`, "1976-11-18T15:23:30.123456789Z"); - -// converts to string -assert.sameValue(`${ obj }`, obj.id) - -// offset prints in instant.toString -assert.sameValue(inst.toString({ timeZone: obj }), "1970-01-01T00:00:00+00:00") - -// prints in zdt.toString -var zdt = new Temporal.ZonedDateTime(0n, obj); -assert.sameValue(zdt.toString(), "1970-01-01T00:00:00+00:00[Etc/Custom/UTC_Subclass]"); - -// has no next transitions -assert.sameValue(obj.getNextTransition(), null) - -// has no previous transitions -assert.sameValue(obj.getPreviousTransition(), null) - -// works in Temporal.Now -assert(Temporal.Now.plainDateTimeISO(obj) instanceof Temporal.PlainDateTime); -assert(Temporal.Now.plainDateISO(obj) instanceof Temporal.PlainDate); -assert(Temporal.Now.plainTimeISO(obj) instanceof Temporal.PlainTime); diff --git a/test/staging/Temporal/ZonedDateTime/old/compare.js b/test/staging/Temporal/ZonedDateTime/old/compare.js index 05678af3d05..e2a697cb7de 100644 --- a/test/staging/Temporal/ZonedDateTime/old/compare.js +++ b/test/staging/Temporal/ZonedDateTime/old/compare.js @@ -110,32 +110,6 @@ assert.throws(TypeError, () => Temporal.ZonedDateTime.compare(zdt1, { // disregards time zone IDs if exact times are equal assert.sameValue(Temporal.ZonedDateTime.compare(zdt1, zdt1.withTimeZone("+05:30")), 0); -// disregards calendar IDs if exact times and time zones are equal -var fakeJapanese = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "japanese", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert.sameValue(Temporal.ZonedDateTime.compare(zdt1, zdt1.withCalendar(fakeJapanese)), 0); - // compares exact time, not clock time var clockBefore = Temporal.ZonedDateTime.from("1999-12-31T23:30-08:00[-08:00]"); var clockAfter = Temporal.ZonedDateTime.from("2000-01-01T01:30-04:00[-04:00]"); diff --git a/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js b/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js index 64442e44e9b..cad759c9b8a 100644 --- a/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js +++ b/test/staging/Temporal/ZonedDateTime/old/construction-and-properties.js @@ -7,12 +7,11 @@ description: Construction and properties features: [Temporal] ---*/ -var tz = new Temporal.TimeZone("-08:00"); var epochMillis = Date.UTC(1976, 10, 18, 15, 23, 30, 123); var epochNanos = BigInt(epochMillis) * BigInt(1000000) + BigInt(456789); // works -var zdt = new Temporal.ZonedDateTime(epochNanos, tz); +var zdt = new Temporal.ZonedDateTime(epochNanos, "-08:00"); assert(zdt instanceof Temporal.ZonedDateTime); assert.sameValue(typeof zdt, "object"); assert.sameValue(zdt.toInstant().epochMilliseconds, Date.UTC(1976, 10, 18, 15, 23, 30, 123), "epochMilliseconds"); @@ -46,64 +45,3 @@ assert.sameValue(zdt.inLeapYear, true); assert.sameValue(zdt.offset, "+00:00"); assert.sameValue(zdt.offsetNanoseconds, 0); assert.sameValue(`${ zdt }`, "1976-11-18T15:23:30.123456789+00:00[UTC]"); - -// Temporal.ZonedDateTime with non-UTC time zone and non-ISO calendar -// can be constructed -var fakeGregorian = { - era() { return "ce"; }, - year(date) { return date.withCalendar("iso8601").year; }, - month(date) { return date.withCalendar("iso8601").month; }, - monthCode(date) { return date.withCalendar("iso8601").monthCode; }, - day(date) { return date.withCalendar("iso8601").day; }, - dayOfWeek(date) { return date.withCalendar("iso8601").dayOfWeek; }, - dayOfYear(date) { return date.withCalendar("iso8601").dayOfYear; }, - weekOfYear(date) { return date.withCalendar("iso8601").weekOfYear; }, - daysInWeek(date) { return date.withCalendar("iso8601").daysInWeek; }, - daysInMonth(date) { return date.withCalendar("iso8601").daysInMonth; }, - daysInYear(date) { return date.withCalendar("iso8601").daysInYear; }, - monthsInYear(date) { return date.withCalendar("iso8601").monthsInYear; }, - inLeapYear(date) { return date.withCalendar("iso8601").inLeapYear; }, - id: "gregory", - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - fields() {}, - mergeFields() {}, - monthDayFromFields() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -var fakeVienna = { - getOffsetNanosecondsFor() { return 3600_000_000_000; }, - getPossibleInstantsFor(datetime) { return [datetime.toZonedDateTime("+01:00").toInstant()]; }, - id: "Europe/Vienna", -} -var zdt = new Temporal.ZonedDateTime(epochNanos, fakeVienna, fakeGregorian); -assert(zdt instanceof Temporal.ZonedDateTime); -assert.sameValue(typeof zdt, "object"); - -assert.sameValue(zdt.era, "ce"); -assert.sameValue(zdt.year, 1976); -assert.sameValue(zdt.month, 11); -assert.sameValue(zdt.monthCode, "M11"); -assert.sameValue(zdt.day, 18); -assert.sameValue(zdt.hour, 16); -assert.sameValue(zdt.minute, 23); -assert.sameValue(zdt.second, 30); -assert.sameValue(zdt.millisecond, 123); -assert.sameValue(zdt.microsecond, 456); -assert.sameValue(zdt.nanosecond, 789); -assert.sameValue(zdt.epochMilliseconds, 217178610123); -assert.sameValue(zdt.epochNanoseconds, 217178610123456789n); -assert.sameValue(zdt.dayOfWeek, 4); -assert.sameValue(zdt.dayOfYear, 323); -assert.sameValue(zdt.weekOfYear, 47); -assert.sameValue(zdt.daysInWeek, 7); -assert.sameValue(zdt.daysInMonth, 30); -assert.sameValue(zdt.daysInYear, 366); -assert.sameValue(zdt.monthsInYear, 12); -assert.sameValue(zdt.inLeapYear, true); -assert.sameValue(zdt.offset, "+01:00"); -assert.sameValue(zdt.offsetNanoseconds, 3600000000000); -assert.sameValue(`${ zdt }`, "1976-11-18T16:23:30.123456789+01:00[Europe/Vienna][u-ca=gregory]"); - diff --git a/test/staging/Temporal/ZonedDateTime/old/equals.js b/test/staging/Temporal/ZonedDateTime/old/equals.js index b2623050eee..d0a458bcd60 100644 --- a/test/staging/Temporal/ZonedDateTime/old/equals.js +++ b/test/staging/Temporal/ZonedDateTime/old/equals.js @@ -7,35 +7,7 @@ description: Temporal.ZonedDateTime.prototype.equals() features: [Temporal] ---*/ -var tz = { - getOffsetNanosecondsFor() { return -5 * 3600_000_000_000; }, - getPossibleInstantsFor(pdt) { return Temporal.TimeZone.from("-05:00").getPossibleInstantsFor(pdt); }, - id: "America/New_York", -}; -var cal = { - dateFromFields(...args) { return Temporal.Calendar.from("iso8601").dateFromFields(...args); }, - id: "gregory", - dateAdd() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields(fieldNames) { return fieldNames; }, - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -var zdt = new Temporal.ZonedDateTime(0n, tz, cal); +var zdt = new Temporal.ZonedDateTime(0n, "-05:00", "iso8601"); // constructed from equivalent parameters are equal var zdt2 = Temporal.ZonedDateTime.from({ @@ -43,22 +15,18 @@ var zdt2 = Temporal.ZonedDateTime.from({ month: 12, day: 31, hour: 19, - timeZone: tz, - calendar: cal, + timeZone: "-05:00", + calendar: "iso8601", }); assert(zdt.equals(zdt2)); assert(zdt2.equals(zdt)); // different instant not equal -var zdt2 = new Temporal.ZonedDateTime(1n, tz, cal); +var zdt2 = new Temporal.ZonedDateTime(1n, "-05:00", "iso8601"); assert(!zdt.equals(zdt2)); // different time zone not equal -var zdt2 = new Temporal.ZonedDateTime(0n, "UTC", cal); -assert(!zdt.equals(zdt2)); - -// different calendar not equal -var zdt2 = new Temporal.ZonedDateTime(0n, tz, "iso8601"); +var zdt2 = new Temporal.ZonedDateTime(0n, "UTC", "iso8601"); assert(!zdt.equals(zdt2)); // casts its argument @@ -77,22 +45,22 @@ assert(!zdt.equals({ year: 1969, month: 12, day: 31, - timeZone: tz + timeZone: "-05:00" })); assert.throws(TypeError, () => zdt.equals({ month: 12, day: 31, - timeZone: tz + timeZone: "-05:00" })); assert.throws(TypeError, () => zdt.equals({ year: 1969, day: 31, - timeZone: tz + timeZone: "-05:00" })); assert.throws(TypeError, () => zdt.equals({ year: 1969, month: 12, - timeZone: tz + timeZone: "-05:00" })); assert.throws(TypeError, () => zdt.equals({ year: 1969, @@ -103,6 +71,6 @@ assert.throws(TypeError, () => zdt.equals({ years: 1969, months: 12, days: 31, - timeZone: tz, - calendarName: "gregory" + timeZone: "-05:00", + calendarName: "iso8601" })); diff --git a/test/staging/Temporal/ZonedDateTime/old/property-bags.js b/test/staging/Temporal/ZonedDateTime/old/property-bags.js index 21d3f134528..97976234904 100644 --- a/test/staging/Temporal/ZonedDateTime/old/property-bags.js +++ b/test/staging/Temporal/ZonedDateTime/old/property-bags.js @@ -4,18 +4,15 @@ /*--- esid: sec-temporal-zoneddatetime-objects description: property bags -includes: [temporalHelpers.js] features: [Temporal] ---*/ -var lagos = Temporal.TimeZone.from("+01:00"); - // can be constructed with monthCode and without month assert.sameValue(`${ Temporal.ZonedDateTime.from({ year: 1976, monthCode: "M11", day: 18, - timeZone: lagos + timeZone: "+01:00" }) }`, "1976-11-18T00:00:00+01:00[+01:00]"); // can be constructed with month and without monthCode @@ -23,7 +20,7 @@ assert.sameValue(`${ Temporal.ZonedDateTime.from({ year: 1976, month: 11, day: 18, - timeZone: lagos + timeZone: "+01:00" }) }`, "1976-11-18T00:00:00+01:00[+01:00]"); // month and monthCode must agree @@ -32,7 +29,7 @@ assert.throws(RangeError, () => Temporal.ZonedDateTime.from({ month: 11, monthCode: "M12", day: 18, - timeZone: lagos + timeZone: "+01:00" })); // Temporal.ZonedDateTime.from({}) throws @@ -44,7 +41,7 @@ assert.throws(TypeError, () => Temporal.ZonedDateTime.from({ month: undefined, monthCode: undefined, day: 18, - timeZone: lagos + timeZone: "+01:00" })) // options may be a function object @@ -52,7 +49,7 @@ assert.sameValue(`${ Temporal.ZonedDateTime.from({ year: 1976, month: 11, day: 18, - timeZone: lagos + timeZone: "+01:00" }, () => { }) }`, "1976-11-18T00:00:00+01:00[+01:00]"); @@ -61,7 +58,7 @@ assert.throws(TypeError, () => Temporal.ZonedDateTime.from({ years: 1976, months: 11, days: 18, - timeZone: lagos + timeZone: "+01:00" })); // incorrectly-spelled properties are ignored @@ -69,7 +66,7 @@ assert.sameValue(`${ Temporal.ZonedDateTime.from({ year: 1976, month: 11, day: 18, - timeZone: lagos, + timeZone: "+01:00", hours: 12 }) }`, "1976-11-18T00:00:00+01:00[+01:00]"); @@ -91,7 +88,7 @@ assert.sameValue(`${ Temporal.ZonedDateTime.from({ month: 11, day: 18, offset: offset, - timeZone: Temporal.TimeZone.from("+10:00") + timeZone: "+10:00" }) ) }); @@ -102,7 +99,7 @@ var bad = { year: 2019, month: 1, day: 32, - timeZone: lagos + timeZone: "+01:00" }; assert.throws(RangeError, () => Temporal.ZonedDateTime.from(bad, { overflow: "reject" })); assert.sameValue(`${ Temporal.ZonedDateTime.from(bad) }`, "2019-01-31T00:00:00+01:00[+01:00]"); @@ -133,142 +130,6 @@ var obj = { }; assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj)); assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { offset: "reject" })); - -var cali = TemporalHelpers.springForwardFallBackTimeZone(); -var date = { -year: 2000, -month: 10, -day: 29, -timeZone: cali -}; -// { offset: 'prefer' } if offset matches time zone (first 1:30 when DST ends) -var obj = { - ...date, - hour: 1, - minute: 30, - offset: "-07:00" -}; -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "prefer" }) }`, "2000-10-29T01:30:00-07:00[Custom/Spring_Fall]"); - -// { offset: 'prefer' } if offset matches time zone (second 1:30 when DST ends) -var obj = { - ...date, - hour: 1, - minute: 30, - offset: "-08:00" -}; -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "prefer" }) }`, "2000-10-29T01:30:00-08:00[Custom/Spring_Fall]"); - -// { offset: 'prefer' } if offset does not match time zone" -var obj = { - ...date, - hour: 4, - offset: "-07:00" -}; -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "prefer" }) }`, "2000-10-29T04:00:00-08:00[Custom/Spring_Fall]"); - -// { offset: 'ignore' } uses time zone only -var obj = { - ...date, - hour: 4, - offset: "-12:00" -}; -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "ignore" }) }`, "2000-10-29T04:00:00-08:00[Custom/Spring_Fall]"); - -// { offset: 'use' } uses offset only -var obj = { - ...date, - hour: 4, - offset: "-07:00" -}; -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset: "use" }) }`, "2000-10-29T03:00:00-08:00[Custom/Spring_Fall]"); - -// Disambiguation options - -// plain datetime with multiple instants - Fall DST -var obj = { - year: 2000, - month: 10, - day: 29, - hour: 1, - minute: 45, - timeZone: cali -}; -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj) }`, "2000-10-29T01:45:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "compatible" }) }`, "2000-10-29T01:45:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "earlier" }) }`, "2000-10-29T01:45:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "later" }) }`, "2000-10-29T01:45:00-08:00[Custom/Spring_Fall]"); -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { disambiguation: "reject" })); - -// plain datetime with multiple instants - Spring DST -var obj = { - year: 2000, - month: 4, - day: 2, - hour: 2, - minute: 30, - timeZone: cali -}; -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj) }`, "2000-04-02T03:30:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "compatible" }) }`, "2000-04-02T03:30:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "earlier" }) }`, "2000-04-02T01:30:00-08:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { disambiguation: "later" }) }`, "2000-04-02T03:30:00-07:00[Custom/Spring_Fall]"); -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { disambiguation: "reject" })); - -// uses disambiguation if offset is ignored -var obj = { - year: 2000, - month: 4, - day: 2, - hour: 2, - minute: 30, - timeZone: cali -}; -var offset = "ignore"; -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset }) }`, "2000-04-02T03:30:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { - offset, - disambiguation: "compatible" -}) }`, "2000-04-02T03:30:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { - offset, - disambiguation: "earlier" -}) }`, "2000-04-02T01:30:00-08:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { - offset, - disambiguation: "later" -}) }`, "2000-04-02T03:30:00-07:00[Custom/Spring_Fall]"); -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { disambiguation: "reject" })); - -// uses disambiguation if offset is wrong and option is prefer -var obj = { - year: 2000, - month: 4, - day: 2, - hour: 2, - minute: 30, - offset: "-23:59", - timeZone: cali -}; -var offset = "prefer"; -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { offset }) }`, "2000-04-02T03:30:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { - offset, - disambiguation: "compatible" -}) }`, "2000-04-02T03:30:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { - offset, - disambiguation: "earlier" -}) }`, "2000-04-02T01:30:00-08:00[Custom/Spring_Fall]"); -assert.sameValue(`${ Temporal.ZonedDateTime.from(obj, { - offset, - disambiguation: "later" -}) }`, "2000-04-02T03:30:00-07:00[Custom/Spring_Fall]"); -assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { - offset, - disambiguation: "reject" -})); - // throw when bad disambiguation [ "", @@ -279,15 +140,3 @@ assert.throws(RangeError, () => Temporal.ZonedDateTime.from(obj, { ].forEach(disambiguation => { assert.throws(RangeError, () => Temporal.ZonedDateTime.from("2020-11-01T04:00[UTC]", { disambiguation })); }); - -// sub-minute time zone offsets - -// does not truncate offset property to minutes -var zdt = Temporal.ZonedDateTime.from({ - year: 1971, - month: 1, - day: 1, - hour: 12, - timeZone: TemporalHelpers.specificOffsetTimeZone(-2.67e12) // -00:44:30 in nanoseconds -}); -assert.sameValue(zdt.offset, "-00:44:30"); diff --git a/test/staging/Temporal/ZonedDateTime/old/round.js b/test/staging/Temporal/ZonedDateTime/old/round.js index 32c1efc6067..9b13291f4c6 100644 --- a/test/staging/Temporal/ZonedDateTime/old/round.js +++ b/test/staging/Temporal/ZonedDateTime/old/round.js @@ -4,7 +4,6 @@ /*--- esid: sec-temporal-zoneddatetime-objects description: Temporal.ZonedDateTime.prototype.round() -includes: [temporalHelpers.js] features: [Temporal] ---*/ @@ -212,30 +211,3 @@ var bal = Temporal.ZonedDateTime.from("1976-11-18T23:59:59.999999999+01:00[+01:0 ].forEach(smallestUnit => { assert.sameValue(`${ bal.round({ smallestUnit }) }`, "1976-11-19T00:00:00+01:00[+01:00]"); }); - -var timeZone = TemporalHelpers.springForwardFallBackTimeZone(); - -// rounds correctly to a 25-hour day -// (the 12.5 hour is the halfway point, which is 11:30 local time, since 2:00-2:59 repeats) -var roundTo = { smallestUnit: "day" }; -var roundMeDown = Temporal.PlainDateTime.from("2000-10-29T11:29:59").toZonedDateTime(timeZone); -assert.sameValue(`${ roundMeDown.round(roundTo) }`, "2000-10-29T00:00:00-07:00[Custom/Spring_Fall]"); -var roundMeUp = Temporal.PlainDateTime.from("2000-10-29T11:30:01").toZonedDateTime(timeZone); -assert.sameValue(`${ roundMeUp.round(roundTo) }`, "2000-10-30T00:00:00-08:00[Custom/Spring_Fall]"); - -// rounds correctly to a 23-hour day -// (the 11.5 hour is the halfway point, which is 12:30 local time, since 2:00-2:59 skips) -var roundTo = { smallestUnit: "day" }; -var roundMeDown = Temporal.PlainDateTime.from("2000-04-02T12:29:59").toZonedDateTime(timeZone); -assert.sameValue(`${ roundMeDown.round(roundTo) }`, "2000-04-02T00:00:00-08:00[Custom/Spring_Fall]"); -var roundMeUp = Temporal.PlainDateTime.from("2000-04-02T12:30:01").toZonedDateTime(timeZone); -assert.sameValue(`${ roundMeUp.round(roundTo) }`, "2000-04-03T00:00:00-07:00[Custom/Spring_Fall]"); - -// rounding up to a nonexistent wall-clock time -var almostSkipped = Temporal.PlainDateTime.from("2000-04-02T01:59:59.999999999").toZonedDateTime(timeZone); -var rounded = almostSkipped.round({ - smallestUnit: "microsecond", - roundingMode: "halfExpand" -}); -assert.sameValue(`${ rounded }`, "2000-04-02T03:00:00-07:00[Custom/Spring_Fall]"); -assert.sameValue(rounded.epochNanoseconds - almostSkipped.epochNanoseconds, 1n); diff --git a/test/staging/Temporal/ZonedDateTime/old/since.js b/test/staging/Temporal/ZonedDateTime/old/since.js index 627defe6138..b9ed5fe5148 100644 --- a/test/staging/Temporal/ZonedDateTime/old/since.js +++ b/test/staging/Temporal/ZonedDateTime/old/since.js @@ -85,34 +85,6 @@ var monthsDifference = laterDateTime.since(zdt, { largestUnit: "months" }); assert.sameValue(monthsDifference.weeks, 0); assert.notSameValue(monthsDifference.months, 0); -// no two different calendars -var zdt1 = new Temporal.ZonedDateTime(0n, "UTC"); -var fakeJapanese = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "japanese", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -var zdt2 = new Temporal.ZonedDateTime(0n, "UTC", fakeJapanese); -assert.throws(RangeError, () => zdt1.since(zdt2)); - var earlier = Temporal.ZonedDateTime.from('2019-01-08T09:22:36.123456789+01:00[+01:00]'); var later = Temporal.ZonedDateTime.from('2021-09-07T13:39:40.987654321+01:00[+01:00]'); // assumes a different default for largestUnit if smallestUnit is larger than days diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js b/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js index 1cd3cefa0ef..b6283e897dd 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js +++ b/test/staging/Temporal/ZonedDateTime/old/toPlainDate.js @@ -7,35 +7,6 @@ description: Temporal.ZonedDateTime.prototype.toPlainDate() features: [Temporal] ---*/ -var tz = new Temporal.TimeZone("-07:00"); - // works -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO(tz); +var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO("-07:00"); assert.sameValue(`${ zdt.toPlainDate() }`, "2019-10-29"); - -// preserves the calendar -const fakeGregorian = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "gregory", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO(tz).withCalendar(fakeGregorian); -assert.sameValue(zdt.toPlainDate().getCalendar(), fakeGregorian); diff --git a/test/staging/Temporal/ZonedDateTime/old/toPlainTime.js b/test/staging/Temporal/ZonedDateTime/old/toPlainTime.js index 8e95119cc51..e932b1413c1 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toPlainTime.js +++ b/test/staging/Temporal/ZonedDateTime/old/toPlainTime.js @@ -7,8 +7,6 @@ description: Temporal.ZonedDateTime.prototype.toPlainTime() features: [Temporal] ---*/ -var tz = new Temporal.TimeZone("-07:00"); - // works -var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO(tz); +var zdt = Temporal.Instant.from("2019-10-29T09:46:38.271986102Z").toZonedDateTimeISO("-07:00"); assert.sameValue(`${ zdt.toPlainTime() }`, "02:46:38.271986102"); diff --git a/test/staging/Temporal/ZonedDateTime/old/toString.js b/test/staging/Temporal/ZonedDateTime/old/toString.js index 13c860ff56a..80637072a99 100644 --- a/test/staging/Temporal/ZonedDateTime/old/toString.js +++ b/test/staging/Temporal/ZonedDateTime/old/toString.js @@ -4,68 +4,13 @@ /*--- esid: sec-temporal-zoneddatetime-objects description: Temporal.ZonedDateTime.prototype.toString() -includes: [temporalHelpers.js] features: [Temporal] ---*/ var zdt1 = Temporal.ZonedDateTime.from("1976-11-18T15:23+00:00[UTC]"); -var fakeGregorian = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "gregory", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; // shows offset if offset = auto assert.sameValue(zdt1.toString({ offset: "auto" }), "1976-11-18T15:23:00+00:00[UTC]"); // omits offset if offset = never assert.sameValue(zdt1.toString({ offset: "never" }), "1976-11-18T15:23:00[UTC]"); - -// combinations of calendar, time zone, and offset -var zdt = zdt1.withCalendar(fakeGregorian); -assert.sameValue(zdt.toString({ - timeZoneName: "never", - calendarName: "never" -}), "1976-11-18T15:23:00+00:00"); -assert.sameValue(zdt.toString({ - offset: "never", - calendarName: "never" -}), "1976-11-18T15:23:00[UTC]"); -assert.sameValue(zdt.toString({ - offset: "never", - timeZoneName: "never" -}), "1976-11-18T15:23:00[u-ca=gregory]"); -assert.sameValue(zdt.toString({ - offset: "never", - timeZoneName: "never", - calendarName: "never" -}), "1976-11-18T15:23:00"); - -// rounding up to a nonexistent wall-clock time -var dst = TemporalHelpers.springForwardFallBackTimeZone(); -var zdt5 = Temporal.PlainDateTime.from("2000-04-02T01:59:59.999999999").toZonedDateTime(dst); -var roundedString = zdt5.toString({ - fractionalSecondDigits: 8, - roundingMode: "halfExpand" -}); -assert.sameValue(roundedString, "2000-04-02T03:00:00.00000000-07:00[Custom/Spring_Fall]"); -var zdt6 = Temporal.Instant.from(roundedString); -assert.sameValue(zdt6.epochNanoseconds - zdt5.epochNanoseconds, 1n); diff --git a/test/staging/Temporal/ZonedDateTime/old/until.js b/test/staging/Temporal/ZonedDateTime/old/until.js index 67280f879a5..98bd330237b 100644 --- a/test/staging/Temporal/ZonedDateTime/old/until.js +++ b/test/staging/Temporal/ZonedDateTime/old/until.js @@ -85,34 +85,6 @@ var monthsDifference = zdt.until(laterDateTime, { largestUnit: "months" }); assert.sameValue(monthsDifference.weeks, 0); assert.notSameValue(monthsDifference.months, 0); -// no two different calendars -var zdt1 = new Temporal.ZonedDateTime(0n, "UTC"); -var fakeJapanese = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "japanese", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -var zdt2 = new Temporal.ZonedDateTime(0n, "UTC", fakeJapanese); -assert.throws(RangeError, () => zdt1.until(zdt2)); - var earlier = Temporal.ZonedDateTime.from('2019-01-08T09:22:36.123456789+01:00[+01:00]'); var later = Temporal.ZonedDateTime.from('2021-09-07T13:39:40.987654321+01:00[+01:00]'); // assumes a different default for largestUnit if smallestUnit is larger than hours diff --git a/test/staging/Temporal/ZonedDateTime/old/with.js b/test/staging/Temporal/ZonedDateTime/old/with.js index 703fc681a19..a71a7d03e1e 100644 --- a/test/staging/Temporal/ZonedDateTime/old/with.js +++ b/test/staging/Temporal/ZonedDateTime/old/with.js @@ -4,7 +4,6 @@ /*--- esid: sec-temporal-zoneddatetime-objects description: Temporal.ZonedDateTime.prototype.with() -includes: [temporalHelpers.js] features: [Temporal] ---*/ @@ -67,76 +66,6 @@ assert.throws(RangeError, () => zdt.with({ day: 31 }, { overflow })); assert.throws(RangeError, () => zdt.with({ hour: 29 }, { overflow })); assert.throws(RangeError, () => zdt.with({ nanosecond: 9000 }, { overflow })); -var dst = TemporalHelpers.springForwardFallBackTimeZone(); -var dstStartDay = Temporal.PlainDateTime.from("2000-04-02T12:00:01").toZonedDateTime(dst); -var dstEndDay = Temporal.PlainDateTime.from("2000-10-29T12:00:01").toZonedDateTime(dst); -var oneThirty = { -hour: 1, -minute: 30 -}; -var twoThirty = { -hour: 2, -minute: 30 -}; - -// Disambiguation options -var offset = "ignore"; -// compatible, skipped wall time -assert.sameValue(`${ dstStartDay.with(twoThirty, { - offset, - disambiguation: "compatible" -}) }`, "2000-04-02T03:30:01-07:00[Custom/Spring_Fall]"); - -// earlier, skipped wall time -assert.sameValue(`${ dstStartDay.with(twoThirty, { - offset, - disambiguation: "earlier" -}) }`, "2000-04-02T01:30:01-08:00[Custom/Spring_Fall]"); - -// later, skipped wall time -assert.sameValue(`${ dstStartDay.with(twoThirty, { - offset, - disambiguation: "later" -}) }`, "2000-04-02T03:30:01-07:00[Custom/Spring_Fall]"); - -// compatible, repeated wall time -assert.sameValue(`${ dstEndDay.with(oneThirty, { - offset, - disambiguation: "compatible" -}) }`, "2000-10-29T01:30:01-07:00[Custom/Spring_Fall]"); - -// earlier, repeated wall time -assert.sameValue(`${ dstEndDay.with(oneThirty, { - offset, - disambiguation: "earlier" -}) }`, "2000-10-29T01:30:01-07:00[Custom/Spring_Fall]"); - -// later, repeated wall time -assert.sameValue(`${ dstEndDay.with(oneThirty, { - offset, - disambiguation: "later" -}) }`, "2000-10-29T01:30:01-08:00[Custom/Spring_Fall]"); - -// reject -assert.throws(RangeError, () => dstStartDay.with(twoThirty, { - offset, - disambiguation: "reject" -})); -assert.throws(RangeError, () => dstEndDay.with(oneThirty, { - offset, - disambiguation: "reject" -})); - -// compatible is the default -assert.sameValue(`${ dstStartDay.with(twoThirty, { offset }) }`, `${ dstStartDay.with(twoThirty, { - offset, - disambiguation: "compatible" -}) }`); -assert.sameValue(`${ dstEndDay.with(twoThirty, { offset }) }`, `${ dstEndDay.with(twoThirty, { - offset, - disambiguation: "compatible" -}) }`); - // invalid disambiguation [ "", @@ -144,84 +73,6 @@ assert.sameValue(`${ dstEndDay.with(twoThirty, { offset }) }`, `${ dstEndDay.wit "balance" ].forEach(disambiguation => assert.throws(RangeError, () => zdt.with({ day: 5 }, { disambiguation }))); -// Offset options -var bogus = { - ...twoThirty, - offset: "+23:59" -}; -// use, with bogus offset, changes to the exact time with the offset -var preserveExact = dstStartDay.with(bogus, { offset: "use" }); -assert.sameValue(`${ preserveExact }`, "2000-03-31T18:31:01-08:00[Custom/Spring_Fall]"); -assert.sameValue(preserveExact.epochNanoseconds, Temporal.Instant.from("2000-04-02T02:30:01+23:59").epochNanoseconds); - -// ignore, with bogus offset, defers to disambiguation option -var offset = "ignore"; -assert.sameValue(`${ dstStartDay.with(bogus, { - offset, - disambiguation: "earlier" -}) }`, "2000-04-02T01:30:01-08:00[Custom/Spring_Fall]"); -assert.sameValue(`${ dstStartDay.with(bogus, { - offset, - disambiguation: "later" -}) }`, "2000-04-02T03:30:01-07:00[Custom/Spring_Fall]"); - -// prefer, with bogus offset, defers to disambiguation option -var offset = "prefer"; -assert.sameValue(`${ dstStartDay.with(bogus, { - offset, - disambiguation: "earlier" -}) }`, "2000-04-02T01:30:01-08:00[Custom/Spring_Fall]"); -assert.sameValue(`${ dstStartDay.with(bogus, { - offset, - disambiguation: "later" -}) }`, "2000-04-02T03:30:01-07:00[Custom/Spring_Fall]"); - -// reject, with bogus offset, throws -assert.throws(RangeError, () => dstStartDay.with({ - ...twoThirty, - offset: "+23:59" -}, { offset: "reject" })); - -var doubleTime = new Temporal.ZonedDateTime(972811801_000_000_000n, dst); -// use changes to the exact time with the offset -var preserveExact = doubleTime.with({ offset: "-07:00" }, { offset: "use" }); -assert.sameValue(preserveExact.offset, "-07:00"); -assert.sameValue(preserveExact.epochNanoseconds, Temporal.Instant.from("2000-10-29T01:30:01-07:00").epochNanoseconds); - -// ignore defers to disambiguation option -var offset = "ignore"; -assert.sameValue(doubleTime.with({ offset: "-07:00" }, { - offset, - disambiguation: "earlier" -}).offset, "-07:00"); -assert.sameValue(doubleTime.with({ offset: "-07:00" }, { - offset, - disambiguation: "later" -}).offset, "-08:00"); - -// prefer adjusts offset of repeated clock time -assert.sameValue(doubleTime.with({ offset: "-07:00" }, { offset: "prefer" }).offset, "-07:00"); - -// reject adjusts offset of repeated clock time -assert.sameValue(doubleTime.with({ offset: "-07:00" }, { offset: "reject" }).offset, "-07:00"); - -// use does not cause the offset to change when adjusting repeated clock time -assert.sameValue(doubleTime.with({ minute: 31 }, { offset: "use" }).offset, "-08:00"); - -// ignore may cause the offset to change when adjusting repeated clock time -assert.sameValue(doubleTime.with({ minute: 31 }, { offset: "ignore" }).offset, "-07:00"); - -// prefer does not cause the offset to change when adjusting repeated clock time -assert.sameValue(doubleTime.with({ minute: 31 }, { offset: "prefer" }).offset, "-08:00"); - -// reject does not cause the offset to change when adjusting repeated clock time -assert.sameValue(doubleTime.with({ minute: 31 }, { offset: "reject" }).offset, "-08:00"); - -// prefer is the default -assert.sameValue(`${ dstStartDay.with(twoThirty) }`, `${ dstStartDay.with(twoThirty, { offset: "prefer" }) }`); -assert.sameValue(`${ dstEndDay.with(twoThirty) }`, `${ dstEndDay.with(twoThirty, { offset: "prefer" }) }`); -assert.sameValue(`${ doubleTime.with({ minute: 31 }) }`, `${ doubleTime.with({ minute: 31 }, { offset: "prefer" }) }`); - // invalid offset [ "", @@ -246,7 +97,7 @@ assert.throws(TypeError, () => zdt.with({ })); // throws if given a Temporal object with a time zone -assert.throws(TypeError, () => zdt.with(dstStartDay)); +assert.throws(TypeError, () => zdt.with(zdt)); // throws if calendarName is included assert.throws(TypeError, () => zdt.with({ diff --git a/test/staging/Temporal/ZonedDateTime/old/withCalendar.js b/test/staging/Temporal/ZonedDateTime/old/withCalendar.js deleted file mode 100644 index db9dec80771..00000000000 --- a/test/staging/Temporal/ZonedDateTime/old/withCalendar.js +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2018 Bloomberg LP. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -esid: sec-temporal-zoneddatetime-objects -description: Temporal.ZonedDateTime.prototype.withCalendar() -features: [Temporal] ----*/ - -var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789-08:00[-08:00]"); - -// zonedDateTime.withCalendar(japanese) works -var cal = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "japanese", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -assert.sameValue(`${ zdt.withCalendar(cal) }`, "2019-11-18T15:23:30.123456789-08:00[-08:00][u-ca=japanese]"); - -// keeps instant and time zone the same -var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00][u-ca=iso8601]"); -var zdt2 = zdt.withCalendar(cal); -assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds); -assert.sameValue(zdt2.getCalendar(), cal); -assert.sameValue(zdt2.timeZoneId, "+01:00"); diff --git a/test/staging/Temporal/ZonedDateTime/old/withTimezone.js b/test/staging/Temporal/ZonedDateTime/old/withTimezone.js index f05c2c52774..e9e3fd18088 100644 --- a/test/staging/Temporal/ZonedDateTime/old/withTimezone.js +++ b/test/staging/Temporal/ZonedDateTime/old/withTimezone.js @@ -7,33 +7,9 @@ description: Temporal.ZonedDateTime.prototype.withTimeZone() features: [Temporal] ---*/ -// keeps instant and calendar the same -var fakeGregorian = { - dateAdd() {}, - dateFromFields() {}, - dateUntil() {}, - day() {}, - dayOfWeek() {}, - dayOfYear() {}, - daysInMonth() {}, - daysInWeek() {}, - daysInYear() {}, - fields() {}, - id: "gregory", - inLeapYear() {}, - mergeFields() {}, - month() {}, - monthCode() {}, - monthDayFromFields() {}, - monthsInYear() {}, - weekOfYear() {}, - year() {}, - yearMonthFromFields() {}, - yearOfWeek() {}, -}; -var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00]").withCalendar(fakeGregorian); +// keeps instant the same +var zdt = Temporal.ZonedDateTime.from("2019-11-18T15:23:30.123456789+01:00[+01:00]"); var zdt2 = zdt.withTimeZone("-08:00"); assert.sameValue(zdt.epochNanoseconds, zdt2.epochNanoseconds); -assert.sameValue(zdt2.getCalendar(), fakeGregorian); assert.sameValue(zdt2.timeZoneId, "-08:00"); assert.notSameValue(`${ zdt.toPlainDateTime() }`, `${ zdt2.toPlainDateTime() }`); diff --git a/test/staging/Temporal/removed-methods.js b/test/staging/Temporal/removed-methods.js new file mode 100644 index 00000000000..28e4083ed14 --- /dev/null +++ b/test/staging/Temporal/removed-methods.js @@ -0,0 +1,69 @@ +// Copyright (C) 2024 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal +description: Test June 2024 Temporal API removals +info: > + This staging test fails if the Temporal API removals, which reached consensus + in the TC39 meeting of June 2024, are not implemented. + + Technically, it's spec-compliant to expose extra properties and methods, as + long as they are not in the forbidden extensions list. So it's possible that + your implementation might fail this test while still being compliant. + + But still, please don't do that! If you believe this test is in error, open an + issue on the Temporal proposal repo: https://github.com/tc39/proposal-temporal +features: [Temporal] +---*/ + +assert(!("Calendar" in Temporal), "Temporal.Calendar should not exist"); +assert(!("TimeZone" in Temporal), "Temporal.TimeZone should not exist"); + +const { Instant } = Temporal; +assert(!("fromEpochMicroseconds" in Instant), "Temporal.Instant.fromEpochMicroseconds should not exist"); +assert(!("fromEpochSeconds" in Instant), "Temporal.Instant.fromEpochSeconds should not exist"); + +const InstantProto = Temporal.Instant.prototype; +assert(!("epochMicroseconds" in InstantProto), "Temporal.Instant.prototype.epochMicroseconds should not exist"); +assert(!("epochSeconds" in InstantProto), "Temporal.Instant.prototype.epochSeconds should not exist"); +assert(!("toZonedDateTime" in InstantProto), "Temporal.Instant.prototype.toZonedDateTime should not exist"); + +const { Now } = Temporal; +assert(!("plainDate" in Now), "Temporal.Now.plainDate should not exist"); +assert(!("plainDateTime" in Now), "Temporal.Now.plainDateTime should not exist"); +assert(!("zonedDateTime" in Now), "Temporal.Now.zonedDateTime should not exist"); + +const PlainDateProto = Temporal.PlainDate.prototype; +assert(!("getCalendar" in PlainDateProto), "Temporal.PlainDate.prototype.getCalendar should not exist"); +assert(!("getISOFields" in PlainDateProto), "Temporal.PlainDate.prototype.getISOFields should not exist"); + +const PlainDateTimeProto = Temporal.PlainDateTime.prototype; +assert(!("getCalendar" in PlainDateTimeProto), "Temporal.PlainDateTime.prototype.getCalendar should not exist"); +assert(!("getISOFields" in PlainDateTimeProto), "Temporal.PlainDateTime.prototype.getISOFields should not exist"); +assert(!("toPlainMonthDay" in PlainDateTimeProto), "Temporal.PlainDateTime.prototype.toPlainMonthDay should not exist"); +assert(!("toPlainYearMonth" in PlainDateTimeProto), "Temporal.PlainDateTime.prototype.toPlainYearMonth should not exist"); +assert(!("withPlainDate" in PlainDateTimeProto), "Temporal.PlainDateTime.prototype.withPlainDate should not exist"); + +const PlainMonthDayProto = Temporal.PlainMonthDay.prototype; +assert(!("getCalendar" in PlainMonthDayProto), "Temporal.PlainMonthDay.prototype.getCalendar should not exist"); +assert(!("getISOFields" in PlainMonthDayProto), "Temporal.PlainMonthDay.prototype.getISOFields should not exist"); + +const PlainTimeProto = Temporal.PlainTime.prototype; +assert(!("getISOFields" in PlainTimeProto), "Temporal.PlainTime.prototype.getISOFields should not exist"); +assert(!("toPlainDateTime" in PlainTimeProto), "Temporal.PlainTime.prototype.toPlainDateTime should not exist"); +assert(!("toZonedDateTime" in PlainTimeProto), "Temporal.PlainTime.prototype.toZonedDateTime should not exist"); + +const PlainYearMonthProto = Temporal.PlainYearMonth.prototype; +assert(!("getCalendar" in PlainYearMonthProto), "Temporal.PlainYearMonth.prototype.getCalendar should not exist"); +assert(!("getISOFields" in PlainYearMonthProto), "Temporal.PlainYearMonth.prototype.getISOFields should not exist"); + +const ZonedDateTimeProto = Temporal.ZonedDateTime.prototype; +assert(!("epochMicroseconds" in ZonedDateTimeProto), "Temporal.ZonedDateTime.prototype.epochMicroseconds should not exist"); +assert(!("epochSeconds" in ZonedDateTimeProto), "Temporal.ZonedDateTime.prototype.epochSeconds should not exist"); +assert(!("getCalendar" in ZonedDateTimeProto), "Temporal.ZonedDateTime.prototype.getCalendar should not exist"); +assert(!("getISOFields" in ZonedDateTimeProto), "Temporal.ZonedDateTime.prototype.getISOFields should not exist"); +assert(!("getTimeZone" in ZonedDateTimeProto), "Temporal.ZonedDateTime.prototype.getTimeZone should not exist"); +assert(!("toPlainMonthDay" in ZonedDateTimeProto), "Temporal.ZonedDateTime.prototype.toPlainMonthDay should not exist"); +assert(!("toPlainYearMonth" in ZonedDateTimeProto), "Temporal.ZonedDateTime.prototype.toPlainYearMonth should not exist"); +assert(!("withPlainDate" in ZonedDateTimeProto), "Temporal.ZonedDateTime.prototype.withPlainDate should not exist");