diff options
Diffstat (limited to 'js/src/tests/test262/staging')
30 files changed, 618 insertions, 81 deletions
diff --git a/js/src/tests/test262/staging/Intl402/Temporal/old/non-iso-calendars.js b/js/src/tests/test262/staging/Intl402/Temporal/old/non-iso-calendars.js index a4f1a2908f..4639e58e9e 100644 --- a/js/src/tests/test262/staging/Intl402/Temporal/old/non-iso-calendars.js +++ b/js/src/tests/test262/staging/Intl402/Temporal/old/non-iso-calendars.js @@ -6,6 +6,26 @@ esid: sec-temporal-intl description: Non-ISO Calendars features: [Temporal, Array.prototype.includes] +locale: + - en-US-u-ca-iso8601 + - en-US-u-ca-buddhist + - en-US-u-ca-chinese + - en-US-u-ca-coptic + - en-US-u-ca-dangi + - en-US-u-ca-ethioaa + - en-US-u-ca-ethiopic + - en-US-u-ca-gregory + - en-US-u-ca-hebrew + - en-US-u-ca-indian + - en-US-u-ca-islamic + - en-US-u-ca-islamic-umalqura + - en-US-u-ca-islamic-tbla + - en-US-u-ca-islamic-civil + - en-US-u-ca-islamic-rgsa + - en-US-u-ca-islamicc + - en-US-u-ca-japanese + - en-US-u-ca-persian + - en-US-u-ca-roc ---*/ var testChineseData = new Date("2001-02-01T00:00Z").toLocaleString("en-US-u-ca-chinese", { @@ -18,69 +38,256 @@ var testChineseData = new Date("2001-02-01T00:00Z").toLocaleString("en-US-u-ca-c var hasOutdatedChineseIcuData = !testChineseData.endsWith("2001"); // verify that Intl.DateTimeFormat.formatToParts output matches snapshot data -var getLocalizedDates = isoString => { - var calendars = [ - "iso8601", - "buddhist", - "chinese", - "coptic", - "dangi", - "ethioaa", - "ethiopic", - "gregory", - "hebrew", - "indian", - "islamic", - "islamic-umalqura", - "islamic-tbla", - "islamic-civil", - "islamic-rgsa", - "islamicc", - "japanese", - "persian", - "roc" - ]; - var date = new Date(isoString); - return calendars.map(id => `${ id }: ${ date.toLocaleDateString(`en-US-u-ca-${ id }`, { timeZone: "UTC" }) }`).join("\n"); -}; -var year2000Content = getLocalizedDates("2000-01-01T00:00Z"); -var year1Content = getLocalizedDates("0001-01-01T00:00Z"); -var year2000Snapshot = "iso8601: 1/1/2000\n" + "buddhist: 1/1/2543 BE\n" + "chinese: 11/25/1999\n" + "coptic: 4/22/1716 ERA1\n" + "dangi: 11/25/1999\n" + "ethioaa: 4/22/7492 ERA0\n" + "ethiopic: 4/22/1992 ERA1\n" + "gregory: 1/1/2000\n" + "hebrew: 23 Tevet 5760\n" + "indian: 10/11/1921 Saka\n" + "islamic: 9/25/1420 AH\n" + "islamic-umalqura: 9/24/1420 AH\n" + "islamic-tbla: 9/25/1420 AH\n" + "islamic-civil: 9/24/1420 AH\n" + "islamic-rgsa: 9/25/1420 AH\n" + "islamicc: 9/24/1420 AH\n" + "japanese: 1/1/12 H\n" + "persian: 10/11/1378 AP\n" + "roc: 1/1/89 Minguo"; -assert.sameValue(year2000Content, year2000Snapshot); +function compareFormatToPartsSnapshot(isoString, expected) { + const date = new Date(isoString); + Object.entries(expected).forEach(([calendar, expectedComponents]) => { + const formatter = new Intl.DateTimeFormat(`en-US-u-ca-${calendar}`, { timeZone: "UTC" }); + const actualComponents = formatter.formatToParts(date); + Object.entries(expectedComponents).forEach(([expectedType, expectedValue]) => { + const part = actualComponents.find(({type}) => type === expectedType); + const contextMessage = `${expectedType} component of ${isoString} formatted in ${calendar}`; + assert.notSameValue(part, undefined, contextMessage); + assert.sameValue(part.value, `${expectedValue}`, contextMessage); + }); + }); +} + +compareFormatToPartsSnapshot("2000-01-01T00:00Z", { + iso8601: { + year: 2000, + month: 1, + day: 1, + }, + buddhist: { + year: 2543, + era: "BE", + month: 1, + day: 1, + }, + chinese: { + relatedYear: 1999, + month: 11, + day: 25, + }, + coptic: { + year: 1716, + era: "ERA1", + month: 4, + day: 22, + }, + dangi: { + relatedYear: 1999, + month: 11, + day: 25, + }, + ethioaa: { + year: 7492, + era: "ERA0", + month: 4, + day: 22, + }, + ethiopic: { + year: 1992, + era: "ERA1", + month: 4, + day: 22, + }, + gregory: { + year: 2000, + month: 1, + day: 1, + }, + hebrew: { + year: 5760, + month: "Tevet", + day: 23, + }, + indian: { + year: 1921, + era: "Saka", + month: 10, + day: 11, + }, + islamic: { + year: 1420, + era: "AH", + month: 9, + day: 25, + }, + "islamic-umalqura": { + year: 1420, + era: "AH", + month: 9, + day: 24, + }, + "islamic-tbla": { + year: 1420, + era: "AH", + month: 9, + day: 25, + }, + "islamic-civil": { + year: 1420, + era: "AH", + month: 9, + day: 24, + }, + "islamic-rgsa": { + year: 1420, + era: "AH", + month: 9, + day: 25, + }, + islamicc: { + year: 1420, + era: "AH", + month: 9, + day: 24, + }, + japanese: { + year: 12, + era: "H", + month: 1, + day: 1, + }, + persian: { + year: 1378, + era: "AP", + month: 10, + day: 11, + }, + roc: { + year: 89, + era: "Minguo", + month: 1, + day: 1, + }, +}); // Several calendars based on the Gregorian calendar use Julian dates (not // proleptic Gregorian dates) before the Gregorian switchover in Oct 1582. See // https://bugs.chromium.org/p/chromium/issues/detail?id=1173158. The code below // allows these tests to pass regardless of the bug, while still remaining // sensitive to other bugs that may crop up. -const yearOneMonthDay = new Map( +const yearOneDay = new Map( ["iso8601", "gregory", "roc", "buddhist", "japanese"].map(calendar => { hasGregorianSwitchoverBug = new Date("+001001-01-01T00:00Z") .toLocaleDateString(`en-US-u-ca-${calendar}`, { timeZone: "UTC" }) .startsWith("12"); - return [calendar, hasGregorianSwitchoverBug ? "1/3" : "1/1"] + return [calendar, hasGregorianSwitchoverBug ? 3 : 1] })); -var year1Snapshot = - `iso8601: ${yearOneMonthDay.get("iso8601")}/1\n` + - `buddhist: ${yearOneMonthDay.get("buddhist")}/544 BE\n` + - "chinese: 11/21/0\n" + - "coptic: 5/8/284 ERA0\n" + - "dangi: 11/21/0\n" + - "ethioaa: 5/8/5493 ERA0\n" + - "ethiopic: 5/8/5493 ERA0\n" + - `gregory: ${yearOneMonthDay.get("gregory")}/1\n` + - "hebrew: 18 Tevet 3761\n" + - "indian: 10/11/-78 Saka\n" + - "islamic: 5/20/-640 AH\n" + - "islamic-umalqura: 5/18/-640 AH\n" + - "islamic-tbla: 5/19/-640 AH\n" + - "islamic-civil: 5/18/-640 AH\n" + - "islamic-rgsa: 5/20/-640 AH\n" + - "islamicc: 5/18/-640 AH\n" + - `japanese: ${yearOneMonthDay.get("japanese")}/-643 Taika (645\u2013650)\n` + - "persian: 10/11/-621 AP\n" + - `roc: ${yearOneMonthDay.get("roc")}/1911 B.R.O.C.`; -assert.sameValue(year1Content, year1Snapshot); +compareFormatToPartsSnapshot("0001-01-01T00:00Z", { + iso8601: { + year: 1, + month: 1, + day: yearOneDay.get("iso8601"), + }, + buddhist: { + year: 544, + era: "BE", + month: 1, + day: yearOneDay.get("buddhist"), + }, + chinese: { + relatedYear: 0, + month: 11, + day: 21, + }, + coptic: { + year: 284, + era: "ERA0", + month: 5, + day: 8, + }, + dangi: { + relatedYear: 0, + month: 11, + day: 21, + }, + ethioaa: { + year: 5493, + era: "ERA0", + month: 5, + day: 8, + }, + ethiopic: { + year: 5493, + era: "ERA0", + month: 5, + day: 8, + }, + gregory: { + year: 1, + month: 1, + day: yearOneDay.get("gregory"), + }, + hebrew: { + year: 3761, + month: "Tevet", + day: 18, + }, + indian: { + year: -78, + era: "Saka", + month: 10, + day: 11, + }, + islamic: { + year: -640, + era: "AH", + month: 5, + day: 20, + }, + "islamic-umalqura": { + year: -640, + era: "AH", + month: 5, + day: 18, + }, + "islamic-tbla": { + year: -640, + era: "AH", + month: 5, + day: 19, + }, + "islamic-civil": { + year: -640, + era: "AH", + month: 5, + day: 18, + }, + "islamic-rgsa": { + year: -640, + era: "AH", + month: 5, + day: 20, + }, + islamicc: { + year: -640, + era: "AH", + month: 5, + day: 18, + }, + japanese: { + year: -643, + era: "Taika (645\u2013650)", + month: 1, + day: yearOneDay.get("japanese"), + }, + persian: { + year: -621, + era: "AP", + month: 10, + day: 11, + }, + roc: { + year: 1911, + era: "B.R.O.C.", + month: 1, + day: yearOneDay.get("roc"), + }, +}); + var fromWithCases = { iso8601: { year2000: { @@ -331,8 +538,6 @@ var fromWithCases = { year1: RangeError } }; -var logPerf = false; -var totalNow = 0; for (var [id, tests] of Object.entries(fromWithCases)) { var dates = { year2000: Temporal.PlainDate.from("2000-01-01"), @@ -342,7 +547,6 @@ for (var [id, tests] of Object.entries(fromWithCases)) { var values = tests[name]; var errorExpected = values === RangeError; if ((id === "chinese" || id === "dangi") && hasOutdatedChineseIcuData ) { - var now = globalThis.performance ? globalThis.performance.now() : Date.now(); if (errorExpected) { assert.throws(RangeError, () => { var inCal = date.withCalendar(id); @@ -411,13 +615,8 @@ for (var [id, tests] of Object.entries(fromWithCases)) { monthCode: values.monthCode, year: values.year })); - var ms = (globalThis.performance ? globalThis.performance.now() : Date.now()) - now; - totalNow += ms; - if (logPerf) - console.log(`from: ${ id } ${ name }: ${ ms.toFixed(2) }ms, total: ${ totalNow.toFixed(2) }ms`); }; if ((id === "chinese" || id === "dangi") && hasOutdatedChineseIcuData ) { - var now = globalThis.performance ? globalThis.performance.now() : Date.now(); var inCal = date.withCalendar(id); if (errorExpected) { assert.throws(RangeError, () => inCal.with({ day: 1 }).year); @@ -437,10 +636,6 @@ for (var [id, tests] of Object.entries(fromWithCases)) { assert.sameValue(`${ t } year: ${ afterWithYear.year }`, `${ t } year: 2220`); assert.sameValue(`${ t } month: ${ afterWithYear.month }`, `${ t } month: 1`); assert.sameValue(`${ t } day: ${ afterWithYear.day }`, `${ t } day: 1`); - var ms = (globalThis.performance ? globalThis.performance.now() : Date.now()) - now; - totalNow += ms; - if (logPerf) - console.log(`with: ${ id } ${ name }: ${ ms.toFixed(2) }ms, total: ${ totalNow.toFixed(2) }ms`); }; } } @@ -660,13 +855,11 @@ var tests = { } } }; -var calendars = Object.keys(addMonthsCases); -for (var id of calendars) { +for (var id of Object.keys(addMonthsCases)) { for (var [unit, {duration, results, startDate}] of Object.entries(tests)) { var values = results[id]; duration = Temporal.Duration.from(duration); if ((id === "chinese" || id === "dangi") && hasOutdatedChineseIcuData ) { - var now = globalThis.performance ? globalThis.performance.now() : Date.now(); if (values === RangeError) { assert.throws(RangeError, () => Temporal.PlainDate.from({ ...startDate, @@ -722,10 +915,6 @@ for (var id of calendars) { assert.sameValue(`subtract from end-of-month ${ unit } ${ id } month: ${ startReverseNextDay.month }`, `subtract from end-of-month ${ unit } ${ id } month: ${ start.month }`); assert.sameValue(`subtract from end-of-month ${ unit } ${ id } monthCode: ${ startReverseNextDay.monthCode }`, `subtract from end-of-month ${ unit } ${ id } monthCode: ${ start.monthCode }`); } - var ms = (globalThis.performance ? globalThis.performance.now() : Date.now()) - now; - totalNow += ms; - if (logPerf) - console.log(`${ id } add ${ duration }: ${ ms.toFixed(2) }ms, total: ${ totalNow.toFixed(2) }ms`); }; } } @@ -1080,7 +1269,7 @@ var daysInMonthCases = { } }; totalNow = 0; -for (var id of calendars) { +for (var id of Object.keys(daysInMonthCases)) { var {year, leap, days} = daysInMonthCases[id]; var date = hasOutdatedChineseIcuData && (id === "chinese" || id === "dangi") ? undefined : Temporal.PlainDate.from({ year, @@ -1098,7 +1287,6 @@ for (var id of calendars) { } }; if ((id === "chinese" || id === "dangi") && hasOutdatedChineseIcuData ) { - var now = globalThis.performance ? globalThis.performance.now() : Date.now(); var {monthsInYear} = date; assert.sameValue(monthsInYear, days.length); for (var i = monthsInYear, leapMonthIndex = undefined, monthStart = undefined; i >= 1; i--) { @@ -1142,10 +1330,6 @@ for (var id of calendars) { var oneDayPastMonthEnd = monthStart.with({ day: daysInMonth + 1 }); assert.sameValue(oneDayPastMonthEnd.day, daysInMonth); } - var ms = (globalThis.performance ? globalThis.performance.now() : Date.now()) - now; - totalNow += ms; - if (logPerf) - console.log(`${ id } months check ${ id }: ${ ms.toFixed(2) }ms, total: ${ totalNow.toFixed(2) }ms`); }; } var monthDayCases = [ diff --git a/js/src/tests/test262/staging/Temporal/Duration/old/shell.js b/js/src/tests/test262/staging/Temporal/Duration/old/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/staging/Temporal/Duration/old/shell.js +++ b/js/src/tests/test262/staging/Temporal/Duration/old/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/staging/Temporal/TimeZone/old/shell.js b/js/src/tests/test262/staging/Temporal/TimeZone/old/shell.js index eaa8761415..cd31c09e9b 100644 --- a/js/src/tests/test262/staging/Temporal/TimeZone/old/shell.js +++ b/js/src/tests/test262/staging/Temporal/TimeZone/old/shell.js @@ -2351,6 +2351,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2438,6 +2441,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/round.js b/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/round.js index 3dfb21989d..6c613fa47b 100644 --- a/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/round.js +++ b/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/round.js @@ -217,17 +217,19 @@ var bal = Temporal.ZonedDateTime.from("1976-11-18T23:59:59.999999999+01:00[+01:0 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-29T12:29:59").toZonedDateTime(timeZone); +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-29T12:30:01").toZonedDateTime(timeZone); +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-02T11:29:59").toZonedDateTime(timeZone); +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-02T11:30:01").toZonedDateTime(timeZone); +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 diff --git a/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/shell.js b/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/shell.js index 60f74c2518..5265d86aa2 100644 --- a/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/shell.js +++ b/js/src/tests/test262/staging/Temporal/ZonedDateTime/old/shell.js @@ -2022,6 +2022,9 @@ var TemporalHelpers = { "11-18junk", "11-18[u-ca=gregory]", "11-18[u-ca=hebrew]", + "11-18[U-CA=iso8601]", + "11-18[u-CA=iso8601]", + "11-18[FOO=bar]", ]; }, @@ -2109,6 +2112,11 @@ var TemporalHelpers = { plainYearMonthStringsInvalid() { return [ "2020-13", + "1976-11[u-ca=gregory]", + "1976-11[u-ca=hebrew]", + "1976-11[U-CA=iso8601]", + "1976-11[u-CA=iso8601]", + "1976-11[FOO=bar]", ]; }, diff --git a/js/src/tests/test262/staging/built-ins/Array/browser.js b/js/src/tests/test262/staging/built-ins/Array/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/browser.js diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/browser.js b/js/src/tests/test262/staging/built-ins/Array/prototype/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/browser.js diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/browser.js b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/browser.js diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/callback-with-side-effects.js b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/callback-with-side-effects.js new file mode 100644 index 0000000000..83d2057623 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/callback-with-side-effects.js @@ -0,0 +1,30 @@ +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.flatMap +description: > + Array.prototype.flatMap is given a callback that modifies the array being + iterated. +includes: [compareArray.js] +---*/ + +(function TestGrow() { + let array = [0,1,2,3]; + function f(e) { + array[4] = 42; + return e; + } + assert.compareArray(array.flatMap(f), [0,1,2,3]); +})(); + +(function TestShrink() { + let array = [0,1,2,3]; + function f(e) { + array.length = 3; + return e; + } + assert.compareArray(array.flatMap(f), [0,1,2]); +})(); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/shell.js b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/flatMap/shell.js diff --git a/js/src/tests/test262/staging/built-ins/Array/prototype/shell.js b/js/src/tests/test262/staging/built-ins/Array/prototype/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/prototype/shell.js diff --git a/js/src/tests/test262/staging/built-ins/Array/shell.js b/js/src/tests/test262/staging/built-ins/Array/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/Array/shell.js diff --git a/js/src/tests/test262/staging/built-ins/RegExp/browser.js b/js/src/tests/test262/staging/built-ins/RegExp/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/browser.js diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/browser.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/browser.js diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-replace.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-replace.js new file mode 100644 index 0000000000..f26eebab4d --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-replace.js @@ -0,0 +1,31 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Test replace function with duplicate names in alteration. +features: [regexp-duplicate-named-groups] +includes: [compareArray.js] +---*/ + +assert.compareArray( + '2xyy', 'xxyy'.replace(/(?:(?:(?<a>x)|(?<a>y))\k<a>)/, '2$<a>')); +assert.compareArray( + 'x2zyyxxy', + 'xzzyyxxy'.replace( + /(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>)/, '2$<a>')); +assert.compareArray( + '2x(x,)yy', 'xxyy'.replace(/(?:(?:(?<a>x)|(?<a>y))\k<a>)/, '2$<a>($1,$2)')); +assert.compareArray( + 'x2z(,,,,z)yyxxy', + 'xzzyyxxy'.replace( + /(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>)/, + '2$<a>($1,$2,$3,$4,$5)')); +assert.compareArray( + '2x2y', 'xxyy'.replace(/(?:(?:(?<a>x)|(?<a>y))\k<a>)/g, '2$<a>')); +assert.compareArray( + 'x2z2y2xy', + 'xzzyyxxy'.replace( + /(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>)/g, '2$<a>')); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-search.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-search.js new file mode 100644 index 0000000000..27a2b22a82 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups-search.js @@ -0,0 +1,16 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Test search function with duplicate names in alteration. +features: [regexp-duplicate-named-groups] +includes: [compareArray.js] +---*/ + +assert.compareArray(3, 'abcxyz'.search(/(?<a>x)|(?<a>y)/)); +assert.compareArray(3, 'abcxyz'.search(/(?<a>y)|(?<a>x)/)); +assert.compareArray(1, 'aybcxyz'.search(/(?<a>x)|(?<a>y)/)); +assert.compareArray(1, 'aybcxyz'.search(/(?<a>y)|(?<a>x)/)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups.js new file mode 100644 index 0000000000..d28346f13b --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/duplicate-named-groups.js @@ -0,0 +1,19 @@ +// |reftest| skip -- regexp-duplicate-named-groups is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Test different functions with duplicate names in alteration. +features: [regexp-duplicate-named-groups] +includes: [compareArray.js] +---*/ + +assert.compareArray( + ['xxyy', undefined, 'y'], /(?:(?:(?<a>x)|(?<a>y))\k<a>){2}/.exec('xxyy')); +assert.compareArray( + ['zzyyxx', 'x', undefined, undefined, undefined, undefined], + /(?:(?:(?<a>x)|(?<a>y)|(a)|(?<b>b)|(?<a>z))\k<a>){3}/.exec('xzzyyxxy')); +assert.compareArray( + ['xxyy', undefined, 'y'], 'xxyy'.match(/(?:(?:(?<a>x)|(?<a>y))\k<a>){2}/)); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/built-ins/RegExp/named-groups/shell.js b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/named-groups/shell.js diff --git a/js/src/tests/test262/staging/built-ins/RegExp/shell.js b/js/src/tests/test262/staging/built-ins/RegExp/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/RegExp/shell.js diff --git a/js/src/tests/test262/staging/built-ins/browser.js b/js/src/tests/test262/staging/built-ins/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/browser.js diff --git a/js/src/tests/test262/staging/built-ins/shell.js b/js/src/tests/test262/staging/built-ins/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/built-ins/shell.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/browser.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/browser.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/browser.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/browser.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/cross-realm.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/cross-realm.js new file mode 100644 index 0000000000..40a3a9a54c --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/cross-realm.js @@ -0,0 +1,17 @@ +// |reftest| skip -- explicit-resource-management is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Value shared by all realms +info: | + Unless otherwise specified, well-known symbols values are shared by all + realms. +features: [cross-realm, explicit-resource-management] +---*/ + +var OSymbol = $262.createRealm().global.Symbol; + +assert.sameValue(Symbol.dispose, OSymbol.dispose); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/prop-desc.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/prop-desc.js new file mode 100644 index 0000000000..8f4330035c --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/prop-desc.js @@ -0,0 +1,20 @@ +// |reftest| skip -- explicit-resource-management is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + `Symbol.dispose` property descriptor +info: | + This property has the attributes { [[Writable]]: false, [[Enumerable]]: + false, [[Configurable]]: false }. +includes: [propertyHelper.js] +features: [explicit-resource-management] +---*/ + +assert.sameValue(typeof Symbol.dispose, 'symbol'); +verifyNotEnumerable(Symbol, 'dispose'); +verifyNotWritable(Symbol, 'dispose'); +verifyNotConfigurable(Symbol, 'dispose'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/shell.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/dispose/shell.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/Symbol/shell.js b/js/src/tests/test262/staging/explicit-resource-management/Symbol/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/Symbol/shell.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/browser.js b/js/src/tests/test262/staging/explicit-resource-management/browser.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/browser.js diff --git a/js/src/tests/test262/staging/explicit-resource-management/call-dispose-methods.js b/js/src/tests/test262/staging/explicit-resource-management/call-dispose-methods.js new file mode 100644 index 0000000000..55189d2150 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/call-dispose-methods.js @@ -0,0 +1,194 @@ +// |reftest| skip -- explicit-resource-management is not supported +// Copyright (C) 2024 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: Test if disposed methods are called in correct syntax. +includes: [compareArray.js] +features: [explicit-resource-management] +---*/ + +// Block ---------------- +let blockValues = []; + +(function TestUsingInBlock() { + { + using x = { + value: 1, + [Symbol.dispose]() { + blockValues.push(42); + } + }; + blockValues.push(43); + } +})(); +assert.compareArray(blockValues, [43, 42]); + +// CaseBlock -------------- +let caseBlockValues = []; + +(function TestUsingInCaseBlock() { + let label = 1; + switch (label) { + case 1: + using x = { + value: 1, + [Symbol.dispose]() { + caseBlockValues.push(42); + } + }; + } + caseBlockValues.push(43); +})(); +assert.compareArray(caseBlockValues, [42, 43]); + +// ForStatement -------------- +let forStatementValues = []; + +(function TestUsingInForStatement() { + for (let i = 0; i < 3; i++) { + using x = { + value: i, + [Symbol.dispose]() { + forStatementValues.push(this.value); + } + }; + } + forStatementValues.push(3); +})(); +assert.compareArray(forStatementValues, [0, 1, 2, 3]); + +// ForInStatement -------------- +let forInStatementValues = []; + +(function TestUsingInForInStatement() { + for (let i in [0, 1]) { + using x = { + value: i, + [Symbol.dispose]() { + forInStatementValues.push(this.value); + } + }; + } + forInStatementValues.push('2'); +})(); +assert.compareArray(forInStatementValues, ['0', '1', '2']); + +// ForOfStatement -------------- +let forOfStatementValues = []; + +(function TestUsingInForOfStatement() { + for (let i of [0, 1]) { + using x = { + value: i, + [Symbol.dispose]() { + forOfStatementValues.push(this.value); + } + }; + } + forOfStatementValues.push(2); +})(); +assert.compareArray(forOfStatementValues, [0, 1, 2]); + +// FunctionBody -------------- +let functionBodyValues = []; + +(function TestUsingInFunctionBody() { + using x = { + value: 1, + [Symbol.dispose]() { + functionBodyValues.push(42); + } + }; + using y = { + value: 2, + [Symbol.dispose]() { + functionBodyValues.push(43); + } + }; +})(); +assert.compareArray(functionBodyValues, [43, 42]); + +// GeneratorBody -------------- +let generatorBodyValues = []; + +function* gen() { + using x = { + value: 1, + [Symbol.dispose]() { + generatorBodyValues.push(42); + } + }; + yield x; +} + +(function TestUsingInGeneratorBody() { + let iter = gen(); + iter.next(); + iter.next(); + generatorBodyValues.push(43); +})(); +assert.compareArray(generatorBodyValues, [42, 43]); + +// ClassStaticBlockBody -------------- +let classStaticBlockBodyValues = []; + +class staticBlockClass { + static { + using x = { + value: 1, + [Symbol.dispose]() { + classStaticBlockBodyValues.push(42); + } + }; + } +} + +(function TestUsingInAsyncFunctionBody() { + let example = new staticBlockClass(); +})(); +assert.compareArray(classStaticBlockBodyValues, [42]); + +// Derived constructor case +let derivedConstructorValues = []; + +class baseClass { + constructor() { + derivedConstructorValues.push(43); + } +} + +class subClass extends baseClass { + constructor() { + try { + using x = { + value: 1, + [Symbol.dispose]() { + derivedConstructorValues.push(42); + } + }; + } catch (e) { + return; + } finally { + super(); + } + } +} + +(function TestUsingInDerivedConstructor() { + let example = new subClass(); +})(); +assert.compareArray(derivedConstructorValues, [42, 43]); + +// Lack of dispose method +let values = []; + +function TestUsingWithoutDisposeMethod() { + { + using x = {value: 1}; + values.push(43); + } +} +assert.throws(TypeError, TestUsingWithoutDisposeMethod, 'No dispose method'); + +reportCompare(0, 0); diff --git a/js/src/tests/test262/staging/explicit-resource-management/shell.js b/js/src/tests/test262/staging/explicit-resource-management/shell.js new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/js/src/tests/test262/staging/explicit-resource-management/shell.js |