mirror of
https://github.com/tc39/test262.git
synced 2025-09-25 11:08:49 +02:00
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
40 lines
983 B
JavaScript
40 lines
983 B
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.plaindatetimeiso
|
|
description: Rejects non-numeric nanosecond values reported by TimeZone-like object
|
|
features: [BigInt, Symbol, Temporal, arrow-function]
|
|
---*/
|
|
const invalidValues = [
|
|
undefined,
|
|
null,
|
|
true,
|
|
'2020-01-01T12:45:36',
|
|
Symbol(),
|
|
2n,
|
|
{},
|
|
Temporal.PlainDateTime,
|
|
Temporal.PlainDateTime.prototype
|
|
];
|
|
|
|
for (const dateTime of invalidValues) {
|
|
let callCount = 0;
|
|
|
|
const timeZone = {
|
|
id: 'Etc/Test',
|
|
getPossibleInstantsFor() { return []; },
|
|
getOffsetNanosecondsFor(instant, calendar) {
|
|
callCount += 1;
|
|
return dateTime;
|
|
}
|
|
};
|
|
|
|
assert.throws(
|
|
TypeError,
|
|
() => Temporal.Now.plainDateTimeISO(timeZone),
|
|
'Temporal.Now.plainDateTimeISO(timeZone) throws a TypeError exception'
|
|
);
|
|
|
|
assert.sameValue(callCount, 1, 'The value of callCount is expected to be 1');
|
|
}
|