1 // |reftest| shell-option(--enable-float16array)
2 // Copyright (C) 2016 the V8 project authors. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 esid: sec-%typedarray%.from
6 description: Throw a TypeError exception is mapfn is not callable
8 22.2.2.1 %TypedArray%.from ( source [ , mapfn [ , thisArg ] ] )
11 3. If mapfn was supplied and mapfn is not undefined, then
12 a. If IsCallable(mapfn) is false, throw a TypeError exception.
14 includes: [testTypedArray.js]
15 features: [Symbol, Symbol.iterator, TypedArray]
20 Object.defineProperty(arrayLike, Symbol.iterator, {
26 assert.throws(TypeError, function() {
27 TypedArray.from(arrayLike, null);
30 assert.throws(TypeError, function() {
31 TypedArray.from(arrayLike, 42);
32 }, "mapfn is a number");
34 assert.throws(TypeError, function() {
35 TypedArray.from(arrayLike, "");
36 }, "mapfn is a string");
38 assert.throws(TypeError, function() {
39 TypedArray.from(arrayLike, {});
40 }, "mapfn is an ordinary object");
42 assert.throws(TypeError, function() {
43 TypedArray.from(arrayLike, []);
44 }, "mapfn is an array");
46 assert.throws(TypeError, function() {
47 TypedArray.from(arrayLike, true);
48 }, "mapfn is a boolean");
51 assert.throws(TypeError, function() {
52 TypedArray.from(arrayLike, s);
53 }, "mapfn is a symbol");
57 "IsCallable(mapfn) check occurs before getting source[@@iterator]"