blob: ea2e6bd4a227aaf93427638b3ccc78349360fb95 [file] [log] [blame]
keith_miller@apple.com470fd132016-12-22 01:06:20 +00001import * as assert from '../assert.js';
2import Builder from '../Builder.js';
3
4const builder = (new Builder())
5 .Type().End()
6 .Function().End()
7 .Export()
8 .Function("br1")
9 .Function("br0")
10 .End()
11 .Code()
12 .Function("br1", { params: [], ret: "i32" })
keith_miller@apple.comc71449d2016-12-22 22:19:42 +000013 .Block("i32", b => {
keith_miller@apple.com470fd132016-12-22 01:06:20 +000014 return b.I32Const(0)
15 .I32Const(1)
16 .BrIf(1)
17 })
keith_miller@apple.com470fd132016-12-22 01:06:20 +000018 .End()
19
20 .Function("br0", { params: [], ret: "i32" })
21 .I32Const(0)
22 .I32Const(1)
23 .BrIf(0)
24 .End()
25
26 .End();
27
28const bin = builder.WebAssembly().get();
29const module = new WebAssembly.Module(bin);
30const instance = new WebAssembly.Instance(module);
31assert.eq(instance.exports.br1(), 0)
32assert.eq(instance.exports.br0(), 0)