test262/test/built-ins/Temporal/PlainDateTime/from/read-time-fields-before-datefromfields.js
Philip Chimento 77a34cf93f Add Temporal tests
This copies over the tests that previously existed in the
tc39/proposal-temporal repository.

For context, see thread starting at:
https://github.com/tc39/test262/issues/3002#issuecomment-926234480

In service of https://github.com/tc39/test262/issues/3002
2021-10-01 14:30:12 -04:00

28 lines
1.3 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Copyright (C) 2021 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.plaindatetime.from
description: The time fields are read from the object before being passed to dateFromFields().
info: |
sec-temporal.plaindatetime.from step 3:
3. Return ? ToTemporalDateTime(_item_, _options_).
sec-temporal-totemporaldatetime step 2.e:
e. Let _result_ be ? InterpretTemporalDateTimeFields(_calendar_, _fields_, _options_).
sec-temporal-interprettemporaldatetimefields steps 12:
1. Let _timeResult_ be ? ToTemporalTimeRecord(_fields_).
2. Let _temporalDate_ be ? DateFromFields(_calendar_, _fields_, _options_).
includes: [temporalHelpers.js]
features: [Temporal]
---*/
const calendar = TemporalHelpers.calendarMakeInfinityTime();
const datetime = Temporal.PlainDateTime.from({ year: 2000, month: 5, day: 2, hour: 12, minute: 34, second: 56, millisecond: 987, microsecond: 654, nanosecond: 321, calendar });
assert.sameValue(datetime.hour, 12, "hour value");
assert.sameValue(datetime.minute, 34, "minute value");
assert.sameValue(datetime.second, 56, "second value");
assert.sameValue(datetime.millisecond, 987, "millisecond value");
assert.sameValue(datetime.microsecond, 654, "microsecond value");
assert.sameValue(datetime.nanosecond, 321, "nanosecond value");