Skip to content

Commit

Permalink
Update test262 7/3
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=258846
rdar://111724018

Reviewed by Keith Miller and Mark Lam.

Mechanically update it to ToT version. We should update test262
mechanically to reduce the cost of update of test262.

* JSTests/test262/config.yaml:
* JSTests/test262/expectations.yaml:

Canonical link: https://commits.webkit.org/265911@main
  • Loading branch information
Constellation committed Jul 10, 2023
1 parent cbe26af commit 6185c5f
Show file tree
Hide file tree
Showing 2,086 changed files with 33,504 additions and 10,762 deletions.
1 change: 1 addition & 0 deletions JSTests/test262/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ skip:
- callable-boundary-realms
- FinalizationRegistry.prototype.cleanupSome
- decorators
- iterator-helpers
- Intl.DurationFormat
- Intl.Locale-info # Getters are replaced with methods.
paths:
Expand Down
455 changes: 345 additions & 110 deletions JSTests/test262/expectations.yaml

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions JSTests/test262/harness/regExpUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ function printStringCodePoints(string) {
function testPropertyEscapes(regExp, string, expression) {
if (!regExp.test(string)) {
for (const symbol of string) {
const hex = printCodePoint(symbol.codePointAt(0));
const formatted = printCodePoint(symbol.codePointAt(0));
assert(
regExp.test(symbol),
`\`${ expression }\` should match U+${ hex } (\`${ symbol }\`)`
`\`${ expression }\` should match ${ formatted } (\`${ symbol }\`)`
);
}
}
Expand All @@ -73,7 +73,7 @@ function testPropertyOfStrings(args) {
for (const string of matchStrings) {
assert(
regExp.test(string),
`\`${ expression }\` should match ${ string } (U+${ printStringCodePoints(string) })`
`\`${ expression }\` should match ${ string } (${ printStringCodePoints(string) })`
);
}
}
Expand All @@ -83,7 +83,7 @@ function testPropertyOfStrings(args) {
for (const string of nonMatchStrings) {
assert(
!regExp.test(string),
`\`${ expression }\` should not match ${ string } (U+${ printStringCodePoints(string) })`
`\`${ expression }\` should not match ${ string } (${ printStringCodePoints(string) })`
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion JSTests/test262/harness/sta.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Test262Error.prototype.toString = function () {
return "Test262Error: " + this.message;
};

Test262Error.thrower = (message) => {
Test262Error.thrower = function (message) {
throw new Test262Error(message);
};

Expand Down
135 changes: 111 additions & 24 deletions JSTests/test262/harness/temporalHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ defines: [TemporalHelpers]
features: [Symbol.species, Symbol.iterator, Temporal]
---*/

const ASCII_IDENTIFIER = /^[$_a-zA-Z][$_a-zA-Z0-9]*$/u;

function formatPropertyName(propertyKey, objectName = "") {
switch (typeof propertyKey) {
case "symbol":
Expand All @@ -17,12 +19,20 @@ function formatPropertyName(propertyKey, objectName = "") {
} else {
return `${objectName}[Symbol('${propertyKey.description}')]`
}
case "number":
return `${objectName}[${propertyKey}]`;
case "string":
if (propertyKey !== String(Number(propertyKey))) {
if (ASCII_IDENTIFIER.test(propertyKey)) {
return objectName ? `${objectName}.${propertyKey}` : propertyKey;
}
return `${objectName}['${propertyKey.replace(/'/g, "\\'")}']`
}
// fall through
default:
return objectName ? `${objectName}.${propertyKey}` : propertyKey;
// integer or string integer-index
return `${objectName}[${propertyKey}]`;
}
}

const SKIP_SYMBOL = Symbol("Skip");

var TemporalHelpers = {
Expand Down Expand Up @@ -75,7 +85,7 @@ var TemporalHelpers = {
* Shorthand for asserting that each field of a Temporal.PlainDate is equal to
* an expected value. (Except the `calendar` property, since callers may want
* to assert either object equality with an object they put in there, or the
* result of date.calendar.toString().)
* value of date.calendarId.)
*/
assertPlainDate(date, year, month, monthCode, day, description = "", era = undefined, eraYear = undefined) {
assert(date instanceof Temporal.PlainDate, `${description} instanceof`);
Expand All @@ -93,7 +103,7 @@ var TemporalHelpers = {
* Shorthand for asserting that each field of a Temporal.PlainDateTime is
* equal to an expected value. (Except the `calendar` property, since callers
* may want to assert either object equality with an object they put in there,
* or the result of datetime.calendar.toString().)
* or the value of datetime.calendarId.)
*/
assertPlainDateTime(datetime, year, month, monthCode, day, hour, minute, second, millisecond, microsecond, nanosecond, description = "", era = undefined, eraYear = undefined) {
assert(datetime instanceof Temporal.PlainDateTime, `${description} instanceof`);
Expand All @@ -116,13 +126,17 @@ var TemporalHelpers = {
*
* Shorthand for asserting that two Temporal.PlainDateTimes are of the correct
* type, equal according to their equals() methods, and additionally that
* their calendars are the same value.
* their calendar internal slots are the same value.
*/
assertPlainDateTimesEqual(actual, expected, description = "") {
assert(expected instanceof Temporal.PlainDateTime, `${description} expected value should be a Temporal.PlainDateTime`);
assert(actual instanceof Temporal.PlainDateTime, `${description} instanceof`);
assert(actual.equals(expected), `${description} equals method`);
assert.sameValue(actual.calendar, expected.calendar, `${description} calendar same value`);
assert.sameValue(
actual.getISOFields().calendar,
expected.getISOFields().calendar,
`${description} calendar same value`
);
},

/*
Expand All @@ -131,7 +145,7 @@ var TemporalHelpers = {
* Shorthand for asserting that each field of a Temporal.PlainMonthDay is
* equal to an expected value. (Except the `calendar` property, since callers
* may want to assert either object equality with an object they put in there,
* or the result of monthDay.calendar.toString().)
* or the value of monthDay.calendarId().)
*/
assertPlainMonthDay(monthDay, monthCode, day, description = "", referenceISOYear = 1972) {
assert(monthDay instanceof Temporal.PlainMonthDay, `${description} instanceof`);
Expand Down Expand Up @@ -174,7 +188,7 @@ var TemporalHelpers = {
* Shorthand for asserting that each field of a Temporal.PlainYearMonth is
* equal to an expected value. (Except the `calendar` property, since callers
* may want to assert either object equality with an object they put in there,
* or the result of yearMonth.calendar.toString().)
* or the value of yearMonth.calendarId.)
*/
assertPlainYearMonth(yearMonth, year, month, monthCode, description = "", era = undefined, eraYear = undefined, referenceISODay = 1) {
assert(yearMonth instanceof Temporal.PlainYearMonth, `${description} instanceof`);
Expand All @@ -191,14 +205,18 @@ var TemporalHelpers = {
*
* Shorthand for asserting that two Temporal.ZonedDateTimes are of the correct
* type, equal according to their equals() methods, and additionally that
* their time zones and calendars are the same value.
* their time zones and calendar internal slots are the same value.
*/
assertZonedDateTimesEqual(actual, expected, description = "") {
assert(expected instanceof Temporal.ZonedDateTime, `${description} expected value should be a Temporal.ZonedDateTime`);
assert(actual instanceof Temporal.ZonedDateTime, `${description} instanceof`);
assert(actual.equals(expected), `${description} equals method`);
assert.sameValue(actual.timeZone, expected.timeZone, `${description} time zone same value`);
assert.sameValue(actual.calendar, expected.calendar, `${description} calendar same value`);
assert.sameValue(
actual.getISOFields().calendar,
expected.getISOFields().calendar,
`${description} calendar same value`
);
},

/*
Expand Down Expand Up @@ -831,6 +849,20 @@ var TemporalHelpers = {
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";
}
Expand Down Expand Up @@ -1051,13 +1083,17 @@ var TemporalHelpers = {
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);
return super.dateAdd(date, duration, options).withCalendar(this);
}
}
return new CalendarDateAddPlainDateInstance();
Expand Down Expand Up @@ -1437,6 +1473,34 @@ var TemporalHelpers = {
* 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) {
Expand All @@ -1449,8 +1513,7 @@ var TemporalHelpers = {
// 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);
// Remove the HasProperty check resulting from the above constructor call
assert.sameValue(calls.pop(), `has ${objectName}.calendar`);
removeExtraHasPropertyChecks(objectName, calls);
return result;
},
yearMonthFromFields(...args) {
Expand All @@ -1463,8 +1526,7 @@ var TemporalHelpers = {
// 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);
// Remove the HasProperty check resulting from the above constructor call
assert.sameValue(calls.pop(), `has ${objectName}.calendar`);
removeExtraHasPropertyChecks(objectName, calls);
return result;
},
monthDayFromFields(...args) {
Expand All @@ -1477,8 +1539,7 @@ var TemporalHelpers = {
// 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);
// Remove the HasProperty check resulting from the above constructor call
assert.sameValue(calls.pop(), `has ${objectName}.calendar`);
removeExtraHasPropertyChecks(objectName, calls);
return result;
},
dateAdd(...args) {
Expand All @@ -1490,13 +1551,33 @@ var TemporalHelpers = {
const originalResult = iso8601.dateAdd(...args);
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this);
// Remove the HasProperty check resulting from the above constructor call
assert.sameValue(calls.pop(), `has ${objectName}.calendar`);
removeExtraHasPropertyChecks(objectName, calls);
return result;
}
},
id: "iso8601",
};
// Automatically generate the other methods that don't need any custom code
["toString", "dateUntil", "era", "eraYear", "year", "month", "monthCode", "day", "daysInMonth", "fields", "mergeFields"].forEach((methodName) => {
[
"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) {
Expand Down Expand Up @@ -1669,7 +1750,7 @@ var TemporalHelpers = {
if (result === undefined) {
return undefined;
}
if (typeof result === "object") {
if ((result !== null && typeof result === "object") || typeof result === "function") {
return result;
}
return TemporalHelpers.toPrimitiveObserver(calls, result, `${formatPropertyName(key, objectName)}`);
Expand Down Expand Up @@ -1770,6 +1851,10 @@ var TemporalHelpers = {
return null;
}

get id() {
return "Custom/Spring_Fall";
}

toString() {
return "Custom/Spring_Fall";
}
Expand All @@ -1790,7 +1875,9 @@ var TemporalHelpers = {
*/
timeZoneObserver(calls, objectName, methodOverrides = {}) {
const utc = new Temporal.TimeZone("UTC");
const trackingMethods = {};
const trackingMethods = {
id: "UTC",
};
// Automatically generate the methods
["getOffsetNanosecondsFor", "getPossibleInstantsFor", "toString"].forEach((methodName) => {
trackingMethods[methodName] = function (...args) {
Expand Down

0 comments on commit 6185c5f

Please sign in to comment.