mirror of
https://github.com/tc39/test262.git
synced 2025-05-29 19:20:30 +02:00
Remove support for nested Temporal calendar property bags
Previously, "nested" calendar property bags were unwrapped up to one level. That is, this object: { calendar: { // ...Temporal.Calendar methods } } would not be considered to implement the Calendar protocol, but would have its calendar property used instead, if it were passed to an API that required a Calendar protocol object. These nested property bags are no longer supported. Discussion: https://github.com/tc39/proposal-temporal/issues/2104#issuecomment-1409549753 Corresponding normative PR: https://github.com/tc39/proposal-temporal/pull/2485
This commit is contained in:
parent
24def913ec
commit
bc979c51a5
@ -1475,10 +1475,7 @@ var TemporalHelpers = {
|
|||||||
const originalResult = iso8601.dateFromFields(...args);
|
const originalResult = iso8601.dateFromFields(...args);
|
||||||
// Replace the calendar in the result with the call-tracking calendar
|
// Replace the calendar in the result with the call-tracking calendar
|
||||||
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
||||||
const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this);
|
return new Temporal.PlainDate(isoYear, isoMonth, isoDay, this);
|
||||||
// Remove the HasProperty check resulting from the above constructor call
|
|
||||||
assert.sameValue(calls.pop(), `has ${objectName}.calendar`);
|
|
||||||
return result;
|
|
||||||
},
|
},
|
||||||
yearMonthFromFields(...args) {
|
yearMonthFromFields(...args) {
|
||||||
calls.push(`call ${objectName}.yearMonthFromFields`);
|
calls.push(`call ${objectName}.yearMonthFromFields`);
|
||||||
@ -1489,10 +1486,7 @@ var TemporalHelpers = {
|
|||||||
const originalResult = iso8601.yearMonthFromFields(...args);
|
const originalResult = iso8601.yearMonthFromFields(...args);
|
||||||
// Replace the calendar in the result with the call-tracking calendar
|
// Replace the calendar in the result with the call-tracking calendar
|
||||||
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
||||||
const result = new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay);
|
return new Temporal.PlainYearMonth(isoYear, isoMonth, this, isoDay);
|
||||||
// Remove the HasProperty check resulting from the above constructor call
|
|
||||||
assert.sameValue(calls.pop(), `has ${objectName}.calendar`);
|
|
||||||
return result;
|
|
||||||
},
|
},
|
||||||
monthDayFromFields(...args) {
|
monthDayFromFields(...args) {
|
||||||
calls.push(`call ${objectName}.monthDayFromFields`);
|
calls.push(`call ${objectName}.monthDayFromFields`);
|
||||||
@ -1503,10 +1497,7 @@ var TemporalHelpers = {
|
|||||||
const originalResult = iso8601.monthDayFromFields(...args);
|
const originalResult = iso8601.monthDayFromFields(...args);
|
||||||
// Replace the calendar in the result with the call-tracking calendar
|
// Replace the calendar in the result with the call-tracking calendar
|
||||||
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
||||||
const result = new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear);
|
return new Temporal.PlainMonthDay(isoMonth, isoDay, this, isoYear);
|
||||||
// Remove the HasProperty check resulting from the above constructor call
|
|
||||||
assert.sameValue(calls.pop(), `has ${objectName}.calendar`);
|
|
||||||
return result;
|
|
||||||
},
|
},
|
||||||
dateAdd(...args) {
|
dateAdd(...args) {
|
||||||
calls.push(`call ${objectName}.dateAdd`);
|
calls.push(`call ${objectName}.dateAdd`);
|
||||||
@ -1516,10 +1507,7 @@ var TemporalHelpers = {
|
|||||||
}
|
}
|
||||||
const originalResult = iso8601.dateAdd(...args);
|
const originalResult = iso8601.dateAdd(...args);
|
||||||
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
const {isoYear, isoMonth, isoDay} = originalResult.getISOFields();
|
||||||
const result = new Temporal.PlainDate(isoYear, isoMonth, isoDay, this);
|
return new Temporal.PlainDate(isoYear, isoMonth, isoDay, this);
|
||||||
// Remove the HasProperty check resulting from the above constructor call
|
|
||||||
assert.sameValue(calls.pop(), `has ${objectName}.calendar`);
|
|
||||||
return result;
|
|
||||||
},
|
},
|
||||||
id: "iso8601",
|
id: "iso8601",
|
||||||
};
|
};
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.from
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to from() does not have its
|
|
||||||
'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const arg = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(arg, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Temporal.Calendar.from(arg);
|
|
||||||
Temporal.Calendar.from({ calendar: arg });
|
|
@ -1,11 +0,0 @@
|
|||||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.from
|
|
||||||
description: Converting objects to Temporal.Calendar
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
assert.throws(RangeError, () => Temporal.Calendar.from({ calendar: "local" }));
|
|
||||||
assert.throws(RangeError, () => Temporal.Calendar.from({ calendar: { calendar: "iso8601" } }));
|
|
@ -1,32 +0,0 @@
|
|||||||
// Copyright (C) 2021 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.from
|
|
||||||
description: Converting objects to Temporal.Calendar
|
|
||||||
includes: [compareArray.js, temporalHelpers.js]
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const expected = [
|
|
||||||
"has outer.calendar",
|
|
||||||
"get outer.calendar",
|
|
||||||
"has inner.calendar",
|
|
||||||
"get inner.toString",
|
|
||||||
"call inner.toString",
|
|
||||||
];
|
|
||||||
const actual = [];
|
|
||||||
const calendar = TemporalHelpers.propertyBagObserver(actual, {
|
|
||||||
calendar: new Proxy(TemporalHelpers.toPrimitiveObserver(actual, "iso8601", "inner"), {
|
|
||||||
has(t, p) {
|
|
||||||
actual.push(`has inner.${p}`);
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
get(t, p) {
|
|
||||||
return t[p];
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
}, "outer");
|
|
||||||
const result = Temporal.Calendar.from(calendar);
|
|
||||||
assert.sameValue(result.id, "iso8601");
|
|
||||||
assert.compareArray(actual, expected);
|
|
@ -3,19 +3,9 @@
|
|||||||
|
|
||||||
/*---
|
/*---
|
||||||
esid: sec-temporal.calendar.from
|
esid: sec-temporal.calendar.from
|
||||||
description: Converting objects to Temporal.Calendar
|
description: Converting a plain object to Temporal.Calendar gives the same object
|
||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
const cal = new Temporal.Calendar("iso8601");
|
|
||||||
const calFromObject = Temporal.Calendar.from({ calendar: cal });
|
|
||||||
assert(calFromObject instanceof Temporal.Calendar);
|
|
||||||
assert.sameValue(calFromObject.id, "iso8601");
|
|
||||||
|
|
||||||
const calFromString = Temporal.Calendar.from({ calendar: "iso8601" });
|
|
||||||
assert(calFromString instanceof Temporal.Calendar);
|
|
||||||
assert.sameValue(calFromString.id, "iso8601");
|
|
||||||
|
|
||||||
const custom = { id: "custom-calendar" };
|
const custom = { id: "custom-calendar" };
|
||||||
assert.sameValue(Temporal.Calendar.from({ calendar: custom }), custom);
|
|
||||||
assert.sameValue(Temporal.Calendar.from(custom), custom);
|
assert.sameValue(Temporal.Calendar.from(custom), custom);
|
||||||
|
@ -7,18 +7,10 @@ description: Leap second is a valid ISO string for Calendar
|
|||||||
features: [Temporal]
|
features: [Temporal]
|
||||||
---*/
|
---*/
|
||||||
|
|
||||||
let arg = "2016-12-31T23:59:60";
|
const arg = "2016-12-31T23:59:60";
|
||||||
const result1 = Temporal.Calendar.from(arg);
|
const result = Temporal.Calendar.from(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1.id,
|
result.id,
|
||||||
"iso8601",
|
"iso8601",
|
||||||
"leap second is a valid ISO string for Calendar"
|
"leap second is a valid ISO string for Calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { calendar: "2016-12-31T23:59:60" };
|
|
||||||
const result2 = Temporal.Calendar.from(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2.id,
|
|
||||||
"iso8601",
|
|
||||||
"leap second is a valid ISO string for Calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -20,7 +20,6 @@ const rangeErrorTests = [
|
|||||||
|
|
||||||
for (const [arg, description] of rangeErrorTests) {
|
for (const [arg, description] of rangeErrorTests) {
|
||||||
assert.throws(RangeError, () => Temporal.Calendar.from(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => Temporal.Calendar.from(arg), `${description} does not convert to a valid ISO string`);
|
||||||
assert.throws(RangeError, () => Temporal.Calendar.from({ calendar: arg }), `${description} does not convert to a valid ISO string (in property bag)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -29,5 +28,4 @@ const typeErrorTests = [
|
|||||||
|
|
||||||
for (const [arg, description] of typeErrorTests) {
|
for (const [arg, description] of typeErrorTests) {
|
||||||
assert.throws(TypeError, () => Temporal.Calendar.from(arg), `${description} is not a valid object and does not convert to a string`);
|
assert.throws(TypeError, () => Temporal.Calendar.from(arg), `${description} is not a valid object and does not convert to a string`);
|
||||||
assert.throws(TypeError, () => Temporal.Calendar.from({ calendar: arg }), `${description} is not a valid object and does not convert to a string (in property bag)`);
|
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dateAdd(arg, new Temporal.Duration());
|
const result = instance.dateAdd(arg, new Temporal.Duration());
|
||||||
TemporalHelpers.assertPlainDate(result1, 1976, 11, "M11", 18, "Calendar is case-insensitive");
|
TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.dateAdd(arg, new Temporal.Duration());
|
|
||||||
TemporalHelpers.assertPlainDate(result2, 1976, 11, "M11", 18, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.dateadd
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to dateAdd() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.dateAdd(arg, new Temporal.Duration());
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.dateAdd(arg, new Temporal.Duration());
|
|
@ -12,18 +12,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dateAdd(arg, new Temporal.Duration());
|
const result = instance.dateAdd(arg, new Temporal.Duration());
|
||||||
TemporalHelpers.assertPlainDate(
|
TemporalHelpers.assertPlainDate(
|
||||||
result1,
|
result,
|
||||||
1976, 11, "M11", 18,
|
1976, 11, "M11", 18,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.dateAdd(arg, new Temporal.Duration());
|
|
||||||
TemporalHelpers.assertPlainDate(
|
|
||||||
result2,
|
|
||||||
1976, 11, "M11", 18,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -12,13 +12,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dateAdd(arg, new Temporal.Duration());
|
const result = instance.dateAdd(arg, new Temporal.Duration());
|
||||||
TemporalHelpers.assertPlainDate(result1, 1976, 11, "M11", 18, "19970327 is a valid ISO string for calendar");
|
TemporalHelpers.assertPlainDate(result, 1976, 11, "M11", 18, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.dateAdd(arg, new Temporal.Duration());
|
|
||||||
TemporalHelpers.assertPlainDate(result2, 1976, 11, "M11", 18, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -27,16 +23,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.dateAdd(arg, new Temporal.Duration()),
|
() => instance.dateAdd(arg, new Temporal.Duration()),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.dateAdd(arg, new Temporal.Duration()),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.dateAdd(arg, new Temporal.Duration()), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.dateAdd(arg, new Temporal.Duration()), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,7 +11,6 @@ features: [Temporal]
|
|||||||
const expected = [
|
const expected = [
|
||||||
// ToTemporalDate → GetTemporalCalendarWithISODefault
|
// ToTemporalDate → GetTemporalCalendarWithISODefault
|
||||||
"get date.calendar",
|
"get date.calendar",
|
||||||
"has date.calendar.calendar",
|
|
||||||
// ToTemporalDate → CalendarFields
|
// ToTemporalDate → CalendarFields
|
||||||
"get date.calendar.fields",
|
"get date.calendar.fields",
|
||||||
"call date.calendar.fields",
|
"call date.calendar.fields",
|
||||||
|
@ -12,14 +12,8 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
|
const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
|
||||||
TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "Calendar is case-insensitive (first argument)");
|
TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "Calendar is case-insensitive (first argument)");
|
||||||
const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
|
const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
|
||||||
TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "Calendar is case-insensitive (second argument)");
|
TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "Calendar is case-insensitive (second argument)");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result3 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
|
|
||||||
TemporalHelpers.assertDuration(result3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "Calendar is case-insensitive (nested property, first argument)");
|
|
||||||
const result4 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
|
|
||||||
TemporalHelpers.assertDuration(result4, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "Calendar is case-insensitive (nested property, second argument)");
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.dateuntil
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to dateUntil() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.dateUntil(arg, arg);
|
|
@ -12,14 +12,8 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
|
const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
|
||||||
TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for calendar (first argument)");
|
TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for calendar (first argument)");
|
||||||
const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
|
const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
|
||||||
TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for calendar (second argument)");
|
TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for calendar (second argument)");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result3 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
|
|
||||||
TemporalHelpers.assertDuration(result3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for calendar (nested property, first argument)");
|
|
||||||
const result4 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
|
|
||||||
TemporalHelpers.assertDuration(result4, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "leap second is a valid ISO string for calendar (nested property, second argument)");
|
|
||||||
|
@ -12,18 +12,12 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
|
const result1 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
|
||||||
TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (first argument)");
|
TemporalHelpers.assertDuration(result1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (first argument)");
|
||||||
const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
|
const result2 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
|
||||||
TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (second argument)");
|
TemporalHelpers.assertDuration(result2, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (second argument)");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result3 = instance.dateUntil(arg, new Temporal.PlainDate(1976, 11, 19));
|
|
||||||
TemporalHelpers.assertDuration(result3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property, first argument)");
|
|
||||||
const result4 = instance.dateUntil(new Temporal.PlainDate(1976, 11, 19), arg);
|
|
||||||
TemporalHelpers.assertDuration(result4, 0, 0, 0, -1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for calendar (nested property, second argument)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
-19970327,
|
-19970327,
|
||||||
@ -31,7 +25,7 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)),
|
() => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)),
|
||||||
@ -42,15 +36,4 @@ for (const calendar of numbers) {
|
|||||||
() => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg),
|
() => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (second argument)`
|
`Number ${calendar} does not convert to a valid ISO string for calendar (second argument)`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, first argument)`
|
|
||||||
);
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property, second argument)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -22,13 +22,9 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} does not convert to a valid ISO string (first argument)`);
|
assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} does not convert to a valid ISO string (first argument)`);
|
||||||
assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} does not convert to a valid ISO string (second argument)`);
|
assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} does not convert to a valid ISO string (second argument)`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} does not convert to a valid ISO string (nested property, first argument)`);
|
|
||||||
assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} does not convert to a valid ISO string (nested property, second argument)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -39,15 +35,7 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} is not a valid property bag and does not convert to a string (first argument)`);
|
assert.throws(TypeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} is not a valid property bag and does not convert to a string (first argument)`);
|
||||||
assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} is not a valid property bag and does not convert to a string (second argument)`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `${description} is not a valid property bag and does not convert to a string (nested property, first argument)`);
|
|
||||||
assert.throws(TypeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `${description} is not a valid property bag and does not convert to a string (nested property, second argument)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.dateUntil(arg, new Temporal.PlainDate(1977, 11, 19)), `nested undefined calendar property is always a RangeError (first argument)`);
|
|
||||||
assert.throws(RangeError, () => instance.dateUntil(new Temporal.PlainDate(1977, 11, 19), arg), `nested undefined calendar property is always a RangeError (second argument)`);
|
|
||||||
|
@ -11,7 +11,6 @@ features: [Temporal]
|
|||||||
const expected = [
|
const expected = [
|
||||||
// ToTemporalDate 1 → GetTemporalCalendarWithISODefault
|
// ToTemporalDate 1 → GetTemporalCalendarWithISODefault
|
||||||
"get one.calendar",
|
"get one.calendar",
|
||||||
"has one.calendar.calendar",
|
|
||||||
// ToTemporalDate 1 → CalendarFields
|
// ToTemporalDate 1 → CalendarFields
|
||||||
"get one.calendar.fields",
|
"get one.calendar.fields",
|
||||||
"call one.calendar.fields",
|
"call one.calendar.fields",
|
||||||
@ -33,7 +32,6 @@ const expected = [
|
|||||||
"call one.calendar.dateFromFields",
|
"call one.calendar.dateFromFields",
|
||||||
// ToTemporalDate 2 → GetTemporalCalendarWithISODefault
|
// ToTemporalDate 2 → GetTemporalCalendarWithISODefault
|
||||||
"get two.calendar",
|
"get two.calendar",
|
||||||
"has two.calendar.calendar",
|
|
||||||
// ToTemporalDate 2 → CalendarFields
|
// ToTemporalDate 2 → CalendarFields
|
||||||
"get two.calendar.fields",
|
"get two.calendar.fields",
|
||||||
"call two.calendar.fields",
|
"call two.calendar.fields",
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.day(arg);
|
const result = instance.day(arg);
|
||||||
assert.sameValue(result1, 18, "Calendar is case-insensitive");
|
assert.sameValue(result, 18, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.day(arg);
|
|
||||||
assert.sameValue(result2, 18, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.day
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to day() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.day(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.day(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.day(arg);
|
const result = instance.day(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
18,
|
18,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.day(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
18,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.day(arg);
|
const result = instance.day(arg);
|
||||||
assert.sameValue(result1, 18, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 18, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.day(arg);
|
|
||||||
assert.sameValue(result2, 18, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.day(arg),
|
() => instance.day(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.day(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.day(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.day(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.day(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.day(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.day(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.day(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.day(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dayOfWeek(arg);
|
const result = instance.dayOfWeek(arg);
|
||||||
assert.sameValue(result1, 4, "Calendar is case-insensitive");
|
assert.sameValue(result, 4, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.dayOfWeek(arg);
|
|
||||||
assert.sameValue(result2, 4, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.dayofweek
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to dayOfWeek() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.dayOfWeek(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.dayOfWeek(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dayOfWeek(arg);
|
const result = instance.dayOfWeek(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
4,
|
4,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.dayOfWeek(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
4,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dayOfWeek(arg);
|
const result = instance.dayOfWeek(arg);
|
||||||
assert.sameValue(result1, 4, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 4, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.dayOfWeek(arg);
|
|
||||||
assert.sameValue(result2, 4, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.dayOfWeek(arg),
|
() => instance.dayOfWeek(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.dayOfWeek(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.dayOfWeek(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.dayOfWeek(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.dayOfWeek(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.dayOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.dayOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.dayOfWeek(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.dayOfWeek(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dayOfYear(arg);
|
const result = instance.dayOfYear(arg);
|
||||||
assert.sameValue(result1, 323, "Calendar is case-insensitive");
|
assert.sameValue(result, 323, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.dayOfYear(arg);
|
|
||||||
assert.sameValue(result2, 323, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.dayofyear
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to dayOfYear() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.dayOfYear(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.dayOfYear(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dayOfYear(arg);
|
const result = instance.dayOfYear(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
323,
|
323,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.dayOfYear(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
323,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.dayOfYear(arg);
|
const result = instance.dayOfYear(arg);
|
||||||
assert.sameValue(result1, 323, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 323, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.dayOfYear(arg);
|
|
||||||
assert.sameValue(result2, 323, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.dayOfYear(arg),
|
() => instance.dayOfYear(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.dayOfYear(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.dayOfYear(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.dayOfYear(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.dayOfYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.dayOfYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.dayOfYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.dayOfYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.dayOfYear(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.daysInMonth(arg);
|
const result = instance.daysInMonth(arg);
|
||||||
assert.sameValue(result1, 30, "Calendar is case-insensitive");
|
assert.sameValue(result, 30, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.daysInMonth(arg);
|
|
||||||
assert.sameValue(result2, 30, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.daysinmonth
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to daysInMonth() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.daysInMonth(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.daysInMonth(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.daysInMonth(arg);
|
const result = instance.daysInMonth(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
30,
|
30,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.daysInMonth(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
30,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.daysInMonth(arg);
|
const result = instance.daysInMonth(arg);
|
||||||
assert.sameValue(result1, 30, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 30, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.daysInMonth(arg);
|
|
||||||
assert.sameValue(result2, 30, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.daysInMonth(arg),
|
() => instance.daysInMonth(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.daysInMonth(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.daysInMonth(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.daysInMonth(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.daysInMonth(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.daysInMonth(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.daysInMonth(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.daysInMonth(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.daysInMonth(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.daysInWeek(arg);
|
const result = instance.daysInWeek(arg);
|
||||||
assert.sameValue(result1, 7, "Calendar is case-insensitive");
|
assert.sameValue(result, 7, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.daysInWeek(arg);
|
|
||||||
assert.sameValue(result2, 7, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.daysinweek
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to daysInWeek() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.daysInWeek(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.daysInWeek(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.daysInWeek(arg);
|
const result = instance.daysInWeek(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
7,
|
7,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.daysInWeek(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
7,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.daysInWeek(arg);
|
const result = instance.daysInWeek(arg);
|
||||||
assert.sameValue(result1, 7, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 7, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.daysInWeek(arg);
|
|
||||||
assert.sameValue(result2, 7, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.daysInWeek(arg),
|
() => instance.daysInWeek(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.daysInWeek(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.daysInWeek(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.daysInWeek(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.daysInWeek(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.daysInWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.daysInWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.daysInWeek(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.daysInWeek(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.daysInYear(arg);
|
const result = instance.daysInYear(arg);
|
||||||
assert.sameValue(result1, 366, "Calendar is case-insensitive");
|
assert.sameValue(result, 366, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.daysInYear(arg);
|
|
||||||
assert.sameValue(result2, 366, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.daysinyear
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to daysInYear() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.daysInYear(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.daysInYear(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.daysInYear(arg);
|
const result = instance.daysInYear(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
366,
|
366,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.daysInYear(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
366,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.daysInYear(arg);
|
const result = instance.daysInYear(arg);
|
||||||
assert.sameValue(result1, 366, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 366, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.daysInYear(arg);
|
|
||||||
assert.sameValue(result2, 366, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.daysInYear(arg),
|
() => instance.daysInYear(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.daysInYear(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.daysInYear(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.daysInYear(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.daysInYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.daysInYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.daysInYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.daysInYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.daysInYear(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.inLeapYear(arg);
|
const result = instance.inLeapYear(arg);
|
||||||
assert.sameValue(result1, true, "Calendar is case-insensitive");
|
assert.sameValue(result, true, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.inLeapYear(arg);
|
|
||||||
assert.sameValue(result2, true, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.inleapyear
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to inLeapYear() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.inLeapYear(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.inLeapYear(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.inLeapYear(arg);
|
const result = instance.inLeapYear(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
true,
|
true,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.inLeapYear(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
true,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.inLeapYear(arg);
|
const result = instance.inLeapYear(arg);
|
||||||
assert.sameValue(result1, true, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, true, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.inLeapYear(arg);
|
|
||||||
assert.sameValue(result2, true, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.inLeapYear(arg),
|
() => instance.inLeapYear(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.inLeapYear(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.inLeapYear(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.inLeapYear(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.inLeapYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.inLeapYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.inLeapYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.inLeapYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.inLeapYear(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.month(arg);
|
const result = instance.month(arg);
|
||||||
assert.sameValue(result1, 11, "Calendar is case-insensitive");
|
assert.sameValue(result, 11, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.month(arg);
|
|
||||||
assert.sameValue(result2, 11, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.month
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to month() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.month(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.month(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.month(arg);
|
const result = instance.month(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
11,
|
11,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.month(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
11,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.month(arg);
|
const result = instance.month(arg);
|
||||||
assert.sameValue(result1, 11, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 11, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.month(arg);
|
|
||||||
assert.sameValue(result2, 11, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.month(arg),
|
() => instance.month(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.month(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.month(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.month(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.month(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.month(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.month(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.month(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.month(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.monthCode(arg);
|
const result = instance.monthCode(arg);
|
||||||
assert.sameValue(result1, "M11", "Calendar is case-insensitive");
|
assert.sameValue(result, "M11", "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.monthCode(arg);
|
|
||||||
assert.sameValue(result2, "M11", "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.monthcode
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to monthCode() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.monthCode(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.monthCode(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.monthCode(arg);
|
const result = instance.monthCode(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
"M11",
|
"M11",
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.monthCode(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
"M11",
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.monthCode(arg);
|
const result = instance.monthCode(arg);
|
||||||
assert.sameValue(result1, "M11", "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, "M11", "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.monthCode(arg);
|
|
||||||
assert.sameValue(result2, "M11", "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.monthCode(arg),
|
() => instance.monthCode(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.monthCode(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.monthCode(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.monthCode(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.monthCode(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.monthCode(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.monthCode(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.monthCode(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.monthCode(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.monthsInYear(arg);
|
const result = instance.monthsInYear(arg);
|
||||||
assert.sameValue(result1, 12, "Calendar is case-insensitive");
|
assert.sameValue(result, 12, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.monthsInYear(arg);
|
|
||||||
assert.sameValue(result2, 12, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.monthsinyear
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to monthsInYear() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.monthsInYear(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.monthsInYear(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.monthsInYear(arg);
|
const result = instance.monthsInYear(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
12,
|
12,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.monthsInYear(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
12,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.monthsInYear(arg);
|
const result = instance.monthsInYear(arg);
|
||||||
assert.sameValue(result1, 12, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 12, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.monthsInYear(arg);
|
|
||||||
assert.sameValue(result2, 12, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.monthsInYear(arg),
|
() => instance.monthsInYear(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.monthsInYear(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.monthsInYear(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.monthsInYear(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.monthsInYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.monthsInYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.monthsInYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.monthsInYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.monthsInYear(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.weekOfYear(arg);
|
const result = instance.weekOfYear(arg);
|
||||||
assert.sameValue(result1, 47, "Calendar is case-insensitive");
|
assert.sameValue(result, 47, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.weekOfYear(arg);
|
|
||||||
assert.sameValue(result2, 47, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.weekofyear
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to weekOfYear() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.weekOfYear(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.weekOfYear(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.weekOfYear(arg);
|
const result = instance.weekOfYear(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
47,
|
47,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.weekOfYear(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
47,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.weekOfYear(arg);
|
const result = instance.weekOfYear(arg);
|
||||||
assert.sameValue(result1, 47, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 47, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.weekOfYear(arg);
|
|
||||||
assert.sameValue(result2, 47, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.weekOfYear(arg),
|
() => instance.weekOfYear(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.weekOfYear(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.weekOfYear(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.weekOfYear(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.weekOfYear(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.weekOfYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.weekOfYear(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.weekOfYear(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.weekOfYear(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.year(arg);
|
const result = instance.year(arg);
|
||||||
assert.sameValue(result1, 1976, "Calendar is case-insensitive");
|
assert.sameValue(result, 1976, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.year(arg);
|
|
||||||
assert.sameValue(result2, 1976, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.year
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to year() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.year(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.year(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.year(arg);
|
const result = instance.year(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
1976,
|
1976,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.year(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
1976,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.year(arg);
|
const result = instance.year(arg);
|
||||||
assert.sameValue(result1, 1976, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 1976, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.year(arg);
|
|
||||||
assert.sameValue(result2, 1976, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.year(arg),
|
() => instance.year(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.year(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.year(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.year(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.year(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.year(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.year(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.year(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.year(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -11,10 +11,6 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "IsO8601";
|
const calendar = "IsO8601";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.yearOfWeek(arg);
|
const result = instance.yearOfWeek(arg);
|
||||||
assert.sameValue(result1, 1976, "Calendar is case-insensitive");
|
assert.sameValue(result, 1976, "Calendar is case-insensitive");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.yearOfWeek(arg);
|
|
||||||
assert.sameValue(result2, 1976, "Calendar is case-insensitive (nested property)");
|
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.calendar.prototype.yearofweek
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to yearOfWeek() in a property bag does
|
|
||||||
not have its 'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Calendar("iso8601");
|
|
||||||
|
|
||||||
const calendar = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(calendar, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
|
||||||
instance.yearOfWeek(arg);
|
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
instance.yearOfWeek(arg);
|
|
@ -11,18 +11,10 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = "2016-12-31T23:59:60";
|
const calendar = "2016-12-31T23:59:60";
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.yearOfWeek(arg);
|
const result = instance.yearOfWeek(arg);
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1,
|
result,
|
||||||
1976,
|
1976,
|
||||||
"leap second is a valid ISO string for calendar"
|
"leap second is a valid ISO string for calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.yearOfWeek(arg);
|
|
||||||
assert.sameValue(
|
|
||||||
result2,
|
|
||||||
1976,
|
|
||||||
"leap second is a valid ISO string for calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Calendar("iso8601");
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
const result1 = instance.yearOfWeek(arg);
|
const result = instance.yearOfWeek(arg);
|
||||||
assert.sameValue(result1, 1976, "19970327 is a valid ISO string for calendar");
|
assert.sameValue(result, 1976, "19970327 is a valid ISO string for calendar");
|
||||||
|
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
const result2 = instance.yearOfWeek(arg);
|
|
||||||
assert.sameValue(result2, 1976, "19970327 is a valid ISO string for calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
const arg = { year: 1976, monthCode: "M11", day: 18, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.yearOfWeek(arg),
|
() => instance.yearOfWeek(arg),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
`Number ${calendar} does not convert to a valid ISO string for calendar`
|
||||||
);
|
);
|
||||||
arg = { year: 1976, monthCode: "M11", day: 18, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.yearOfWeek(arg),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.yearOfWeek(arg), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.yearOfWeek(arg), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.yearOfWeek(arg), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -36,12 +33,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const arg = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.yearOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.yearOfWeek(arg), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.yearOfWeek(arg), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const arg = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.yearOfWeek(arg), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -88,7 +88,6 @@ actual.splice(0); // clear
|
|||||||
const expectedOpsForPlainRelativeTo = expected.concat([
|
const expectedOpsForPlainRelativeTo = expected.concat([
|
||||||
// ToRelativeTemporalObject
|
// ToRelativeTemporalObject
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
"get options.relativeTo.day",
|
"get options.relativeTo.day",
|
||||||
@ -154,7 +153,6 @@ actual.splice(0); // clear
|
|||||||
const expectedOpsForZonedRelativeTo = expected.concat([
|
const expectedOpsForZonedRelativeTo = expected.concat([
|
||||||
// ToRelativeTemporalObject
|
// ToRelativeTemporalObject
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
"get options.relativeTo.day",
|
"get options.relativeTo.day",
|
||||||
|
@ -71,7 +71,6 @@ actual.splice(0); // clear
|
|||||||
const expectedOpsForPlainRelativeTo = expected.concat([
|
const expectedOpsForPlainRelativeTo = expected.concat([
|
||||||
// ToRelativeTemporalObject
|
// ToRelativeTemporalObject
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
// PrepareTemporalFields
|
// PrepareTemporalFields
|
||||||
@ -136,7 +135,6 @@ actual.splice(0); // clear
|
|||||||
const expectedOpsForZonedRelativeTo = expected.concat([
|
const expectedOpsForZonedRelativeTo = expected.concat([
|
||||||
// ToRelativeTemporalObject
|
// ToRelativeTemporalObject
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
// PrepareTemporalFields
|
// PrepareTemporalFields
|
||||||
|
@ -12,13 +12,9 @@ const instance = new Temporal.Duration(1, 0, 0, 1);
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
const result1 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo });
|
const result = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo });
|
||||||
TemporalHelpers.assertDuration(result1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar");
|
TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar");
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
const result2 = instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo });
|
|
||||||
TemporalHelpers.assertDuration(result2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -27,16 +23,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }),
|
() => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
|
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
|
||||||
);
|
);
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -39,12 +36,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.add(new Temporal.Duration(0, 0, 0, 0, -24), { relativeTo }), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -48,7 +48,6 @@ const expectedOpsForPlainRelativeTo = [
|
|||||||
"call options.largestUnit.toString",
|
"call options.largestUnit.toString",
|
||||||
"get options.relativeTo",
|
"get options.relativeTo",
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
"get options.relativeTo.day",
|
"get options.relativeTo.day",
|
||||||
@ -231,7 +230,6 @@ const expectedOpsForZonedRelativeTo = [
|
|||||||
"call options.largestUnit.toString",
|
"call options.largestUnit.toString",
|
||||||
"get options.relativeTo",
|
"get options.relativeTo",
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
"get options.relativeTo.day",
|
"get options.relativeTo.day",
|
||||||
|
@ -12,13 +12,9 @@ const instance = new Temporal.Duration(1, 0, 0, 0, 24);
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
const result1 = instance.round({ largestUnit: "years", relativeTo });
|
const result = instance.round({ largestUnit: "years", relativeTo });
|
||||||
TemporalHelpers.assertDuration(result1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar");
|
TemporalHelpers.assertDuration(result, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar");
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
const result2 = instance.round({ largestUnit: "years", relativeTo });
|
|
||||||
TemporalHelpers.assertDuration(result2, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -27,16 +23,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.round({ largestUnit: "years", relativeTo }),
|
() => instance.round({ largestUnit: "years", relativeTo }),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
|
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
|
||||||
);
|
);
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.round({ largestUnit: "years", relativeTo }),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -39,12 +36,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.round({ largestUnit: "years", relativeTo }), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.round({ largestUnit: "years", relativeTo }), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -71,7 +71,6 @@ actual.splice(0); // clear
|
|||||||
const expectedOpsForPlainRelativeTo = expected.concat([
|
const expectedOpsForPlainRelativeTo = expected.concat([
|
||||||
// ToRelativeTemporalObject
|
// ToRelativeTemporalObject
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
// PrepareTemporalFields
|
// PrepareTemporalFields
|
||||||
@ -136,7 +135,6 @@ actual.splice(0); // clear
|
|||||||
const expectedOpsForZonedRelativeTo = expected.concat([
|
const expectedOpsForZonedRelativeTo = expected.concat([
|
||||||
// ToRelativeTemporalObject
|
// ToRelativeTemporalObject
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
// PrepareTemporalFields
|
// PrepareTemporalFields
|
||||||
|
@ -12,13 +12,9 @@ const instance = new Temporal.Duration(1, 0, 0, 1);
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
const result1 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo });
|
const result = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo });
|
||||||
TemporalHelpers.assertDuration(result1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar");
|
TemporalHelpers.assertDuration(result, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar");
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
const result2 = instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo });
|
|
||||||
TemporalHelpers.assertDuration(result2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, "19970327 is a valid ISO string for relativeTo.calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -27,16 +23,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }),
|
() => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
|
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
|
||||||
);
|
);
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -39,12 +36,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.subtract(new Temporal.Duration(0, 0, 0, 0, 24), { relativeTo }), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -36,7 +36,6 @@ const expectedOpsForPlainRelativeTo = [
|
|||||||
// ToRelativeTemporalObject
|
// ToRelativeTemporalObject
|
||||||
"get options.relativeTo",
|
"get options.relativeTo",
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
"get options.relativeTo.day",
|
"get options.relativeTo.day",
|
||||||
@ -144,7 +143,6 @@ const expectedOpsForZonedRelativeTo = [
|
|||||||
// ToRelativeTemporalObject
|
// ToRelativeTemporalObject
|
||||||
"get options.relativeTo",
|
"get options.relativeTo",
|
||||||
"get options.relativeTo.calendar",
|
"get options.relativeTo.calendar",
|
||||||
"has options.relativeTo.calendar.calendar",
|
|
||||||
"get options.relativeTo.calendar.fields",
|
"get options.relativeTo.calendar.fields",
|
||||||
"call options.relativeTo.calendar.fields",
|
"call options.relativeTo.calendar.fields",
|
||||||
"get options.relativeTo.day",
|
"get options.relativeTo.day",
|
||||||
|
@ -11,13 +11,9 @@ const instance = new Temporal.Duration(1, 0, 0, 0, 24);
|
|||||||
|
|
||||||
const calendar = 19970327;
|
const calendar = 19970327;
|
||||||
|
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
const result1 = instance.total({ unit: "days", relativeTo });
|
const result = instance.total({ unit: "days", relativeTo });
|
||||||
assert.sameValue(result1, 367, "19970327 is a valid ISO string for relativeTo.calendar");
|
assert.sameValue(result, 367, "19970327 is a valid ISO string for relativeTo.calendar");
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
const result2 = instance.total({ unit: "days", relativeTo });
|
|
||||||
assert.sameValue(result2, 367, "19970327 is a valid ISO string for relativeTo.calendar (nested property)");
|
|
||||||
|
|
||||||
const numbers = [
|
const numbers = [
|
||||||
1,
|
1,
|
||||||
@ -26,16 +22,10 @@ const numbers = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const calendar of numbers) {
|
for (const calendar of numbers) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(
|
assert.throws(
|
||||||
RangeError,
|
RangeError,
|
||||||
() => instance.total({ unit: "days", relativeTo }),
|
() => instance.total({ unit: "days", relativeTo }),
|
||||||
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
|
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar`
|
||||||
);
|
);
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(
|
|
||||||
RangeError,
|
|
||||||
() => instance.total({ unit: "days", relativeTo }),
|
|
||||||
`Number ${calendar} does not convert to a valid ISO string for relativeTo.calendar (nested property)`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,8 @@ const rangeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of rangeErrorTests) {
|
for (const [calendar, description] of rangeErrorTests) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), `${description} does not convert to a valid ISO string`);
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), `${description} does not convert to a valid ISO string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -39,12 +36,6 @@ const typeErrorTests = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const [calendar, description] of typeErrorTests) {
|
for (const [calendar, description] of typeErrorTests) {
|
||||||
let relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar };
|
||||||
assert.throws(TypeError, () => instance.total({ unit: "days", relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
assert.throws(TypeError, () => instance.total({ unit: "days", relativeTo }), `${description} is not a valid property bag and does not convert to a string`);
|
||||||
|
|
||||||
relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar } };
|
|
||||||
assert.throws(TypeError, () => instance.total({ unit: "days", relativeTo }), `${description} is not a valid property bag and does not convert to a string (nested property)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const relativeTo = { year: 2019, monthCode: "M11", day: 1, calendar: { calendar: undefined } };
|
|
||||||
assert.throws(RangeError, () => instance.total({ unit: "days", relativeTo }), `nested undefined calendar property is always a RangeError`);
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
|
|
||||||
/*---
|
|
||||||
esid: sec-temporal.instant.prototype.tozoneddatetime
|
|
||||||
description: >
|
|
||||||
A Temporal.Calendar instance passed to toZonedDateTime() does not have its
|
|
||||||
'calendar' property observably checked
|
|
||||||
features: [Temporal]
|
|
||||||
---*/
|
|
||||||
|
|
||||||
const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
|
|
||||||
|
|
||||||
const arg = new Temporal.Calendar("iso8601");
|
|
||||||
Object.defineProperty(arg, "calendar", {
|
|
||||||
get() {
|
|
||||||
throw new Test262Error("calendar.calendar should not be accessed");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
|
||||||
instance.toZonedDateTime({ calendar: { calendar: arg }, timeZone: "UTC" });
|
|
@ -9,18 +9,10 @@ features: [Temporal]
|
|||||||
|
|
||||||
const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
|
const instance = new Temporal.Instant(1_000_000_000_000_000_000n);
|
||||||
|
|
||||||
let arg = "2016-12-31T23:59:60";
|
const arg = "2016-12-31T23:59:60";
|
||||||
const result1 = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
const result = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
result1.calendarId,
|
result.calendarId,
|
||||||
"iso8601",
|
"iso8601",
|
||||||
"leap second is a valid ISO string for Calendar"
|
"leap second is a valid ISO string for Calendar"
|
||||||
);
|
);
|
||||||
|
|
||||||
arg = { calendar: "2016-12-31T23:59:60" };
|
|
||||||
const result2 = instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" });
|
|
||||||
assert.sameValue(
|
|
||||||
result2.calendarId,
|
|
||||||
"iso8601",
|
|
||||||
"leap second is a valid ISO string for Calendar (nested property)"
|
|
||||||
);
|
|
||||||
|
@ -22,7 +22,6 @@ const rangeErrorTests = [
|
|||||||
|
|
||||||
for (const [arg, description] of rangeErrorTests) {
|
for (const [arg, description] of rangeErrorTests) {
|
||||||
assert.throws(RangeError, () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), `${description} does not convert to a valid ISO string`);
|
assert.throws(RangeError, () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), `${description} does not convert to a valid ISO string`);
|
||||||
assert.throws(RangeError, () => instance.toZonedDateTime({ calendar: { calendar: arg }, timeZone: "UTC" }), `${description} does not convert to a valid ISO string (in property bag)`);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const typeErrorTests = [
|
const typeErrorTests = [
|
||||||
@ -31,5 +30,4 @@ const typeErrorTests = [
|
|||||||
|
|
||||||
for (const [arg, description] of typeErrorTests) {
|
for (const [arg, description] of typeErrorTests) {
|
||||||
assert.throws(TypeError, () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), `${description} is not a valid object and does not convert to a string`);
|
assert.throws(TypeError, () => instance.toZonedDateTime({ calendar: arg, timeZone: "UTC" }), `${description} is not a valid object and does not convert to a string`);
|
||||||
assert.throws(TypeError, () => instance.toZonedDateTime({ calendar: { calendar: arg }, timeZone: "UTC" }), `${description} is not a valid object and does not convert to a string (in property bag)`);
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user