1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
// |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.plaindatetime.prototype.with
description: >
with() should throw a TypeError if mergeFields() returns a primitive,
without passing the value on to any other calendar methods
includes: [compareArray.js, temporalHelpers.js]
features: [BigInt, Symbol, Temporal]
---*/
[undefined, null, true, 3.14159, "bad value", Symbol("no"), 7n].forEach((primitive) => {
const calendar = TemporalHelpers.calendarMergeFieldsReturnsPrimitive(primitive);
const instance = new Temporal.PlainDateTime(2000, 5, 2, 15, 30, 45, 987, 654, 321, calendar);
assert.throws(TypeError, () => instance.with({ year: 2005 }), "bad return from mergeFields() throws");
assert.sameValue(calendar.dateFromFieldsCallCount, 0, "dateFromFields() never called");
});
reportCompare(0, 0);
|