diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js b/js/src/tests/test262/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js new file mode 100644 index 0000000000..99fa7e30eb --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/flatMap/non-callable-argument-throws.js @@ -0,0 +1,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); |