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
44
45
46
47
48
49
50
51
52
|
// 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: >
non callable argument should throw TypeError Exception
info: |
Array.prototype.flatMap ( mapperFunction [ , thisArg ] )
1. Let O be ? ToObject(this value).
2. Let sourceLen be ? ToLength(? Get(O, "length")).
3. If IsCallable(mapperFunction) is false, throw a TypeError exception.
...
features: [Array.prototype.flatMap, Symbol]
---*/
assert.sameValue(typeof Array.prototype.flatMap, "function");
assert.throws(TypeError, function() {
[].flatMap({});
}, 'non callable argument, object');
assert.throws(TypeError, function() {
[].flatMap(0);
}, 'non callable argument, number');
assert.throws(TypeError, function() {
[].flatMap();
}, 'non callable argument, implict undefined');
assert.throws(TypeError, function() {
[].flatMap(undefined);
}, 'non callable argument, undefined');
assert.throws(TypeError, function() {
[].flatMap(null);
}, 'non callable argument, null');
assert.throws(TypeError, function() {
[].flatMap(false);
}, 'non callable argument, boolean');
assert.throws(TypeError, function() {
[].flatMap('');
}, 'non callable argument, string');
var s = Symbol();
assert.throws(TypeError, function() {
[].flatMap(s);
}, 'non callable argument, symbol');
reportCompare(0, 0);
|