mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 22:40:28 +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)
41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
import Builder from '../Builder.js'
|
|
import * as assert from '../assert.js'
|
|
|
|
const builder = (new Builder())
|
|
.Type().End()
|
|
.Import()
|
|
.Function("import", "sideEffects", {params: [], ret: "void"})
|
|
.End()
|
|
.Function().End()
|
|
.Export()
|
|
.Function("foo")
|
|
.Function("bar")
|
|
.End()
|
|
.Code()
|
|
.Function("foo", {params: ["i64"], ret: "void"})
|
|
.Call(0)
|
|
.Return()
|
|
.End()
|
|
.Function("bar", {params: [], ret: "i64"})
|
|
.Call(0)
|
|
.I32Const(25)
|
|
.I64ExtendUI32()
|
|
.Return()
|
|
.End()
|
|
.End();
|
|
|
|
const bin = builder.WebAssembly().get();
|
|
const module = new WebAssembly.Module(bin);
|
|
let called = false;
|
|
const imp = {
|
|
import: {
|
|
sideEffects() { called = true; }
|
|
}
|
|
};
|
|
|
|
const instance = new WebAssembly.Instance(module, imp);
|
|
assert.throws(() => instance.exports.foo(20), WebAssembly.RuntimeError, "WebAssembly function with an i64 argument can't be called from JavaScript");
|
|
assert.throws(() => instance.exports.foo({valueOf() { throw new Error("Should not be called!"); }}), WebAssembly.RuntimeError, "WebAssembly function with an i64 argument can't be called from JavaScript");
|
|
assert.throws(() => instance.exports.bar(), WebAssembly.RuntimeError, "WebAssembly function that returns i64 can't be called from JavaScript");
|
|
assert.eq(called, false);
|