blob: 8ff696b263ccfeee6c29455d494d30bcfb50c8b1 [file] [log] [blame]
import * as assert from '../assert.js'
import { instantiate } from '../wabt-wrapper.js';
async function test() {
{
const instance = await instantiate(`
(func (export "foo") (param i32) (result i32)
(local.get 0)
(block
(local.set 0 (i32.const 0xbbadbeef))))
`);
assert.eq(instance.exports.foo(3), 3);
}
{
const instance = await instantiate(`
(func $const (result i32)
(i32.const 42)
)
(func (export "foo") (param i32) (result i32 i32)
(call $const)
(local.get 0)
(block (param i32) (result i32)
))
`);
assert.eq(instance.exports.foo(3), [42, 3]);
}
{
const instance = await instantiate(`
(func (export "foo") (param i32) (result i32)
(local.get 0)
(if (local.get 0)
(then (local.set 0 (i32.const 42)))
(else (local.set 0 (i32.const 13)))))
`);
assert.eq(instance.exports.foo(1), 1);
assert.eq(instance.exports.foo(0), 0);
}
}
assert.asyncTest(test());