test262/test/built-ins/Temporal/ZonedDateTime/compare/argument-propertybag-offset-not-agreeing-with-timezone.js
Philip Chimento 141aca7dba Test offset property in ZonedDateTime property bags
https://github.com/tc39/proposal-temporal/pull/1893 was a bug that caused
the 'offset' property to be ignored in ZonedDateTime property bags. Add
tests that ensure it is not ignored.

This was a normative change that achieved consensus at the October 2021
TC39 meeting.
2022-02-01 17:59:02 -05:00

16 lines
812 B
JavaScript

// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.zoneddatetime.compare
description: Property bag with offset property is rejected if offset does not agree with time zone
features: [Temporal]
---*/
const timeZone = new Temporal.TimeZone("+01:00");
const datetime = new Temporal.ZonedDateTime(0n, timeZone);
const properties = { year: 2021, month: 10, day: 28, offset: "-07:00", timeZone };
assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(properties, datetime), "offset property not matching time zone is rejected (first argument)");
assert.throws(RangeError, () => Temporal.ZonedDateTime.compare(datetime, properties), "offset property not matching time zone is rejected (second argument)");