diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string.js new file mode 100644 index 00000000000..9a8748d8771 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/argument-string.js @@ -0,0 +1,18 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-temporal.calendar.prototype.monthsinyear +description: An ISO 8601 date string should be converted as input +info: | + a. Perform ? ToTemporalDate(temporalDateLike). + 5. Return 12𝔽. +features: [Temporal] +---*/ + +let cal = new Temporal.Calendar("iso8601"); + +assert.sameValue(cal.monthsInYear("3456-12-20"), 12); +assert.sameValue(cal.monthsInYear("+000998-01-28"), 12); +assert.sameValue(cal.monthsInYear("3456-12-20T03:04:05+00:00[UTC]"), 12); +assert.sameValue(cal.monthsInYear("+000998-01-28T03:04:05+00:00[UTC]"), 12); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/basic.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/basic.js index fcf4e35084a..9edcee17457 100644 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/basic.js +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/basic.js @@ -9,9 +9,9 @@ features: [Temporal] const iso = Temporal.Calendar.from("iso8601"); const res = 12; -assert.sameValue(iso.monthsInYear(Temporal.PlainDate.from("1994-11-05")), res, "PlainDate"); -assert.sameValue(iso.monthsInYear(Temporal.PlainDateTime.from("1994-11-05T08:15:30")), res, "PlainDateTime"); -assert.sameValue(iso.monthsInYear(Temporal.PlainYearMonth.from("1994-11")), res, "PlainYearMonth"); +assert.sameValue(iso.monthsInYear(new Temporal.PlainDate(1994, 11, 5)), res, "PlainDate"); +assert.sameValue(iso.monthsInYear(new Temporal.PlainDateTime(1994, 11, 5, 8, 15, 30)), res, "PlainDateTime"); +assert.sameValue(iso.monthsInYear(new Temporal.PlainYearMonth(1994, 11)), res, "PlainYearMonth"); assert.sameValue(iso.monthsInYear({ year: 1994, month: 11, day: 5 }), res, "property bag"); assert.sameValue(iso.monthsInYear("1994-11-05"), res, "string"); assert.throws(TypeError, () => iso.monthsInYear({ year: 2000 }), "property bag with missing properties"); diff --git a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/branding.js b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/branding.js index e86c5f50e22..4d16a000786 100644 --- a/test/built-ins/Temporal/Calendar/prototype/monthsInYear/branding.js +++ b/test/built-ins/Temporal/Calendar/prototype/monthsInYear/branding.js @@ -11,12 +11,14 @@ const monthsInYear = Temporal.Calendar.prototype.monthsInYear; assert.sameValue(typeof monthsInYear, "function"); -assert.throws(TypeError, () => monthsInYear.call(undefined), "undefined"); -assert.throws(TypeError, () => monthsInYear.call(null), "null"); -assert.throws(TypeError, () => monthsInYear.call(true), "true"); -assert.throws(TypeError, () => monthsInYear.call(""), "empty string"); -assert.throws(TypeError, () => monthsInYear.call(Symbol()), "symbol"); -assert.throws(TypeError, () => monthsInYear.call(1), "1"); -assert.throws(TypeError, () => monthsInYear.call({}), "plain object"); -assert.throws(TypeError, () => monthsInYear.call(Temporal.Calendar), "Temporal.Calendar"); -assert.throws(TypeError, () => monthsInYear.call(Temporal.Calendar.prototype), "Temporal.Calendar.prototype"); +const arg = new Temporal.PlainDate(2021, 3, 4); + +assert.throws(TypeError, () => monthsInYear.call(undefined, arg), "undefined"); +assert.throws(TypeError, () => monthsInYear.call(null, arg), "null"); +assert.throws(TypeError, () => monthsInYear.call(true, arg), "true"); +assert.throws(TypeError, () => monthsInYear.call("", arg), "empty string"); +assert.throws(TypeError, () => monthsInYear.call(Symbol(), arg), "symbol"); +assert.throws(TypeError, () => monthsInYear.call(1, arg), "1"); +assert.throws(TypeError, () => monthsInYear.call({}, arg), "plain object"); +assert.throws(TypeError, () => monthsInYear.call(Temporal.Calendar, arg), "Temporal.Calendar"); +assert.throws(TypeError, () => monthsInYear.call(Temporal.Calendar.prototype, arg), "Temporal.Calendar.prototype");