diff --git a/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..069cbe1f47 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateAdd/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, dateAdd() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.dateAdd(arg, new Temporal.Duration()); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..b073972a11 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dateUntil/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, dateUntil() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.dateUntil(arg, arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/day/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/day/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..1009f03c37 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, day() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.day(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..93809cb554 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfWeek/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, dayOfWeek() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.dayOfWeek(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..27b7bca6e2 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/dayOfYear/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, dayOfYear() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.dayOfYear(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..e8e70549ec --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInMonth/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, daysInMonth() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.daysInMonth(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..5fbff5902c --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInWeek/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, daysInWeek() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.daysInWeek(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..7ec3d90bd2 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/daysInYear/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, daysInYear() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.daysInYear(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..c0595d5b32 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/inLeapYear/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, inLeapYear() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.inLeapYear(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/month/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/month/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..a5a139061a --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, month() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.month(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..9103858bbf --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthCode/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, monthCode() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.monthCode(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..4c59331766 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, monthsInYear() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.monthsInYear(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..9b7e75c9d1 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/weekOfYear/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, weekOfYear() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.weekOfYear(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Calendar/prototype/year/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/Calendar/prototype/year/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..9cbcd95944 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, year() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.year(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-calendar-fields-undefined.js b/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-calendar-fields-undefined.js new file mode 100644 index 0000000000..3b4860ef89 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/add/relativeto-propertybag-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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.add +description: > + When calendar.fields is undefined, add() doesn't perform an + observable array iteration to convert the property bag to relativeTo +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Duration(1, 0, 0, 1); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const relativeTo = { year: 1981, month: 12, day: 15, calendar }; + +instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-fields-undefined.js b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-fields-undefined.js new file mode 100644 index 0000000000..5be5a897da --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/round/relativeto-propertybag-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, round() doesn't perform an + observable array iteration to convert the property bag to relativeTo +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Duration(1, 0, 0, 0, 24); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const relativeTo = { year: 1981, month: 12, day: 15, calendar }; + +instance.round({ largestUnit: "years", relativeTo }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-calendar-fields-undefined.js b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-calendar-fields-undefined.js new file mode 100644 index 0000000000..38e03015a3 --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/subtract/relativeto-propertybag-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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.subtract +description: > + When calendar.fields is undefined, subtract() doesn't perform an + observable array iteration to convert the property bag to relativeTo +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Duration(1, 0, 0, 1); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const relativeTo = { year: 1981, month: 12, day: 15, calendar }; + +instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-fields-undefined.js b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-fields-undefined.js new file mode 100644 index 0000000000..9207964e4f --- /dev/null +++ b/test/built-ins/Temporal/Duration/prototype/total/relativeto-propertybag-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, total() doesn't perform an + observable array iteration to convert the property bag to relativeTo +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Duration(1, 0, 0, 0, 24); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const relativeTo = { year: 1981, month: 12, day: 15, calendar }; + +instance.total({ unit: "days", relativeTo }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDate/compare/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDate/compare/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..e961c88642 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/compare/argument-calendar-fields-undefined.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.plaindate.prototype.compare +description: > + When calendar.fields is undefined, compare() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +Temporal.PlainDate.compare(arg, arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDate/from/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDate/from/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..ac5af22395 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/from/argument-calendar-fields-undefined.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.plaindate.prototype.from +description: > + When calendar.fields is undefined, from() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +Temporal.PlainDate.from(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDate/prototype/equals/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..b06e491246 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/equals/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, equals() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.equals(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDate/prototype/since/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/since/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..8ce3ee4b83 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/since/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, since() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.since(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fields-undefined.js new file mode 100644 index 0000000000..7d16c30ebe --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainMonthDay/calendar-fields-undefined.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.plaindate.prototype.toplainmonthday +description: > + When calendar.fields is undefined, toPlainMonthDay() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDate(1981, 12, 15, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.toPlainMonthDay(); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fields-undefined.js new file mode 100644 index 0000000000..b64ea890ec --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/toPlainYearMonth/calendar-fields-undefined.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.plaindate.prototype.toplainyearmonth +description: > + When calendar.fields is undefined, toPlainYearMonth() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDate(1981, 12, 15, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.toPlainYearMonth(); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDate/prototype/until/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/until/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..719de0a3f2 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/until/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, until() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDate(2000, 5, 2); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.until(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDate/prototype/with/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDate/prototype/with/calendar-fields-undefined.js new file mode 100644 index 0000000000..bcfe3a463b --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/with/calendar-fields-undefined.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.plaindate.prototype.with +description: > + When calendar.fields is undefined, with() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDate(1981, 12, 15, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.with({ year: 2022 }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDateTime/compare/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDateTime/compare/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..86cd7e5d84 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/compare/argument-calendar-fields-undefined.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.compare +description: > + When calendar.fields is undefined, compare() doesn't perform an + observable array iteration to convert the property bag to PlainDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +Temporal.PlainDateTime.compare(arg, arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDateTime/from/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDateTime/from/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..871c37a4f0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/from/argument-calendar-fields-undefined.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.from +description: > + When calendar.fields is undefined, from() doesn't perform an + observable array iteration to convert the property bag to PlainDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +Temporal.PlainDateTime.from(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..99dd1589da --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/equals/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, equals() doesn't perform an + observable array iteration to convert the property bag to PlainDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.equals(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..bf05d69d10 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/since/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, since() doesn't perform an + observable array iteration to convert the property bag to PlainDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.since(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fields-undefined.js new file mode 100644 index 0000000000..47465b7ef0 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainMonthDay/calendar-fields-undefined.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.toplainmonthday +description: > + When calendar.fields is undefined, toPlainMonthDay() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.toPlainMonthDay(); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fields-undefined.js new file mode 100644 index 0000000000..f8a295e723 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/toPlainYearMonth/calendar-fields-undefined.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.toplainyearmonth +description: > + When calendar.fields is undefined, toPlainYearMonth() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.toPlainYearMonth(); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..d336b3ff9d --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/until/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, until() doesn't perform an + observable array iteration to convert the property bag to PlainDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.until(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-undefined.js new file mode 100644 index 0000000000..231e6026fa --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/with/calendar-fields-undefined.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.with +description: > + When calendar.fields is undefined, with() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDateTime(1981, 12, 15, 14, 15, 45, 987, 654, 321, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.with({ year: 2022 }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..22210a44c2 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/withPlainDate/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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.withplaindate +description: > + When calendar.fields is undefined, withPlainDate() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainDateTime(2000, 5, 2, 12, 34, 56, 987, 654, 321); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.withPlainDate(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainMonthDay/from/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainMonthDay/from/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..1ab8faca01 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/from/argument-calendar-fields-undefined.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.plainmonthday.prototype.from +description: > + When calendar.fields is undefined, from() doesn't perform an + observable array iteration to convert the property bag to PlainMonthDay +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { monthCode: "M12", day: 15, calendar }; + +Temporal.PlainMonthDay.from(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..ec3e602786 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/equals/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, equals() doesn't perform an + observable array iteration to convert the property bag to PlainMonthDay +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainMonthDay(5, 2); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { monthCode: "M12", day: 15, calendar }; + +instance.equals(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fields-undefined.js new file mode 100644 index 0000000000..38dc03ded0 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/toPlainDate/calendar-fields-undefined.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.plainmonthday.prototype.toplaindate +description: > + When calendar.fields is undefined, toPlainDate() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainMonthDay(12, 15, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.toPlainDate({ year: 2022 }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-undefined.js new file mode 100644 index 0000000000..228207d627 --- /dev/null +++ b/test/built-ins/Temporal/PlainMonthDay/prototype/with/calendar-fields-undefined.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.plainmonthday.prototype.with +description: > + When calendar.fields is undefined, with() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainMonthDay(12, 15, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.with({ day: 1 }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..e6e9f1efa7 --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toPlainDateTime/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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.toplaindatetime +description: > + When calendar.fields is undefined, toPlainDateTime() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.toPlainDateTime(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..ac6a7f558a --- /dev/null +++ b/test/built-ins/Temporal/PlainTime/prototype/toZonedDateTime/argument-calendar-fields-undefined.js @@ -0,0 +1,41 @@ +// Copyright (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.tozoneddatetime +description: > + When calendar.fields is undefined, toZonedDateTime() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +const instance = new Temporal.PlainTime(12, 34, 56, 987, 654, 321); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.toZonedDateTime({ plainDate: arg, timeZone }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainYearMonth/compare/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainYearMonth/compare/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..fc63eb24a0 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/compare/argument-calendar-fields-undefined.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.plainyearmonth.prototype.compare +description: > + When calendar.fields is undefined, compare() doesn't perform an + observable array iteration to convert the property bag to PlainYearMonth +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, calendar }; + +Temporal.PlainYearMonth.compare(arg, arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainYearMonth/from/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainYearMonth/from/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..3b29344fb6 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/from/argument-calendar-fields-undefined.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.plainyearmonth.prototype.from +description: > + When calendar.fields is undefined, from() doesn't perform an + observable array iteration to convert the property bag to PlainYearMonth +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, calendar }; + +Temporal.PlainYearMonth.from(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-fields-undefined.js new file mode 100644 index 0000000000..5526e07d15 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/add/calendar-fields-undefined.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.plainyearmonth.prototype.add +description: > + When calendar.fields is undefined, add() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainYearMonth(1981, 12, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.add({ years: 1 }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..c65533a50f --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/equals/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, equals() doesn't perform an + observable array iteration to convert the property bag to PlainYearMonth +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainYearMonth(2000, 5); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, calendar }; + +instance.equals(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-fields-undefined.js new file mode 100644 index 0000000000..d775950d9e --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/since/calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, since() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainYearMonth(1981, 12, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.since(new Temporal.PlainYearMonth(1979, 4, calendar)); +// Check that no iteration is performed when converting a property bag either +instance.since({ year: 1979, month: 4, calendar }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-fields-undefined.js new file mode 100644 index 0000000000..be3b2eca9c --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/subtract/calendar-fields-undefined.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.plainyearmonth.prototype.subtract +description: > + When calendar.fields is undefined, subtract() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainYearMonth(1981, 12, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.subtract({ years: 1 }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fields-undefined.js new file mode 100644 index 0000000000..c841e16bab --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/toPlainDate/calendar-fields-undefined.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.plainyearmonth.prototype.toplaindate +description: > + When calendar.fields is undefined, toPlainDate() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainYearMonth(1981, 12, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.toPlainDate({ day: 1 }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-fields-undefined.js new file mode 100644 index 0000000000..05d42fbdc5 --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/until/calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, until() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainYearMonth(1981, 12, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.until(new Temporal.PlainYearMonth(2022, 10, calendar)); +// Check that no iteration is performed when converting a property bag either +instance.since({ year: 2022, month: 10, calendar }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-fields-undefined.js b/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-fields-undefined.js new file mode 100644 index 0000000000..24328c335f --- /dev/null +++ b/test/built-ins/Temporal/PlainYearMonth/prototype/with/calendar-fields-undefined.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.plainyearmonth.prototype.with +description: > + When calendar.fields is undefined, with() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.PlainYearMonth(1981, 12, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.with({ year: 2022 }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..ea27bcc2d3 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getInstantFor/argument-calendar-fields-undefined.js @@ -0,0 +1,39 @@ +// Copyright (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: > + When calendar.fields is undefined, getInstantFor() doesn't perform an + observable array iteration to convert the property bag to PlainDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.getInstantFor(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..23d62c4595 --- /dev/null +++ b/test/built-ins/Temporal/TimeZone/prototype/getPossibleInstantsFor/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (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: > + When calendar.fields is undefined, getPossibleInstantsFor() doesn't perform an + observable array iteration to convert the property bag to PlainDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.TimeZone("UTC"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.getPossibleInstantsFor(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/ZonedDateTime/compare/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/ZonedDateTime/compare/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..6521610739 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/compare/argument-calendar-fields-undefined.js @@ -0,0 +1,39 @@ +// Copyright (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.compare +description: > + When calendar.fields is undefined, compare() doesn't perform an + observable array iteration to convert the property bag to ZonedDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, timeZone, calendar }; + +Temporal.ZonedDateTime.compare(arg, arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/ZonedDateTime/from/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/ZonedDateTime/from/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..1dce02a5bf --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/from/argument-calendar-fields-undefined.js @@ -0,0 +1,39 @@ +// Copyright (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.from +description: > + When calendar.fields is undefined, from() doesn't perform an + observable array iteration to convert the property bag to ZonedDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, timeZone, calendar }; + +Temporal.ZonedDateTime.from(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..05d9055113 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/equals/argument-calendar-fields-undefined.js @@ -0,0 +1,41 @@ +// Copyright (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: > + When calendar.fields is undefined, equals() doesn't perform an + observable array iteration to convert the property bag to ZonedDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, timeZone, calendar }; + +instance.equals(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..de2a8a129d --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/since/argument-calendar-fields-undefined.js @@ -0,0 +1,41 @@ +// Copyright (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: > + When calendar.fields is undefined, since() doesn't perform an + observable array iteration to convert the property bag to ZonedDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, timeZone, calendar }; + +instance.since(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fields-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fields-undefined.js new file mode 100644 index 0000000000..d9f6de1b59 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainMonthDay/calendar-fields-undefined.js @@ -0,0 +1,39 @@ +// Copyright (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.toplainmonthday +description: > + When calendar.fields is undefined, toPlainMonthDay() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.toPlainMonthDay(); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fields-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fields-undefined.js new file mode 100644 index 0000000000..a6e64c5fa9 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/toPlainYearMonth/calendar-fields-undefined.js @@ -0,0 +1,39 @@ +// Copyright (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.toplainyearmonth +description: > + When calendar.fields is undefined, toPlainYearMonth() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.toPlainYearMonth(); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..d060a91ec5 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/until/argument-calendar-fields-undefined.js @@ -0,0 +1,41 @@ +// Copyright (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: > + When calendar.fields is undefined, until() doesn't perform an + observable array iteration to convert the property bag to ZonedDateTime +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +const instance = new Temporal.ZonedDateTime(0n, timeZone); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, timeZone, calendar }; + +instance.until(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-undefined.js new file mode 100644 index 0000000000..cadd41c7ba --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/with/calendar-fields-undefined.js @@ -0,0 +1,39 @@ +// Copyright (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: > + When calendar.fields is undefined, with() doesn't perform an + observable array iteration +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone, calendar); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +instance.with({ year: 2022 }); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-calendar-fields-undefined.js b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..0991840993 --- /dev/null +++ b/test/built-ins/Temporal/ZonedDateTime/prototype/withPlainDate/argument-calendar-fields-undefined.js @@ -0,0 +1,41 @@ +// Copyright (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.withplaindate +description: > + When calendar.fields is undefined, withPlainDate() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const timeZone = new class extends Temporal.TimeZone { + getPossibleInstantsFor(dt) { + const instants = super.getPossibleInstantsFor.call(this, dt); + // Return an iterable object that doesn't call Array iterator + return { + *[Symbol.iterator]() { + for (let index = 0; index < instants.length; index++) { + yield instants[index]; + } + } + } + } +}("UTC"); + +const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, timeZone); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.withPlainDate(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/intl402/Temporal/Calendar/prototype/era/argument-calendar-fields-undefined.js b/test/intl402/Temporal/Calendar/prototype/era/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..cf4972c007 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/era/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, era() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.era(arg); + +Array.prototype[Symbol.iterator] = oldIterator; diff --git a/test/intl402/Temporal/Calendar/prototype/eraYear/argument-calendar-fields-undefined.js b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-calendar-fields-undefined.js new file mode 100644 index 0000000000..d30f69c541 --- /dev/null +++ b/test/intl402/Temporal/Calendar/prototype/eraYear/argument-calendar-fields-undefined.js @@ -0,0 +1,27 @@ +// Copyright (C) 2022 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: > + When calendar.fields is undefined, eraYear() doesn't perform an + observable array iteration to convert the property bag to PlainDate +features: [Temporal] +---*/ + +const calendar = new Temporal.Calendar("iso8601"); +calendar.fields = undefined; + +const instance = new Temporal.Calendar("iso8601"); + +// Detect observable array iteration: +const oldIterator = Array.prototype[Symbol.iterator]; +Array.prototype[Symbol.iterator] = function () { + throw new Test262Error(`array shouldn't be iterated: ${new Error().stack}`); +}; + +const arg = { year: 1981, month: 12, day: 15, calendar }; + +instance.eraYear(arg); + +Array.prototype[Symbol.iterator] = oldIterator;