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)
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 / 43: 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());
|