summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Temporal/Calendar/prototype/dateFromFields/throw-type-error-from-GetOptionsObject.js
blob: 53393dae1e7d94bba8670653beb21946ea424084 (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
// |reftest| skip-if(!this.hasOwnProperty('Temporal')) -- Temporal is not enabled unconditionally
// Copyright (C) 2021 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-temporal.calendar.prototype.datefromfields
description: Temporal.Calendar.prototype.dateFromFields should throw TypeError from GetOptionsObject.
info: |
  4. If Type(fields) is not Object, throw a TypeError exception.
features: [BigInt, Symbol, Temporal, arrow-function]
---*/
let cal = new Temporal.Calendar('iso8601');

let fields = {
  year: 2021,
  month: 7,
  day: 20
};

let notObjectList = [null, 'string', Symbol('efg'), true, false, Infinity, NaN, 123, 456n];

notObjectList.forEach(function(options) {
  assert.throws(
    TypeError,
    () => cal.dateFromFields(fields, options),
    'cal.dateFromFields(fields, options) throws a TypeError exception'
  );
});

reportCompare(0, 0);