mirror of
https://github.com/tc39/test262.git
synced 2025-08-18 16:38:32 +02:00
Many existing tests use a Proxy to test the order of observable operations on a property bag argument that gets passed in to a Temporal API. I am going to write several more tests that do this, as well. This seems like a good thing to put into TemporalHelpers, where it can be implemented consistently so that we don't get discrepancies in which operations are tracked. (For example, we had some tests which didn't test for an ownKeys operation that was supposed to be there.) Updates existing tests to use this helper.
59 lines
1.6 KiB
JavaScript
59 lines
1.6 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.duration.from
|
|
description: Properties on an object passed to from() are accessed in the correct order
|
|
includes: [compareArray.js, temporalHelpers.js]
|
|
features: [Temporal]
|
|
---*/
|
|
|
|
const expected = [
|
|
"get fields.days",
|
|
"get fields.days.valueOf",
|
|
"call fields.days.valueOf",
|
|
"get fields.hours",
|
|
"get fields.hours.valueOf",
|
|
"call fields.hours.valueOf",
|
|
"get fields.microseconds",
|
|
"get fields.microseconds.valueOf",
|
|
"call fields.microseconds.valueOf",
|
|
"get fields.milliseconds",
|
|
"get fields.milliseconds.valueOf",
|
|
"call fields.milliseconds.valueOf",
|
|
"get fields.minutes",
|
|
"get fields.minutes.valueOf",
|
|
"call fields.minutes.valueOf",
|
|
"get fields.months",
|
|
"get fields.months.valueOf",
|
|
"call fields.months.valueOf",
|
|
"get fields.nanoseconds",
|
|
"get fields.nanoseconds.valueOf",
|
|
"call fields.nanoseconds.valueOf",
|
|
"get fields.seconds",
|
|
"get fields.seconds.valueOf",
|
|
"call fields.seconds.valueOf",
|
|
"get fields.weeks",
|
|
"get fields.weeks.valueOf",
|
|
"call fields.weeks.valueOf",
|
|
"get fields.years",
|
|
"get fields.years.valueOf",
|
|
"call fields.years.valueOf",
|
|
];
|
|
const actual = [];
|
|
const fields = TemporalHelpers.propertyBagObserver(actual, {
|
|
years: 1,
|
|
months: 1,
|
|
weeks: 1,
|
|
days: 1,
|
|
hours: 1,
|
|
minutes: 1,
|
|
seconds: 1,
|
|
milliseconds: 1,
|
|
microseconds: 1,
|
|
nanoseconds: 1,
|
|
}, "fields");
|
|
const result = Temporal.Duration.from(fields);
|
|
TemporalHelpers.assertDuration(result, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
|
|
assert.compareArray(actual, expected, "order of operations");
|