mirror of https://github.com/tc39/test262.git
Improve coverage: zonedDateTime & zonedDateTimeISO
This commit is contained in:
parent
424406b5be
commit
aa5c2adb7c
|
@ -0,0 +1,47 @@
|
|||
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Behavior when provided calendar value is a function
|
||||
includes: [compareArray.js]
|
||||
features: [BigInt, Proxy, Temporal]
|
||||
---*/
|
||||
const actual = [];
|
||||
|
||||
const expected = [
|
||||
'has timeZone.timeZone'
|
||||
];
|
||||
|
||||
const calendar = function() {};
|
||||
|
||||
const timeZone = new Proxy({
|
||||
getOffsetNanosecondsFor(instant) {
|
||||
actual.push('call timeZone.getOffsetNanosecondsFor');
|
||||
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||
}
|
||||
}, {
|
||||
has(target, property) {
|
||||
actual.push(`has timeZone.${property}`);
|
||||
return property in target;
|
||||
},
|
||||
|
||||
get(target, property) {
|
||||
actual.push(`get timeZone.${property}`);
|
||||
return target[property];
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Temporal.Calendar, 'from', {
|
||||
get() {
|
||||
actual.push('get Temporal.Calendar.from');
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
const result = Temporal.Now.zonedDateTime(calendar, timeZone);
|
||||
|
||||
assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected');
|
||||
|
||||
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');
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Forwards error thrown by invoking "toString" property
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var calendar = {
|
||||
calendar: {
|
||||
calendar: true,
|
||||
toString: function() {
|
||||
throw new Test262Error();
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTime(calendar);
|
||||
}, 'Temporal.Now.zonedDateTime(calendar) throws a Test262Error exception');
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Forwards error thrown by retrieving value of "calendar" property
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var calendar = {
|
||||
get calendar() {
|
||||
throw new Test262Error();
|
||||
},
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTime(calendar);
|
||||
}, 'Temporal.Now.zonedDateTime(calendar) throws a Test262Error exception');
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Forwards error thrown by checking presence of "calendar" property
|
||||
features: [Proxy, Temporal]
|
||||
---*/
|
||||
|
||||
var calendar = new Proxy({}, {
|
||||
has: function(target, property) {
|
||||
if (property === 'calendar') {
|
||||
throw new Test262Error();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTime(calendar);
|
||||
}, 'Temporal.Now.zonedDateTime(calendar) throws a Test262Error exception');
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Forwards error thrown by checking presence of nested "calendar" property
|
||||
features: [Proxy, Temporal]
|
||||
---*/
|
||||
|
||||
var calendar = {
|
||||
calendar: new Proxy({}, {
|
||||
has: function(target, property) {
|
||||
if (property === 'calendar') {
|
||||
throw new Test262Error();
|
||||
}
|
||||
},
|
||||
})
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTime(calendar);
|
||||
}, 'Temporal.Now.zonedDateTime(calendar) throws a Test262Error exception');
|
|
@ -0,0 +1,73 @@
|
|||
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Observable interactions with the provided calendar-like object
|
||||
includes: [compareArray.js]
|
||||
features: [Proxy, Temporal]
|
||||
---*/
|
||||
|
||||
const actual = [];
|
||||
const expectedWithout = [
|
||||
'has calendar.calendar',
|
||||
'get calendar.calendar',
|
||||
'has nestedCalendar.calendar'
|
||||
];
|
||||
const expectedWith = [
|
||||
'has calendar.calendar',
|
||||
'get calendar.calendar',
|
||||
'has nestedCalendar.calendar',
|
||||
'get nestedCalendar.Symbol(Symbol.toPrimitive)',
|
||||
'get nestedCalendar.toString',
|
||||
'call nestedCalendar.toString'
|
||||
];
|
||||
const nestedCalendar = new Proxy({
|
||||
toString: function() {
|
||||
actual.push('call nestedCalendar.toString');
|
||||
return 'iso8601';
|
||||
}
|
||||
}, {
|
||||
has(target, property) {
|
||||
actual.push(`has nestedCalendar.${String(property)}`);
|
||||
return property in target;
|
||||
},
|
||||
get(target, property) {
|
||||
actual.push(`get nestedCalendar.${String(property)}`);
|
||||
return target[property];
|
||||
},
|
||||
});
|
||||
const calendar = new Proxy({
|
||||
calendar: nestedCalendar,
|
||||
toString: function() {
|
||||
actual.push('call calendar.toString');
|
||||
return 'iso8601';
|
||||
},
|
||||
}, {
|
||||
has(target, property) {
|
||||
actual.push(`has calendar.${String(property)}`);
|
||||
return property in target;
|
||||
},
|
||||
get(target, property) {
|
||||
actual.push(`get calendar.${String(property)}`);
|
||||
return target[property];
|
||||
},
|
||||
});
|
||||
|
||||
Object.defineProperty(Temporal.Calendar, 'from', {
|
||||
get() {
|
||||
actual.push('get Temporal.Calendar.from');
|
||||
return undefined;
|
||||
},
|
||||
});
|
||||
|
||||
Temporal.Now.zonedDateTime(calendar);
|
||||
|
||||
assert.compareArray(actual, expectedWithout, 'Observable interactions without `calendar` property');
|
||||
|
||||
actual.length = 0;
|
||||
nestedCalendar.calendar = null;
|
||||
|
||||
Temporal.Now.zonedDateTime(calendar);
|
||||
|
||||
assert.compareArray(actual, expectedWith, 'Observable interactions with `calendar` property');
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Temporal.Now.zonedDateTime is extensible.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert(
|
||||
Object.isExtensible(Temporal.Now.zonedDateTime),
|
||||
'Object.isExtensible(Temporal.Now.zonedDateTime) must return true'
|
||||
);
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Temporal.Now.zonedDateTime.name is "zonedDateTime".
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Temporal.Now.zonedDateTime.name,
|
||||
'zonedDateTime',
|
||||
'The value of Temporal.Now.zonedDateTime.name is expected to be "zonedDateTime"'
|
||||
);
|
||||
|
||||
verifyProperty(Temporal.Now.zonedDateTime, 'name', {
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Temporal.Now.zonedDateTime does not implement [[Construct]]
|
||||
includes: [isConstructor.js]
|
||||
features: [Reflect.construct, Temporal, arrow-function]
|
||||
---*/
|
||||
|
||||
assert.sameValue(isConstructor(Temporal.Now.zonedDateTime), false, 'isConstructor(Temporal.Now.zonedDateTime) must return false');
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new Temporal.Now.zonedDateTime();
|
||||
}, 'new Temporal.Now.zonedDateTime() throws a TypeError exception');
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: The "zonedDateTime" property of Temporal.Now
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.Now, 'zonedDateTime', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Forwards error thrown by invoking "toString" property
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
timeZone: {
|
||||
timeZone: true,
|
||||
toString: function() {
|
||||
throw new Test262Error();
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTime("iso8601", timeZone);
|
||||
}, 'Temporal.Now.zonedDateTime("iso8601", timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Forwards error thrown by retrieving value of "timeZone" property
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
get timeZone() {
|
||||
throw new Test262Error();
|
||||
},
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTime("iso8601", timeZone);
|
||||
}, 'Temporal.Now.zonedDateTime("iso8601", timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Forwards error thrown by checking presence of nested "timeZone" property
|
||||
features: [Proxy, Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
timeZone: new Proxy({}, {
|
||||
has: function(target, property) {
|
||||
if (property === 'timeZone') {
|
||||
throw new Test262Error();
|
||||
}
|
||||
},
|
||||
})
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTime("iso8601", timeZone);
|
||||
}, 'Temporal.Now.zonedDateTime("iso8601", timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Forwards error thrown by checking presence of "timeZone" property
|
||||
features: [Proxy, Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = new Proxy({}, {
|
||||
has: function(target, property) {
|
||||
if (property === 'timeZone') {
|
||||
throw new Test262Error();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTime("iso8601", timeZone);
|
||||
}, 'Temporal.Now.zonedDateTime("iso8601", timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Observable interactions with the provided timezone-like object
|
||||
includes: [compareArray.js]
|
||||
features: [BigInt, Proxy, Temporal]
|
||||
---*/
|
||||
const actual = [];
|
||||
|
||||
const expected = [
|
||||
'has timeZone.timeZone',
|
||||
'get timeZone.timeZone',
|
||||
'has nestedTimeZone.timeZone'
|
||||
];
|
||||
|
||||
const nestedTimeZone = new Proxy({
|
||||
getOffsetNanosecondsFor(instant) {
|
||||
actual.push('call nestedTimeZone.getOffsetNanosecondsFor');
|
||||
|
||||
assert.sameValue(
|
||||
instant instanceof Temporal.Instant,
|
||||
true,
|
||||
'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true'
|
||||
);
|
||||
|
||||
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||
}
|
||||
}, {
|
||||
has(target, property) {
|
||||
actual.push(`has nestedTimeZone.${String(property)}`);
|
||||
return property in target;
|
||||
},
|
||||
|
||||
get(target, property) {
|
||||
actual.push(`get nestedTimeZone.${String(property)}`);
|
||||
return target[property];
|
||||
}
|
||||
});
|
||||
|
||||
const timeZone = new Proxy({
|
||||
timeZone: nestedTimeZone,
|
||||
|
||||
getOffsetNanosecondsFor(instant) {
|
||||
actual.push('call timeZone.getOffsetNanosecondsFor');
|
||||
|
||||
assert.sameValue(
|
||||
instant instanceof Temporal.Instant,
|
||||
true,
|
||||
'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true'
|
||||
);
|
||||
|
||||
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||
}
|
||||
}, {
|
||||
has(target, property) {
|
||||
actual.push(`has timeZone.${property}`);
|
||||
return property in target;
|
||||
},
|
||||
|
||||
get(target, property) {
|
||||
actual.push(`get timeZone.${property}`);
|
||||
return target[property];
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Temporal.TimeZone, 'from', {
|
||||
get() {
|
||||
actual.push('get Temporal.TimeZone.from');
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
Temporal.Now.zonedDateTime('iso8601', timeZone);
|
||||
assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected');
|
|
@ -0,0 +1,12 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Temporal.Now.zonedDateTimeISO is extensible.
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert(
|
||||
Object.isExtensible(Temporal.Now.zonedDateTimeISO),
|
||||
'Object.isExtensible(Temporal.Now.zonedDateTimeISO) must return true'
|
||||
);
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Temporal.Now.zonedDateTimeISO.name is "zonedDateTimeISO".
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
assert.sameValue(
|
||||
Temporal.Now.zonedDateTimeISO.name,
|
||||
'zonedDateTimeISO',
|
||||
'The value of Temporal.Now.zonedDateTimeISO.name is expected to be "zonedDateTimeISO"'
|
||||
);
|
||||
|
||||
verifyProperty(Temporal.Now.zonedDateTimeISO, 'name', {
|
||||
enumerable: false,
|
||||
writable: false,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Temporal.Now.zonedDateTimeISO does not implement [[Construct]]
|
||||
includes: [isConstructor.js]
|
||||
features: [Reflect.construct, Temporal, arrow-function]
|
||||
---*/
|
||||
|
||||
assert.sameValue(isConstructor(Temporal.Now.zonedDateTimeISO), false, 'isConstructor(Temporal.Now.zonedDateTimeISO) must return false');
|
||||
|
||||
assert.throws(TypeError, () => {
|
||||
new Temporal.Now.zonedDateTimeISO();
|
||||
}, 'new Temporal.Now.zonedDateTimeISO() throws a TypeError exception');
|
|
@ -0,0 +1,14 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: The "zonedDateTimeISO" property of Temporal.Now
|
||||
includes: [propertyHelper.js]
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
verifyProperty(Temporal.Now, 'zonedDateTimeISO', {
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
});
|
|
@ -0,0 +1,20 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Forwards error thrown by invoking "toString" property
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
timeZone: {
|
||||
timeZone: true,
|
||||
toString: function() {
|
||||
throw new Test262Error();
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTimeISO(timeZone);
|
||||
}, 'Temporal.Now.zonedDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,17 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Forwards error thrown by retrieving value of "timeZone" property
|
||||
features: [Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
get timeZone() {
|
||||
throw new Test262Error();
|
||||
},
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTimeISO(timeZone);
|
||||
}, 'Temporal.Now.zonedDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Forwards error thrown by checking presence of nested "timeZone" property
|
||||
features: [Proxy, Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = {
|
||||
timeZone: new Proxy({}, {
|
||||
has: function(target, property) {
|
||||
if (property === 'timeZone') {
|
||||
throw new Test262Error();
|
||||
}
|
||||
},
|
||||
})
|
||||
};
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTimeISO(timeZone);
|
||||
}, 'Temporal.Now.zonedDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2021 the V8 project authors. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetimeiso
|
||||
description: Forwards error thrown by checking presence of "timeZone" property
|
||||
features: [Proxy, Temporal]
|
||||
---*/
|
||||
|
||||
var timeZone = new Proxy({}, {
|
||||
has: function(target, property) {
|
||||
if (property === 'timeZone') {
|
||||
throw new Test262Error();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
Temporal.Now.zonedDateTimeISO(timeZone);
|
||||
}, 'Temporal.Now.zonedDateTimeISO(timeZone) throws a Test262Error exception');
|
|
@ -0,0 +1,75 @@
|
|||
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
/*---
|
||||
esid: sec-temporal.now.zoneddatetime
|
||||
description: Observable interactions with the provided timezone-like object
|
||||
includes: [compareArray.js]
|
||||
features: [BigInt, Proxy, Temporal]
|
||||
---*/
|
||||
const actual = [];
|
||||
|
||||
const expected = [
|
||||
'has timeZone.timeZone',
|
||||
'get timeZone.timeZone',
|
||||
'has nestedTimeZone.timeZone'
|
||||
];
|
||||
|
||||
const nestedTimeZone = new Proxy({
|
||||
getOffsetNanosecondsFor(instant) {
|
||||
actual.push('call nestedTimeZone.getOffsetNanosecondsFor');
|
||||
|
||||
assert.sameValue(
|
||||
instant instanceof Temporal.Instant,
|
||||
true,
|
||||
'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true'
|
||||
);
|
||||
|
||||
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||
}
|
||||
}, {
|
||||
has(target, property) {
|
||||
actual.push(`has nestedTimeZone.${String(property)}`);
|
||||
return property in target;
|
||||
},
|
||||
|
||||
get(target, property) {
|
||||
actual.push(`get nestedTimeZone.${String(property)}`);
|
||||
return target[property];
|
||||
}
|
||||
});
|
||||
|
||||
const timeZone = new Proxy({
|
||||
timeZone: nestedTimeZone,
|
||||
|
||||
getOffsetNanosecondsFor(instant) {
|
||||
actual.push('call timeZone.getOffsetNanosecondsFor');
|
||||
|
||||
assert.sameValue(
|
||||
instant instanceof Temporal.Instant,
|
||||
true,
|
||||
'The result of evaluating (instant instanceof Temporal.Instant) is expected to be true'
|
||||
);
|
||||
|
||||
return -Number(instant.epochNanoseconds % 86400000000000n);
|
||||
}
|
||||
}, {
|
||||
has(target, property) {
|
||||
actual.push(`has timeZone.${property}`);
|
||||
return property in target;
|
||||
},
|
||||
|
||||
get(target, property) {
|
||||
actual.push(`get timeZone.${property}`);
|
||||
return target[property];
|
||||
}
|
||||
});
|
||||
|
||||
Object.defineProperty(Temporal.TimeZone, 'from', {
|
||||
get() {
|
||||
actual.push('get Temporal.TimeZone.from');
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
Temporal.Now.zonedDateTimeISO(timeZone);
|
||||
assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected');
|
Loading…
Reference in New Issue