mirror of
https://github.com/tc39/test262.git
synced 2025-05-04 15:00:42 +02:00
* [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)
35 lines
965 B
JavaScript
35 lines
965 B
JavaScript
import Builder from '../Builder.js';
|
|
import * as assert from '../assert.js';
|
|
|
|
{
|
|
const memoryDescription = {initial: 0, maximum: 50};
|
|
const builder = (new Builder())
|
|
.Type().End()
|
|
.Import()
|
|
.Memory("imp", "memory", memoryDescription)
|
|
.Function("imp", "func", {params: [], ret: "void"})
|
|
.End()
|
|
.Function().End()
|
|
.Export()
|
|
.Function("foo")
|
|
.End()
|
|
.Code()
|
|
.Function("foo", {params: [], ret: "i32"})
|
|
.Call(0)
|
|
.CurrentMemory(0)
|
|
.Return()
|
|
.End()
|
|
.End();
|
|
|
|
const bin = builder.WebAssembly().get();
|
|
const module = new WebAssembly.Module(bin);
|
|
const memory = new WebAssembly.Memory(memoryDescription);
|
|
|
|
const func = () => {
|
|
memory.grow(42);
|
|
};
|
|
|
|
const instance = new WebAssembly.Instance(module, {imp: {memory, func}});
|
|
assert.eq(instance.exports.foo(), 42);
|
|
}
|