diff --git a/test/built-ins/Temporal/Calendar/prototype/day/simple.js b/test/built-ins/Temporal/Calendar/prototype/day/simple.js new file mode 100644 index 0000000000..0b3a3504d7 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/day/simple.js @@ -0,0 +1,22 @@ +// 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.day +description: Temporal.Calendar.prototype.day will take different kind of objects. + and return the value of the day. +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalMonthDay]] internal slot, then + a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). + 5. Return ! ISODay(temporalDateLike). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); + +assert.sameValue(15, cal.day(new Temporal.PlainDate(2021, 7, 15))); +assert.sameValue(23, cal.day(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13))); +assert.sameValue(6, cal.day(new Temporal.PlainMonthDay(2, 6))); +assert.sameValue(18, cal.day("2019-03-18")); diff --git a/test/built-ins/Temporal/Calendar/prototype/month-code/simple.js b/test/built-ins/Temporal/Calendar/prototype/month-code/simple.js new file mode 100644 index 0000000000..80cec7a133 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month-code/simple.js @@ -0,0 +1,23 @@ +// 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.monthcode +description: Temporal.Calendar.prototype.monthCode will take different kind of object and return + the value of the monthCode. +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]], [[InitializedTemporalMonthDay]], or [[InitializedTemporalYearMonth]] internal slot, then + a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). + 5. Return ! ISOMonthCode(temporalDateLike). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); + +assert.sameValue("M07", cal.monthCode(new Temporal.PlainDate(2021, 7, 15))); +assert.sameValue("M08", cal.monthCode(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13))); +assert.sameValue("M06", cal.monthCode(new Temporal.PlainYearMonth(1999, 6))); +assert.sameValue("M02", cal.monthCode(new Temporal.PlainMonthDay(2, 6))); +assert.sameValue("M03", cal.monthCode("2019-03-15")); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/simple.js b/test/built-ins/Temporal/Calendar/prototype/month/simple.js new file mode 100644 index 0000000000..7a56c6de62 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/simple.js @@ -0,0 +1,24 @@ +// 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.month +description: Temporal.Calendar.prototype.month will take different kind of object and + return month value. +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(temporalDateLike) is Object and temporalDateLike has an [[InitializedTemporalMonthDay]] internal slot, then + a. Throw a TypeError exception. + 5. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). + 6. Return ! ISOMonth(temporalDateLike). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); + +assert.sameValue(7, cal.month(new Temporal.PlainDate(2021, 7, 15))); +assert.sameValue(8, cal.month(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13))); +assert.sameValue(6, cal.month(new Temporal.PlainYearMonth(1999, 6))); +assert.sameValue(3, cal.month("2019-03-15")); diff --git a/test/built-ins/Temporal/Calendar/prototype/month/throws-type-error.js b/test/built-ins/Temporal/Calendar/prototype/month/throws-type-error.js new file mode 100644 index 0000000000..2567288851 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/month/throws-type-error.js @@ -0,0 +1,22 @@ +// 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.month +description: Temporal.Calendar.prototype.month will throws TypeError while the input object + has an [[InitializedTemporalMonthDay]] internal slot. +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(temporalDateLike) is Object and temporalDateLike has an [[InitializedTemporalMonthDay]] internal slot, then + a. Throw a TypeError exception. + 5. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). + 6. Return ! ISOMonth(temporalDateLike). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); + +assert.throws(TypeError, () => cal.month(new Temporal.PlainMonthDay(3, 16)), + "invalid_argument"); diff --git a/test/built-ins/Temporal/Calendar/prototype/year/simple.js b/test/built-ins/Temporal/Calendar/prototype/year/simple.js new file mode 100644 index 0000000000..9563bf4d64 --- /dev/null +++ b/test/built-ins/Temporal/Calendar/prototype/year/simple.js @@ -0,0 +1,22 @@ +// 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.year +description: Temporal.Calendar.prototype.year will take different kind of object and return + the value of the year. +info: | + 1. Let calendar be the this value. + 2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]). + 3. Assert: calendar.[[Identifier]] is "iso8601". + 4. If Type(temporalDateLike) is not Object or temporalDateLike does not have an [[InitializedTemporalDate]] or [[InitializedTemporalYearMonth]] internal slot, then + a. Set temporalDateLike to ? ToTemporalDate(temporalDateLike). + 5. Return ! ISOYear(temporalDateLike). +features: [Temporal] +---*/ +let cal = new Temporal.Calendar("iso8601"); + +assert.sameValue(2021, cal.year(new Temporal.PlainDate(2021, 7, 15))); +assert.sameValue(1997, cal.year(new Temporal.PlainDateTime(1997, 8, 23, 5, 30, 13))); +assert.sameValue(1999, cal.year(new Temporal.PlainYearMonth(1999, 6))); +assert.sameValue(2019, cal.year("2019-03-15"));