mirror of
https://github.com/tc39/test262.git
synced 2025-09-30 13:38:48 +02:00
Similar to the previous commit with property bags, many existing tests use a Proxy to test the order of observable operations which involve user code passed in as part of a Temporal.TimeZone object. I am going to write several more tests that do this, as well. This seems like a good thing to put into TemporalHelpers, where it can be implemented consistently so that we don't get discrepancies in which operations are tracked. Updates existing tests to use this helper.
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
// 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.plaindatetime
|
|
description: Behavior when provided calendar value is a function
|
|
includes: [compareArray.js, temporalHelpers.js]
|
|
features: [BigInt, Proxy, Temporal]
|
|
---*/
|
|
const actual = [];
|
|
|
|
const expected = [
|
|
'has timeZone.timeZone',
|
|
'get timeZone.getOffsetNanosecondsFor',
|
|
'call timeZone.getOffsetNanosecondsFor'
|
|
];
|
|
|
|
const calendar = function() {};
|
|
|
|
const timeZone = TemporalHelpers.timeZoneObserver(actual, "timeZone", {
|
|
getOffsetNanosecondsFor(instant) {
|
|
return -Number(instant.epochNanoseconds % 86400000000000n);
|
|
},
|
|
});
|
|
|
|
Object.defineProperty(Temporal.Calendar, 'from', {
|
|
get() {
|
|
actual.push('get Temporal.Calendar.from');
|
|
return undefined;
|
|
}
|
|
});
|
|
|
|
const result = Temporal.Now.plainDateTime(calendar, timeZone);
|
|
|
|
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');
|
|
}
|
|
|
|
assert.compareArray(actual, expected, 'The value of actual is expected to equal the value of expected');
|