mirror of
https://github.com/tc39/test262.git
synced 2025-07-21 21:14:45 +02:00
Validate required methods of Temporal TimeZone protocol
Checking whether an object implements the TimeZone protocol is now done by means of HasProperty operations for each of the required methods unless the object already has the TimeZone brand. 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
bc979c51a5
commit
d6a24fe906
@ -191,6 +191,9 @@ const expectedOpsForZonedRelativeTo = expected.concat([
|
||||
"call options.relativeTo.year.valueOf",
|
||||
"get options.relativeTo.calendar.dateFromFields",
|
||||
"call options.relativeTo.calendar.dateFromFields",
|
||||
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
|
||||
"has options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"has options.relativeTo.timeZone.id",
|
||||
"get options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"call options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"get options.relativeTo.timeZone.getOffsetNanosecondsFor",
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -175,6 +175,10 @@ const expectedOpsForZonedRelativeTo = expected.concat([
|
||||
// InterpretTemporalDateTimeFields
|
||||
"get options.relativeTo.calendar.dateFromFields",
|
||||
"call options.relativeTo.calendar.dateFromFields",
|
||||
// ToRelativeTemporalObject again
|
||||
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
|
||||
"has options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"has options.relativeTo.timeZone.id",
|
||||
// InterpretISODateTimeOffset
|
||||
"get options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"call options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -268,6 +268,9 @@ const expectedOpsForZonedRelativeTo = [
|
||||
"call options.relativeTo.year.valueOf",
|
||||
"get options.relativeTo.calendar.dateFromFields",
|
||||
"call options.relativeTo.calendar.dateFromFields",
|
||||
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
|
||||
"has options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"has options.relativeTo.timeZone.id",
|
||||
// InterpretISODateTimeOffset
|
||||
"get options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"call options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -175,6 +175,10 @@ const expectedOpsForZonedRelativeTo = expected.concat([
|
||||
// InterpretTemporalDateTimeFields
|
||||
"get options.relativeTo.calendar.dateFromFields",
|
||||
"call options.relativeTo.calendar.dateFromFields",
|
||||
// ToRelativeTemporalObject again
|
||||
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
|
||||
"has options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"has options.relativeTo.timeZone.id",
|
||||
// InterpretISODateTimeOffset
|
||||
"get options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"call options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -181,6 +181,9 @@ const expectedOpsForZonedRelativeTo = [
|
||||
"call options.relativeTo.year.valueOf",
|
||||
"get options.relativeTo.calendar.dateFromFields",
|
||||
"call options.relativeTo.calendar.dateFromFields",
|
||||
"has options.relativeTo.timeZone.getOffsetNanosecondsFor",
|
||||
"has options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"has options.relativeTo.timeZone.id",
|
||||
// InterpretISODateTimeOffset
|
||||
"get options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
"call options.relativeTo.timeZone.getPossibleInstantsFor",
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -19,6 +19,9 @@ const expected = [
|
||||
"get options.smallestUnit.toString",
|
||||
"call options.smallestUnit.toString",
|
||||
"get options.timeZone",
|
||||
"has options.timeZone.getOffsetNanosecondsFor",
|
||||
"has options.timeZone.getPossibleInstantsFor",
|
||||
"has options.timeZone.id",
|
||||
"get options.timeZone.getOffsetNanosecondsFor",
|
||||
"call options.timeZone.getOffsetNanosecondsFor",
|
||||
"get options.timeZone.getOffsetNanosecondsFor",
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -10,6 +10,9 @@ features: [Temporal]
|
||||
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
"get timeZone.getOffsetNanosecondsFor",
|
||||
"call timeZone.getOffsetNanosecondsFor",
|
||||
"get timeZone.getOffsetNanosecondsFor",
|
||||
|
@ -9,6 +9,11 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
];
|
||||
|
||||
const instant = Temporal.Instant.from("1975-02-02T14:25:36.123456789Z");
|
||||
const calendar = Temporal.Calendar.from("iso8601");
|
||||
@ -19,4 +24,4 @@ const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
|
||||
const result = instant.toZonedDateTime({ timeZone, calendar });
|
||||
assert.sameValue(result.epochNanoseconds, instant.epochNanoseconds);
|
||||
|
||||
assert.compareArray(actual, []);
|
||||
assert.compareArray(actual, expected);
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -10,6 +10,9 @@ features: [Temporal]
|
||||
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
"get timeZone.getOffsetNanosecondsFor",
|
||||
"call timeZone.getOffsetNanosecondsFor",
|
||||
];
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -9,6 +9,9 @@ features: [BigInt, Proxy, Temporal]
|
||||
const actual = [];
|
||||
|
||||
const expected = [
|
||||
'has timeZone.getOffsetNanosecondsFor',
|
||||
'has timeZone.getPossibleInstantsFor',
|
||||
'has timeZone.id',
|
||||
'get timeZone.getOffsetNanosecondsFor',
|
||||
'call timeZone.getOffsetNanosecondsFor'
|
||||
];
|
||||
|
@ -8,6 +8,8 @@ features: [BigInt, Temporal]
|
||||
const calendar = Temporal.Calendar.from('iso8601');
|
||||
|
||||
const timeZone = {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
getOffsetNanosecondsFor(instant) {
|
||||
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ features: [Temporal]
|
||||
|
||||
var calls = [];
|
||||
var timeZone = {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
getOffsetNanosecondsFor: function() {
|
||||
calls.push({
|
||||
args: arguments,
|
||||
|
@ -21,7 +21,9 @@ for (const dateTime of invalidValues) {
|
||||
let callCount = 0;
|
||||
|
||||
const timeZone = {
|
||||
getOffsetNanosecondsFor(instant, calendar) {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
getOffsetNanosecondsFor() {
|
||||
callCount += 1;
|
||||
return dateTime;
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
get getOffsetNanosecondsFor() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
getOffsetNanosecondsFor() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ features: [BigInt, Proxy, Temporal]
|
||||
const actual = [];
|
||||
|
||||
const expected = [
|
||||
'has timeZone.getOffsetNanosecondsFor',
|
||||
'has timeZone.getPossibleInstantsFor',
|
||||
'has timeZone.id',
|
||||
'get timeZone.getOffsetNanosecondsFor',
|
||||
'call timeZone.getOffsetNanosecondsFor'
|
||||
];
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -10,6 +10,9 @@ features: [Temporal]
|
||||
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
"get timeZone.getOffsetNanosecondsFor",
|
||||
"call timeZone.getOffsetNanosecondsFor",
|
||||
];
|
||||
|
@ -6,6 +6,8 @@ description: Return value describes the start of a day
|
||||
features: [BigInt, Temporal]
|
||||
---*/
|
||||
const timeZone = {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
getOffsetNanosecondsFor(instant) {
|
||||
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||
}
|
||||
|
@ -8,6 +8,8 @@ features: [Temporal]
|
||||
|
||||
var calls = [];
|
||||
var timeZone = {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
getOffsetNanosecondsFor: function() {
|
||||
calls.push({
|
||||
args: arguments,
|
||||
|
@ -21,6 +21,8 @@ for (const dateTime of invalidValues) {
|
||||
let callCount = 0;
|
||||
|
||||
const timeZone = {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
getOffsetNanosecondsFor(instant, calendar) {
|
||||
callCount += 1;
|
||||
return dateTime;
|
||||
|
@ -7,6 +7,8 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
get getOffsetNanosecondsFor() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
id: 'Etc/Test',
|
||||
getPossibleInstantsFor() { return []; },
|
||||
getOffsetNanosecondsFor() {
|
||||
throw new Test262Error();
|
||||
}
|
||||
|
@ -9,6 +9,9 @@ features: [BigInt, Proxy, Temporal]
|
||||
const actual = [];
|
||||
|
||||
const expected = [
|
||||
'has timeZone.getOffsetNanosecondsFor',
|
||||
'has timeZone.getPossibleInstantsFor',
|
||||
'has timeZone.id',
|
||||
'get timeZone.getOffsetNanosecondsFor',
|
||||
'call timeZone.getOffsetNanosecondsFor'
|
||||
];
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -10,6 +10,9 @@ features: [Temporal]
|
||||
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
"get timeZone.getOffsetNanosecondsFor",
|
||||
"call timeZone.getOffsetNanosecondsFor",
|
||||
];
|
||||
|
@ -10,6 +10,9 @@ features: [Temporal]
|
||||
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
"get timeZone.getOffsetNanosecondsFor",
|
||||
"call timeZone.getOffsetNanosecondsFor",
|
||||
];
|
||||
|
@ -7,6 +7,11 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||
features: [BigInt, Proxy, Temporal]
|
||||
---*/
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
];
|
||||
|
||||
const calendar = function() {};
|
||||
|
||||
@ -25,7 +30,7 @@ Object.defineProperty(Temporal.Calendar, 'from', {
|
||||
|
||||
const result = Temporal.Now.zonedDateTime(calendar, timeZone);
|
||||
|
||||
assert.compareArray(actual, [], 'no observable operations should be invoked');
|
||||
assert.compareArray(actual, expected, 'order of observable operations');
|
||||
|
||||
for (const property of ['hour', 'minute', 'second', 'millisecond', 'microsecond', 'nanosecond']) {
|
||||
assert.sameValue(result[property], 0, 'The value of result[property] is expected to be 0');
|
||||
|
@ -7,6 +7,11 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||
features: [BigInt, Proxy, Temporal]
|
||||
---*/
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
];
|
||||
|
||||
const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
|
||||
getOffsetNanosecondsFor(instant) {
|
||||
@ -28,4 +33,4 @@ Object.defineProperty(Temporal.TimeZone, 'from', {
|
||||
});
|
||||
|
||||
Temporal.Now.zonedDateTime('iso8601', timeZone);
|
||||
assert.compareArray(actual, [], 'no observable operations should be invoked');
|
||||
assert.compareArray(actual, expected, 'order of observable operations');
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -7,6 +7,11 @@ includes: [compareArray.js, temporalHelpers.js]
|
||||
features: [BigInt, Proxy, Temporal]
|
||||
---*/
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
];
|
||||
|
||||
const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
|
||||
getOffsetNanosecondsFor(instant) {
|
||||
@ -28,4 +33,4 @@ Object.defineProperty(Temporal.TimeZone, 'from', {
|
||||
});
|
||||
|
||||
Temporal.Now.zonedDateTimeISO(timeZone);
|
||||
assert.compareArray(actual, [], 'no observable operations should be invoked');
|
||||
assert.compareArray(actual, expected, 'order of observable operations');
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -9,6 +9,10 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
const expected = [
|
||||
// ToTemporalTimeZoneSlotValue
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
// ToTemporalDisambiguation
|
||||
"get options.disambiguation",
|
||||
"get options.disambiguation.toString",
|
||||
|
@ -10,6 +10,9 @@ features: [Temporal]
|
||||
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
"get options.disambiguation",
|
||||
"get options.disambiguation.toString",
|
||||
"call options.disambiguation.toString",
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -12,9 +12,7 @@ class CustomTimeZone extends Temporal.TimeZone {}
|
||||
const objects = [
|
||||
new Temporal.TimeZone("UTC"),
|
||||
new CustomTimeZone("UTC"),
|
||||
{},
|
||||
{ getPlainDateTimeFor: null },
|
||||
{ id: "Etc/Custom" },
|
||||
{ id: "Etc/Custom", getPossibleInstantsFor: null, getOffsetNanosecondsFor: null },
|
||||
];
|
||||
|
||||
const thisValues = [
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -28,6 +27,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -47,6 +47,9 @@ const expected = [
|
||||
"get one.year",
|
||||
"get one.year.valueOf",
|
||||
"call one.year.valueOf",
|
||||
"has one.timeZone.getOffsetNanosecondsFor",
|
||||
"has one.timeZone.getPossibleInstantsFor",
|
||||
"has one.timeZone.id",
|
||||
// InterpretTemporalDateTimeFields
|
||||
"get one.calendar.dateFromFields",
|
||||
"call one.calendar.dateFromFields",
|
||||
@ -94,6 +97,9 @@ const expected = [
|
||||
"get two.year",
|
||||
"get two.year.valueOf",
|
||||
"call two.year.valueOf",
|
||||
"has two.timeZone.getOffsetNanosecondsFor",
|
||||
"has two.timeZone.getPossibleInstantsFor",
|
||||
"has two.timeZone.id",
|
||||
// InterpretTemporalDateTimeFields
|
||||
"get two.calendar.dateFromFields",
|
||||
"call two.calendar.dateFromFields",
|
||||
|
@ -16,7 +16,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -25,6 +24,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -47,6 +47,9 @@ const expected = [
|
||||
"get item.year",
|
||||
"get item.year.valueOf",
|
||||
"call item.year.valueOf",
|
||||
"has item.timeZone.getOffsetNanosecondsFor",
|
||||
"has item.timeZone.getPossibleInstantsFor",
|
||||
"has item.timeZone.id",
|
||||
// InterpretTemporalDateTimeFields
|
||||
"get options.disambiguation",
|
||||
"get options.disambiguation.toString",
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -47,6 +47,9 @@ const expected = [
|
||||
"get other.year",
|
||||
"get other.year.valueOf",
|
||||
"call other.year.valueOf",
|
||||
"has other.timeZone.getOffsetNanosecondsFor",
|
||||
"has other.timeZone.getPossibleInstantsFor",
|
||||
"has other.timeZone.id",
|
||||
// InterpretTemporalDateTimeFields
|
||||
"get other.calendar.dateFromFields",
|
||||
"call other.calendar.dateFromFields",
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -47,6 +47,9 @@ const expected = [
|
||||
"get other.year",
|
||||
"get other.year.valueOf",
|
||||
"call other.year.valueOf",
|
||||
"has other.timeZone.getOffsetNanosecondsFor",
|
||||
"has other.timeZone.getPossibleInstantsFor",
|
||||
"has other.timeZone.id",
|
||||
"get other.calendar.dateFromFields",
|
||||
"call other.calendar.dateFromFields",
|
||||
"get other.timeZone.getPossibleInstantsFor",
|
||||
|
@ -10,6 +10,9 @@ features: [Temporal]
|
||||
|
||||
const actual = [];
|
||||
const expected = [
|
||||
"has timeZone.getOffsetNanosecondsFor",
|
||||
"has timeZone.getPossibleInstantsFor",
|
||||
"has timeZone.id",
|
||||
"get timeZone.getOffsetNanosecondsFor",
|
||||
"call timeZone.getOffsetNanosecondsFor",
|
||||
];
|
||||
|
@ -12,6 +12,7 @@ const tests = [
|
||||
["+01:00", "1970-01-01T02:01:01.987654321+01:00[+01:00]", "built-in offset"],
|
||||
[{
|
||||
getOffsetNanosecondsFor() { return 0; },
|
||||
getPossibleInstantsFor() { return []; },
|
||||
id: "Etc/Custom",
|
||||
}, "1970-01-01T01:01:01.987654321+00:00[Etc/Custom]", "custom"],
|
||||
];
|
||||
|
@ -14,6 +14,7 @@ const tests = [
|
||||
["+01:00", "1970-01-01T02:01:01.987654321+01:00[!+01:00]", "built-in offset"],
|
||||
[{
|
||||
getOffsetNanosecondsFor() { return 0; },
|
||||
getPossibleInstantsFor() { return []; },
|
||||
id: "Etc/Custom",
|
||||
}, "1970-01-01T01:01:01.987654321+00:00[!Etc/Custom]", "custom"],
|
||||
];
|
||||
|
@ -12,7 +12,8 @@ const tests = [
|
||||
["+01:00", "1970-01-01T02:01:01.987654321+01:00", "built-in offset"],
|
||||
[{
|
||||
getOffsetNanosecondsFor() { return 0; },
|
||||
toString() { return "Etc/Custom"; },
|
||||
getPossibleInstantsFor() { return []; },
|
||||
id: "Etc/Custom",
|
||||
}, "1970-01-01T01:01:01.987654321+00:00", "custom"],
|
||||
];
|
||||
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -47,6 +47,9 @@ const expected = [
|
||||
"get other.year",
|
||||
"get other.year.valueOf",
|
||||
"call other.year.valueOf",
|
||||
"has other.timeZone.getOffsetNanosecondsFor",
|
||||
"has other.timeZone.getPossibleInstantsFor",
|
||||
"has other.timeZone.id",
|
||||
"get other.calendar.dateFromFields",
|
||||
"call other.calendar.dateFromFields",
|
||||
"get other.timeZone.getPossibleInstantsFor",
|
||||
|
@ -18,6 +18,7 @@ features: [BigInt, Symbol, Temporal, arrow-function]
|
||||
);
|
||||
|
||||
const badTimeZone = {
|
||||
id: "Etc/Bad",
|
||||
getPossibleInstantsFor() { return []; },
|
||||
getOffsetNanosecondsFor: notCallable,
|
||||
};
|
||||
|
@ -18,7 +18,6 @@ const rangeErrorTests = [
|
||||
[1, "number that doesn't convert to a valid ISO string"],
|
||||
[19761118, "number that would convert to a valid ISO string in other contexts"],
|
||||
[1n, "bigint"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of rangeErrorTests) {
|
||||
@ -27,6 +26,8 @@ for (const [timeZone, description] of rangeErrorTests) {
|
||||
|
||||
const typeErrorTests = [
|
||||
[Symbol(), "symbol"],
|
||||
[{}, "object not implementing time zone protocol"],
|
||||
[new Temporal.Calendar("iso8601"), "calendar instance"],
|
||||
];
|
||||
|
||||
for (const [timeZone, description] of typeErrorTests) {
|
||||
|
@ -70,6 +70,7 @@ var fakeGregorian = {
|
||||
};
|
||||
var fakeVienna = {
|
||||
getOffsetNanosecondsFor() { return 3600_000_000_000; },
|
||||
getPossibleInstantsFor(datetime) { return [datetime.toZonedDateTime("+01:00").toInstant()]; },
|
||||
id: "Europe/Vienna",
|
||||
}
|
||||
var zdt = new Temporal.ZonedDateTime(epochNanos, fakeVienna, fakeGregorian);
|
||||
|
@ -8,6 +8,7 @@ features: [Temporal]
|
||||
---*/
|
||||
|
||||
var tz = {
|
||||
getOffsetNanosecondsFor() { return -5 * 3600_000_000_000; },
|
||||
getPossibleInstantsFor(pdt) { return Temporal.TimeZone.from("-05:00").getPossibleInstantsFor(pdt); },
|
||||
id: "America/New_York",
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user