mirror of https://github.com/tc39/test262.git
51 lines
1.5 KiB
JavaScript
51 lines
1.5 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.plaintimeiso
|
||
|
description: PlainDateTime.toPlainTime is not observably called
|
||
|
includes: [compareArray.js]
|
||
|
features: [Temporal]
|
||
|
---*/
|
||
|
|
||
|
const actual = [];
|
||
|
const expected = [
|
||
|
"has timeZone.timeZone",
|
||
|
"get timeZone.getOffsetNanosecondsFor",
|
||
|
"call timeZone.getOffsetNanosecondsFor",
|
||
|
];
|
||
|
|
||
|
Object.defineProperty(Temporal.PlainDateTime.prototype, "toPlainTime", {
|
||
|
get() {
|
||
|
actual.push("get Temporal.PlainDateTime.prototype.toPlainTime");
|
||
|
return function() {
|
||
|
actual.push("call Temporal.PlainDateTime.prototype.toPlainTime");
|
||
|
};
|
||
|
},
|
||
|
});
|
||
|
|
||
|
const timeZone = new Proxy({
|
||
|
getOffsetNanosecondsFor(instant) {
|
||
|
actual.push("call timeZone.getOffsetNanosecondsFor");
|
||
|
assert.sameValue(instant instanceof Temporal.Instant, true, "Instant");
|
||
|
return -Number(instant.epochNanoseconds % 86400_000_000_000n);
|
||
|
},
|
||
|
}, {
|
||
|
has(target, property) {
|
||
|
actual.push(`has timeZone.${property}`);
|
||
|
return property in target;
|
||
|
},
|
||
|
get(target, property) {
|
||
|
actual.push(`get timeZone.${property}`);
|
||
|
return target[property];
|
||
|
},
|
||
|
});
|
||
|
|
||
|
const result = Temporal.Now.plainTimeISO(timeZone);
|
||
|
assert.sameValue(result instanceof Temporal.PlainTime, true);
|
||
|
for (const property of ["hour", "minute", "second", "millisecond", "microsecond", "nanosecond"]) {
|
||
|
assert.sameValue(result[property], 0, property);
|
||
|
}
|
||
|
|
||
|
assert.compareArray(actual, expected);
|