1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 esid: sec-%typedarray%.from
5 description: Throw a TypeError exception is mapfn is not callable
7 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
10 3. If mapfn was supplied and mapfn is not undefined, then
11 a. If IsCallable(mapfn) is false, throw a TypeError exception.
13 includes: [testTypedArray.js]
14 features: [Symbol, Symbol.iterator, TypedArray]
19 Object.defineProperty(arrayLike, Symbol.iterator, {
25 assert.throws(TypeError, function() {
26 TypedArray.from(arrayLike, null);
29 assert.throws(TypeError, function() {
30 TypedArray.from(arrayLike, 42);
31 }, "mapfn is a number");
33 assert.throws(TypeError, function() {
34 TypedArray.from(arrayLike, "");
35 }, "mapfn is a string");
37 assert.throws(TypeError, function() {
38 TypedArray.from(arrayLike, {});
39 }, "mapfn is an ordinary object");
41 assert.throws(TypeError, function() {
42 TypedArray.from(arrayLike, []);
43 }, "mapfn is an array");
45 assert.throws(TypeError, function() {
46 TypedArray.from(arrayLike, true);
47 }, "mapfn is a boolean");
50 assert.throws(TypeError, function() {
51 TypedArray.from(arrayLike, s);
52 }, "mapfn is a symbol");
56 "IsCallable(mapfn) check occurs before getting source[@@iterator]"