summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/mergeFields/arguments-empty-object.js
blob: a5d437c19555b9542119264a4435ec2de43ac36c (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
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// 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.calendar.prototype.mergefields
description: Either argument being an empty object should result in a copy of the other object
includes: [compareArray.js]
features: [Temporal]
---*/

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

let calls = 0;
const yearObserver = {
  get year() {
    calls++;
    return 2021;
  }
};

const result1 = calendar.mergeFields(yearObserver, {});
assert.sameValue(calls, 1, "property copied");
assert.compareArray(Object.keys(result1), ["year"]);
assert.sameValue(result1.year, 2021);
assert.sameValue(calls, 1, "result has a data property");

calls = 0;
const result2 = calendar.mergeFields({}, yearObserver);
assert.sameValue(calls, 1, "property copied");
assert.compareArray(Object.keys(result2), ["year"]);
assert.sameValue(result2.year, 2021);
assert.sameValue(calls, 1, "result has a data property");

reportCompare(0, 0);