mirror of
https://github.com/tc39/test262.git
synced 2025-05-04 06:50:32 +02:00
* [javascriptcore-test262-automation] Changes from https://github.com/webkit/webkit.git at sha 8a25978f29 on Tue Aug 28 2018 18:16:05 GMT+0000 (Coordinated Universal Time) * [javascriptcore-test262-automation] Updated curation log with latest revision sha's from export and changed files. sourceRevisionAtLastExport: 8a25978f29 targetRevisionAtLastExport: 70dc33467
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
import * as assert from '../assert.js';
|
|
import Builder from '../Builder.js';
|
|
|
|
(function StartNamedFunction() {
|
|
const b = (new Builder())
|
|
.Type().End()
|
|
.Import()
|
|
.Function("imp", "func", { params: ["i32"] })
|
|
.End()
|
|
.Function().End()
|
|
.Start("foo").End()
|
|
.Code()
|
|
.Function("foo", { params: [] })
|
|
.I32Const(42)
|
|
.Call(0) // Calls func(42).
|
|
.End()
|
|
.End();
|
|
const bin = b.WebAssembly().get();
|
|
const module = new WebAssembly.Module(bin);
|
|
let value = 0;
|
|
const setter = v => value = v;
|
|
const instance = new WebAssembly.Instance(module, { imp: { func: setter } });
|
|
assert.eq(value, 42);
|
|
})();
|
|
|
|
(function InvalidStartFunctionIndex() {
|
|
const b = (new Builder())
|
|
.setChecked(false)
|
|
.Type().End()
|
|
.Function().End()
|
|
.Start(0).End() // Invalid index.
|
|
.Code().End();
|
|
const bin = b.WebAssembly().get();
|
|
assert.throws(() => new WebAssembly.Module(bin), Error, `WebAssembly.Module doesn't parse at byte 17: Start index 0 exceeds function index space 0 (evaluating 'new WebAssembly.Module(bin)')`);
|
|
})();
|