From 56ed1a0f825c09ab2cecc9dcae73ef817c4700fc Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 10 Jun 2022 13:59:37 +0200 Subject: [PATCH] Temporal: Test custom calendar operations. --- .../PlainDate/prototype/dayOfWeek/custom.js | 27 +++++++++++++++++++ .../PlainDate/prototype/dayOfYear/custom.js | 27 +++++++++++++++++++ .../PlainDate/prototype/daysInMonth/custom.js | 27 +++++++++++++++++++ .../PlainDate/prototype/daysInWeek/custom.js | 27 +++++++++++++++++++ .../PlainDate/prototype/daysInYear/custom.js | 27 +++++++++++++++++++ .../PlainDate/prototype/inLeapYear/custom.js | 27 +++++++++++++++++++ .../prototype/monthsInYear/custom.js | 27 +++++++++++++++++++ .../PlainDate/prototype/weekOfYear/custom.js | 27 +++++++++++++++++++ .../prototype/dayOfWeek/custom.js | 27 +++++++++++++++++++ .../prototype/dayOfYear/custom.js | 27 +++++++++++++++++++ .../prototype/daysInMonth/custom.js | 27 +++++++++++++++++++ .../prototype/daysInWeek/custom.js | 27 +++++++++++++++++++ .../prototype/daysInYear/custom.js | 27 +++++++++++++++++++ .../prototype/inLeapYear/custom.js | 27 +++++++++++++++++++ .../prototype/monthsInYear/custom.js | 27 +++++++++++++++++++ .../prototype/weekOfYear/custom.js | 27 +++++++++++++++++++ 16 files changed, 432 insertions(+) create mode 100644 test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/custom.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/dayOfYear/custom.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/daysInMonth/custom.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/daysInWeek/custom.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/daysInYear/custom.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/inLeapYear/custom.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/monthsInYear/custom.js create mode 100644 test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/custom.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/custom.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/custom.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/custom.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/custom.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/custom.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/custom.js create mode 100644 test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom.js diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/custom.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/custom.js new file mode 100644 index 0000000000..faadc3058a --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/dayOfWeek/custom.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-get-temporal.plaindate.prototype.dayofweek +description: Custom calendar tests for dayOfWeek(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + dayOfWeek(...args) { + ++calls; + assert.compareArray(args, [pd], "dayOfWeek arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pd = new Temporal.PlainDate(1830, 8, 25, calendar); +const result = pd.dayOfWeek; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/custom.js new file mode 100644 index 0000000000..f435eecb25 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/dayOfYear/custom.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-get-temporal.plaindate.prototype.dayofyear +description: Custom calendar tests for dayOfYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + dayOfYear(...args) { + ++calls; + assert.compareArray(args, [pd], "dayOfYear arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pd = new Temporal.PlainDate(1830, 8, 25, calendar); +const result = pd.dayOfYear; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/custom.js b/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/custom.js new file mode 100644 index 0000000000..9ad671adca --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/daysInMonth/custom.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-get-temporal.plaindate.prototype.daysinmonth +description: Custom calendar tests for daysInMonth(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + daysInMonth(...args) { + ++calls; + assert.compareArray(args, [pd], "daysInMonth arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pd = new Temporal.PlainDate(1830, 8, 25, calendar); +const result = pd.daysInMonth; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/custom.js b/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/custom.js new file mode 100644 index 0000000000..f181ac8c40 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/daysInWeek/custom.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-get-temporal.plaindate.prototype.daysinweek +description: Custom calendar tests for daysInWeek(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + daysInWeek(...args) { + ++calls; + assert.compareArray(args, [pd], "daysInWeek arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pd = new Temporal.PlainDate(1830, 8, 25, calendar); +const result = pd.daysInWeek; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/daysInYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/daysInYear/custom.js new file mode 100644 index 0000000000..1878dee64c --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/daysInYear/custom.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-get-temporal.plaindate.prototype.daysinyear +description: Custom calendar tests for daysInYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + daysInYear(...args) { + ++calls; + assert.compareArray(args, [pd], "daysInYear arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pd = new Temporal.PlainDate(1830, 8, 25, calendar); +const result = pd.daysInYear; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/custom.js new file mode 100644 index 0000000000..d8ca27082a --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/inLeapYear/custom.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-get-temporal.plaindate.prototype.inleapyear +description: Custom calendar tests for inLeapYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + inLeapYear(...args) { + ++calls; + assert.compareArray(args, [pd], "inLeapYear arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pd = new Temporal.PlainDate(1830, 8, 25, calendar); +const result = pd.inLeapYear; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/custom.js new file mode 100644 index 0000000000..7a6a5888ec --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/monthsInYear/custom.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-get-temporal.plaindate.prototype.monthsinyear +description: Custom calendar tests for monthsInYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + monthsInYear(...args) { + ++calls; + assert.compareArray(args, [pd], "monthsInYear arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pd = new Temporal.PlainDate(1830, 8, 25, calendar); +const result = pd.monthsInYear; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom.js b/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom.js new file mode 100644 index 0000000000..72107aa693 --- /dev/null +++ b/test/built-ins/Temporal/PlainDate/prototype/weekOfYear/custom.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-get-temporal.plaindate.prototype.weekofyear +description: Custom calendar tests for weekOfYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + weekOfYear(...args) { + ++calls; + assert.compareArray(args, [pd], "weekOfYear arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pd = new Temporal.PlainDate(1830, 8, 25, calendar); +const result = pd.weekOfYear; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/custom.js new file mode 100644 index 0000000000..23d6bbd632 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfWeek/custom.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-get-temporal.plaindatetime.prototype.dayofweek +description: Custom calendar tests for dayOfWeek(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + dayOfWeek(...args) { + ++calls; + assert.compareArray(args, [pdt], "dayOfWeek arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); +const result = pdt.dayOfWeek; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/custom.js new file mode 100644 index 0000000000..101676a079 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/dayOfYear/custom.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-get-temporal.plaindatetime.prototype.dayofyear +description: Custom calendar tests for dayOfYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + dayOfYear(...args) { + ++calls; + assert.compareArray(args, [pdt], "dayOfYear arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); +const result = pdt.dayOfYear; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/custom.js new file mode 100644 index 0000000000..2f2aae33e2 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/daysInMonth/custom.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-get-temporal.plaindatetime.prototype.daysinmonth +description: Custom calendar tests for daysInMonth(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + daysInMonth(...args) { + ++calls; + assert.compareArray(args, [pdt], "daysInMonth arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); +const result = pdt.daysInMonth; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/custom.js new file mode 100644 index 0000000000..5bfd635459 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/daysInWeek/custom.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-get-temporal.plaindatetime.prototype.daysinweek +description: Custom calendar tests for daysInWeek(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + daysInWeek(...args) { + ++calls; + assert.compareArray(args, [pdt], "daysInWeek arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); +const result = pdt.daysInWeek; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/custom.js new file mode 100644 index 0000000000..ba025cd446 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/daysInYear/custom.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-get-temporal.plaindatetime.prototype.daysinyear +description: Custom calendar tests for daysInYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + daysInYear(...args) { + ++calls; + assert.compareArray(args, [pdt], "daysInYear arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); +const result = pdt.daysInYear; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/custom.js new file mode 100644 index 0000000000..6f4e498eb8 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/inLeapYear/custom.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-get-temporal.plaindatetime.prototype.inleapyear +description: Custom calendar tests for inLeapYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + inLeapYear(...args) { + ++calls; + assert.compareArray(args, [pdt], "inLeapYear arguments"); + return "7"; + } +} + +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(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/custom.js new file mode 100644 index 0000000000..ef47a09429 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/monthsInYear/custom.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-get-temporal.plaindatetime.prototype.monthsinyear +description: Custom calendar tests for monthsInYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + monthsInYear(...args) { + ++calls; + assert.compareArray(args, [pdt], "monthsInYear arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); +const result = pdt.monthsInYear; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls"); diff --git a/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom.js b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom.js new file mode 100644 index 0000000000..32fd571456 --- /dev/null +++ b/test/built-ins/Temporal/PlainDateTime/prototype/weekOfYear/custom.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-get-temporal.plaindatetime.prototype.weekofyear +description: Custom calendar tests for weekOfYear(). +includes: [compareArray.js] +features: [Temporal] +---*/ + +let calls = 0; +class CustomCalendar extends Temporal.Calendar { + constructor() { + super("iso8601"); + } + weekOfYear(...args) { + ++calls; + assert.compareArray(args, [pdt], "weekOfYear arguments"); + return "7"; + } +} + +const calendar = new CustomCalendar(); +const pdt = new Temporal.PlainDateTime(1830, 8, 25, 20, 0, 0, 0, 0, 0, calendar); +const result = pdt.weekOfYear; +assert.sameValue(result, "7", "result"); +assert.sameValue(calls, 1, "calls");