mirror of
https://github.com/tc39/test262.git
synced 2025-05-04 06:50:32 +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
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
import Builder from '../Builder.js';
|
|
import * as assert from '../assert.js';
|
|
|
|
{
|
|
const memoryDescription = {initial: 0, maximum: 2};
|
|
const builder = (new Builder())
|
|
.Type().End()
|
|
.Import()
|
|
.Memory("imp", "memory", memoryDescription)
|
|
.End()
|
|
.Function().End()
|
|
.Export()
|
|
.Function("foo")
|
|
.Function("bar")
|
|
.End()
|
|
.Code()
|
|
.Function("foo", {params: [], ret: "void"})
|
|
.Unreachable()
|
|
.GrowMemory(0)
|
|
.End()
|
|
.Function("bar", {params: [], ret: "void"})
|
|
.Unreachable()
|
|
.CurrentMemory(0)
|
|
.End()
|
|
.End();
|
|
|
|
const bin = builder.WebAssembly().get();
|
|
const module = new WebAssembly.Module(bin); // Just make sure it parses.
|
|
const memory = new WebAssembly.Memory(memoryDescription);
|
|
const instance = new WebAssembly.Instance(module, {imp: {memory}});
|
|
|
|
assert.throws(() => instance.exports.foo(), WebAssembly.RuntimeError, "Unreachable code should not be executed")
|
|
assert.throws(() => instance.exports.bar(), WebAssembly.RuntimeError, "Unreachable code should not be executed")
|
|
}
|