test262/test/built-ins/Temporal/PlainDateTime/compare/argument-propertybag-optional-properties.js
Philip Chimento 85ae4c0966 Temporal: Add tests for optional properties in property bags
These tests confirm that Temporal-object-like property bags have the
correct default values for their optional properties.

This provides coverage for a V8 bug:
https://issues.chromium.org/issues/446728405
2025-10-30 17:40:54 +01:00

32 lines
890 B
JavaScript

// Copyright (C) 2025 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.compare
description: >
A property bag missing optional properties is equivalent to a property bag
with all the optional properties having their default values
features: [Temporal]
---*/
const minimumProperties = {
year: 2021,
month: 10,
day: 28,
};
const allProperties = {
year: 2021,
month: 10,
day: 28,
hour: 0,
minute: 0,
second: 0,
millisecond: 0,
microsecond: 0,
nanosecond: 0,
calendar: "iso8601",
};
const resultWithout = Temporal.PlainDateTime.compare(minimumProperties, minimumProperties);
const resultWith = Temporal.PlainDateTime.compare(allProperties, allProperties);
assert.sameValue(resultWithout, resultWith, "results should be the same with and without optional properties");