summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/mergeFields/basic.js
blob: 2a9d6abacd55e8ef5b954309abf0571d5071dbad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// 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.calendar.prototype.mergefields
description: >
  Temporal.Calendar.prototype.mergeFields will merge own data properties on its
  arguments
info: |
  1. Let calendar be the this value.
  2. Perform ? RequireInternalSlot(calendar, [[InitializedTemporalCalendar]]).
  3. Assert: calendar.[[Identifier]] is "iso8601".
  4. Set fields to ? ToObject(fields).
  5. Set additionalFields to ? ToObject(additionalFields).
  6. Return ? DefaultMergeFields(fields, additionalFields).
features: [Temporal]
includes: [deepEqual.js]
---*/

const cal = new Temporal.Calendar("iso8601");

assert.deepEqual(
  cal.mergeFields({ a: 1, b: 2 }, { c: 3, d: 4 }),
  { a: 1, b: 2, c: 3, d: 4 },
  "properties are merged"
);

assert.deepEqual(
  cal.mergeFields({ a: 1, b: 2 }, { b: 3, c: 4 }),
  { a: 1, b: 3, c: 4 },
  "property in additionalFields should overwrite one in fields"
);

reportCompare(0, 0);