test262-automation e9a5a7f918 [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time) (#1620)
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
2018-07-03 15:59:58 -04:00

35 lines
933 B
JavaScript

import Builder from '../Builder.js';
import * as assert from '../assert.js';
const tableDescription = {initial: 1, element: "anyfunc"};
const builder = new Builder()
.Type().End()
.Import()
.Table("imp", "table", tableDescription)
.End()
.Function().End()
.Element()
.Element({tableIndex: 0, offset: 0, functionIndices: [0]})
.End()
.Code()
.Function("foo", {params: ["i32"], ret: "i32"})
.GetLocal(0)
.I32Const(42)
.I32Add()
.Return()
.End()
.End();
const bin = builder.WebAssembly().get();
const module = new WebAssembly.Module(bin);
const table = new WebAssembly.Table(tableDescription);
new WebAssembly.Instance(module, {imp: {table}});
const foo = table.get(0);
const objs = [];
for (let i = 0; i < 10000; i++) {
objs.push(new String("foo"));
if (foo(20) !== 20 + 42)
throw new Error("bad!!!");
}