summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Array/prototype/flatMap/this-value-null-undefined-throws.js
blob: f2b52aeb34d227205ea5d626151246a129e6dc83 (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
// Copyright (C) 2018 Shilpi Jain and Michael Ficarra. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-array.prototype.flatMap
description: >
  Throw a TypeError if this value is null or undefined
info: |
  Array.prototype.flatMap ( mapperFunction [ , thisArg ] )

  1. Let O be ? ToObject(this value).
  ...
features: [Array.prototype.flatMap]
---*/

assert.sameValue(typeof Array.prototype.flatMap, 'function');

var mapperFn = function() {};

assert.throws(TypeError, function() {
  [].flatMap.call(null, mapperFn);
}, 'null value');

assert.throws(TypeError, function() {
  [].flatMap.call(undefined, mapperFn);
}, 'undefined');

reportCompare(0, 0);