summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/mergeFields/arguments-not-object.js
blob: 3355b631d977e3886623a067c194a1bd5df74e61 (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
37
38
39
40
41
42
43
// |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: Non-object arguments are converted with ToObject and merge their [[OwnPropertyKeys]] onto a new object
includes: [compareArray.js]
features: [Temporal]
---*/

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

assert.throws(TypeError, () => calendar.mergeFields(undefined, {}));
assert.throws(TypeError, () => calendar.mergeFields({}, undefined));

assert.throws(TypeError, () => calendar.mergeFields(null, {}));
assert.throws(TypeError, () => calendar.mergeFields({}, null));

const boolResult = calendar.mergeFields(true, false);
assert.compareArray(Object.keys(boolResult), [], "Boolean objects have no own property keys");
assert.sameValue(Object.getPrototypeOf(boolResult), null, "null-prototype object returned");

const numResult = calendar.mergeFields(3, 4);
assert.compareArray(Object.keys(numResult), [], "Number objects have no own property keys");
assert.sameValue(Object.getPrototypeOf(boolResult), null, "null-prototype object returned");

const strResult = calendar.mergeFields("abc", "de");
assert.compareArray(Object.keys(strResult), ["0", "1", "2"], "String objects have integer indices as own property keys");
assert.sameValue(strResult["0"], "d");
assert.sameValue(strResult["1"], "e");
assert.sameValue(strResult["2"], "c");
assert.sameValue(Object.getPrototypeOf(boolResult), null, "null-prototype object returned");

const symResult = calendar.mergeFields(Symbol("foo"), Symbol("bar"));
assert.compareArray(Object.keys(symResult), [], "Symbol objects have no own property keys");
assert.sameValue(Object.getPrototypeOf(symResult), null, "null-prototype object returned");

const bigintResult = calendar.mergeFields(3n, 4n);
assert.compareArray(Object.keys(bigintResult), [], "BigInt objects have no own property keys");
assert.sameValue(Object.getPrototypeOf(bigintResult), null, "null-prototype object returned");

reportCompare(0, 0);