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
61 lines
1.9 KiB
JavaScript
61 lines
1.9 KiB
JavaScript
import * as assert from '../assert.js';
|
|
import Builder from '../Builder.js';
|
|
|
|
assert.isFunction(WebAssembly.compile);
|
|
assert.isFunction(WebAssembly.__proto__.compile);
|
|
assert.eq(WebAssembly.compile.length, 1);
|
|
|
|
async function testPromiseAPI() {
|
|
{
|
|
// Can't declare more than one memory.
|
|
const builder = (new Builder())
|
|
.Type().End()
|
|
.Import().Memory("imp", "memory", {initial: 20}).End()
|
|
.Function().End()
|
|
.Memory().InitialMaxPages(1, 1).End()
|
|
.Export().End()
|
|
.Code()
|
|
.End();
|
|
|
|
try {
|
|
await WebAssembly.compile(builder.WebAssembly().get());
|
|
} catch(e) {
|
|
assert.truthy(e instanceof WebAssembly.CompileError);
|
|
assert.truthy(e.message === "WebAssembly.Module doesn't parse at byte 34: there can at most be one Memory section for now");
|
|
}
|
|
}
|
|
|
|
{
|
|
try {
|
|
await WebAssembly.compile();
|
|
} catch(e) {
|
|
assert.truthy(e instanceof TypeError);
|
|
assert.eq(e.message, "first argument must be an ArrayBufferView or an ArrayBuffer (evaluating 'WebAssembly.compile()')");
|
|
}
|
|
}
|
|
|
|
{
|
|
try {
|
|
await WebAssembly.compile(20);
|
|
} catch(e) {
|
|
assert.truthy(e instanceof TypeError);
|
|
assert.eq(e.message, "first argument must be an ArrayBufferView or an ArrayBuffer (evaluating 'WebAssembly.compile(20)')");
|
|
}
|
|
}
|
|
|
|
{
|
|
const builder = (new Builder())
|
|
.Type().End()
|
|
.Import().Memory("imp", "memory", {initial: 20}).End()
|
|
.Function().End()
|
|
.Export().End()
|
|
.Code()
|
|
.End();
|
|
|
|
let module = await WebAssembly.compile(builder.WebAssembly().get());
|
|
assert.truthy(module instanceof WebAssembly.Module);
|
|
}
|
|
}
|
|
|
|
assert.asyncTest(testPromiseAPI());
|