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
|
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --expose-wasm
load("test/mjsunit/wasm/wasm-module-builder.js");
(function TestFunctionPrototype() {
var builder = new WasmModuleBuilder();
var f = builder.addFunction("nine", kSig_i_v)
.addBody([kExprI32Const, 9])
.exportFunc();
var func = builder.instantiate().exports.nine;
// Check type and existence of prototype
assertEquals('function', typeof func);
assertEquals('function', typeof func.apply);
assertEquals('prototype' in func, false);
assertEquals(String(f.index), func.name);
assertEquals(undefined, func.displayName);
// Check that .apply() works.
assertEquals(9, func.apply([]));
assertEquals(9, func.apply([1]));
assertEquals(9, func.apply([2, 3]));
assertEquals(9, func.apply([6, 7, 9, 9]));
// TODO(titzer): assertEquals(1, func.length);
// Check we don't crash when converting to a string.
print(func.toString());
})();
|