mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Temporal: Adapt existing custom calendar getter tests, and expand
The existing tests would fail after making the normative change from tc39/proposal-temporal#2265 because they rely on the getter directly returning whatever value the calendar method returned. This is no longer the case, because the value returned by the calendar is validated, so adjust the assertions in these tests. Also, no longer any need to return a value from the calendar method that needs to be converted; we'll add separate tests for that. Expand these tests to cover all of the PlainDate, PlainDateTime, PlainMonthDay, PlainYearMonth, and ZonedDateTime property getters that delegate to the calendar methods.
This commit is contained in:
parent
89116e95dd
commit
b83af50771
27
test/built-ins/Temporal/PlainDate/prototype/day/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainDate/prototype/day/custom.js
vendored
Normal file
@ -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-get-temporal.plaindate.prototype.day
|
||||
description: Custom calendar tests for day().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
day(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "day arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.day;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
dayOfWeek(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "dayOfWeek arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.dayOfWeek;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
dayOfYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "dayOfYear arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.dayOfYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
daysInMonth(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "daysInMonth arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.daysInMonth;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
daysInWeek(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "daysInWeek arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.daysInWeek;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
daysInYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "daysInYear arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.daysInYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
inLeapYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "inLeapYear arguments");
|
||||
return "7";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.inLeapYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, true, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
27
test/built-ins/Temporal/PlainDate/prototype/month/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainDate/prototype/month/custom.js
vendored
Normal file
@ -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-get-temporal.plaindate.prototype.month
|
||||
description: Custom calendar tests for month().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
month(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "month arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.month;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainDate/prototype/monthCode/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainDate/prototype/monthCode/custom.js
vendored
Normal file
@ -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-get-temporal.plaindate.prototype.monthcode
|
||||
description: Custom calendar tests for monthCode().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
monthCode(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "monthCode arguments");
|
||||
return "M01";
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.monthCode;
|
||||
assert.sameValue(result, "M01", "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
monthsInYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "monthsInYear arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.monthsInYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
weekOfYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "weekOfYear arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.weekOfYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
27
test/built-ins/Temporal/PlainDate/prototype/year/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainDate/prototype/year/custom.js
vendored
Normal file
@ -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-get-temporal.plaindate.prototype.year
|
||||
description: Custom calendar tests for year().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
year(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pd], "year arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pd = new Temporal.PlainDate(1830, 8, 25, calendar);
|
||||
const result = pd.year;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainDateTime/prototype/day/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainDateTime/prototype/day/custom.js
vendored
Normal file
@ -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-get-temporal.plaindatetime.prototype.day
|
||||
description: Custom calendar tests for day().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
day(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "day arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.day;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
dayOfWeek(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "dayOfWeek arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.dayOfWeek;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
dayOfYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "dayOfYear arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.dayOfYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
daysInMonth(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "daysInMonth arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.daysInMonth;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
daysInWeek(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "daysInWeek arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.daysInWeek;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
daysInYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "daysInYear arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.daysInYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
inLeapYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "inLeapYear arguments");
|
||||
return "7";
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.inLeapYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, true, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
27
test/built-ins/Temporal/PlainDateTime/prototype/month/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainDateTime/prototype/month/custom.js
vendored
Normal file
@ -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-get-temporal.plaindatetime.prototype.month
|
||||
description: Custom calendar tests for month().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
month(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "month arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.month;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainDateTime/prototype/monthCode/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainDateTime/prototype/monthCode/custom.js
vendored
Normal file
@ -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-get-temporal.plaindatetime.prototype.monthcode
|
||||
description: Custom calendar tests for monthCode().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
monthCode(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "monthCode arguments");
|
||||
return "M01";
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.monthCode;
|
||||
assert.sameValue(result, "M01", "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
monthsInYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "monthsInYear arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.monthsInYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
@ -16,12 +16,12 @@ class CustomCalendar extends Temporal.Calendar {
|
||||
weekOfYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "weekOfYear arguments");
|
||||
return "7";
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.weekOfYear;
|
||||
assert.sameValue(result, "7", "result");
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
||||
|
27
test/built-ins/Temporal/PlainDateTime/prototype/year/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainDateTime/prototype/year/custom.js
vendored
Normal file
@ -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-get-temporal.plaindatetime.prototype.year
|
||||
description: Custom calendar tests for year().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
year(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [pdt], "year arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar);
|
||||
const result = pdt.year;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainMonthDay/prototype/day/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainMonthDay/prototype/day/custom.js
vendored
Normal file
@ -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-get-temporal.plainmonthday.prototype.day
|
||||
description: Custom calendar tests for day().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
day(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [instance], "day arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.PlainMonthDay(8, 25, calendar);
|
||||
const result = instance.day;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainMonthDay/prototype/monthCode/custom.js
vendored
Normal file
@ -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-get-temporal.plainmonthday.prototype.monthcode
|
||||
description: Custom calendar tests for monthCode().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
monthCode(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [instance], "monthCode arguments");
|
||||
return "M01";
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.PlainMonthDay(8, 25, calendar);
|
||||
const result = instance.monthCode;
|
||||
assert.sameValue(result, "M01", "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainYearMonth/prototype/daysInMonth/custom.js
vendored
Normal file
@ -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-get-temporal.plainyearmonth.prototype.daysinmonth
|
||||
description: Custom calendar tests for daysInMonth().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
daysInMonth(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [instance], "daysInMonth arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.PlainYearMonth(1830, 8, calendar);
|
||||
const result = instance.daysInMonth;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainYearMonth/prototype/daysInYear/custom.js
vendored
Normal file
@ -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-get-temporal.plainyearmonth.prototype.daysinyear
|
||||
description: Custom calendar tests for daysInYear().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
daysInYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [instance], "daysInYear arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.PlainYearMonth(1830, 8, calendar);
|
||||
const result = instance.daysInYear;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainYearMonth/prototype/inLeapYear/custom.js
vendored
Normal file
@ -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-get-temporal.plainyearmonth.prototype.inleapyear
|
||||
description: Custom calendar tests for inLeapYear().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
inLeapYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [instance], "inLeapYear arguments");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.PlainYearMonth(1830, 8, calendar);
|
||||
const result = instance.inLeapYear;
|
||||
assert.sameValue(result, true, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainYearMonth/prototype/month/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainYearMonth/prototype/month/custom.js
vendored
Normal file
@ -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-get-temporal.plainyearmonth.prototype.month
|
||||
description: Custom calendar tests for month().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
month(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [instance], "month arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.PlainYearMonth(1830, 8, calendar);
|
||||
const result = instance.month;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainYearMonth/prototype/monthCode/custom.js
vendored
Normal file
@ -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-get-temporal.plainyearmonth.prototype.monthcode
|
||||
description: Custom calendar tests for monthCode().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
monthCode(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [instance], "monthCode arguments");
|
||||
return "M01";
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.PlainYearMonth(1830, 8, calendar);
|
||||
const result = instance.monthCode;
|
||||
assert.sameValue(result, "M01", "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainYearMonth/prototype/monthsInYear/custom.js
vendored
Normal file
@ -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-get-temporal.plainyearmonth.prototype.monthsinyear
|
||||
description: Custom calendar tests for monthsInYear().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
monthsInYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [instance], "monthsInYear arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.PlainYearMonth(1830, 8, calendar);
|
||||
const result = instance.monthsInYear;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/PlainYearMonth/prototype/year/custom.js
vendored
Normal file
27
test/built-ins/Temporal/PlainYearMonth/prototype/year/custom.js
vendored
Normal file
@ -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-get-temporal.plainyearmonth.prototype.year
|
||||
description: Custom calendar tests for year().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
year(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args, [instance], "year arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.PlainYearMonth(1830, 8, calendar);
|
||||
const result = instance.year;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/day/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/day/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.day
|
||||
description: Custom calendar tests for day().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
day(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "day arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.day;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/dayOfWeek/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.dayofweek
|
||||
description: Custom calendar tests for dayOfWeek().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
dayOfWeek(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "dayOfWeek arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.dayOfWeek;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/dayOfYear/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.dayofyear
|
||||
description: Custom calendar tests for dayOfYear().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
dayOfYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "dayOfYear arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.dayOfYear;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/daysInMonth/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.daysinmonth
|
||||
description: Custom calendar tests for daysInMonth().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
daysInMonth(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "daysInMonth arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.daysInMonth;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/daysInWeek/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.daysinweek
|
||||
description: Custom calendar tests for daysInWeek().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
daysInWeek(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "daysInWeek arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.daysInWeek;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/daysInYear/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.daysinyear
|
||||
description: Custom calendar tests for daysInYear().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
daysInYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "daysInYear arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.daysInYear;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/inLeapYear/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.inleapyear
|
||||
description: Custom calendar tests for inLeapYear().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
inLeapYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "inLeapYear arguments");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.inLeapYear;
|
||||
assert.sameValue(result, true, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/month/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/month/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.month
|
||||
description: Custom calendar tests for month().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
month(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "month arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.month;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/monthCode/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.monthcode
|
||||
description: Custom calendar tests for monthCode().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
monthCode(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "monthCode arguments");
|
||||
return "M01";
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.monthCode;
|
||||
assert.sameValue(result, "M01", "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/monthsInYear/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.monthsinyear
|
||||
description: Custom calendar tests for monthsInYear().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
monthsInYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "monthsInYear arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.monthsInYear;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/weekOfYear/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.weekofyear
|
||||
description: Custom calendar tests for weekOfYear().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
weekOfYear(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "weekOfYear arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.weekOfYear;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
27
test/built-ins/Temporal/ZonedDateTime/prototype/year/custom.js
vendored
Normal file
27
test/built-ins/Temporal/ZonedDateTime/prototype/year/custom.js
vendored
Normal file
@ -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-get-temporal.zoneddatetime.prototype.year
|
||||
description: Custom calendar tests for year().
|
||||
includes: [compareArray.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
let calls = 0;
|
||||
class CustomCalendar extends Temporal.Calendar {
|
||||
constructor() {
|
||||
super("iso8601");
|
||||
}
|
||||
year(...args) {
|
||||
++calls;
|
||||
assert.compareArray(args.map(String), [instance].map((arg) => arg.toPlainDateTime().toString()), "year arguments");
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
const calendar = new CustomCalendar();
|
||||
const instance = new Temporal.ZonedDateTime(1_000_000_000_000_000_000n, "UTC", calendar);
|
||||
const result = instance.year;
|
||||
assert.sameValue(result, 7, "result");
|
||||
assert.sameValue(calls, 1, "calls");
|
Loading…
x
Reference in New Issue
Block a user