mirror of https://github.com/tc39/test262.git
Add tests for Temporal.Calendar.p*.monthsInYear
(Philip, March 2022: This was originally Frank's PR #3059. I did some reformatting, removed duplicate tests, and combined with some existing tests.)
This commit is contained in:
parent
b064eb64f3
commit
c22b8ab9c4
|
@ -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);
|
|
@ -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");
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue