Skip to content

Commit

Permalink
[chore] Add a simple sum function to the corpus
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Sep 9, 2024
1 parent afa3860 commit 5a2d9fc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ public void shouldWorkFactorial() {
assertEquals(120, result.asInt());
}

@Test
public void shouldRunABasicAdd() {
var instance = Instance.builder(loadModule("compiled/add.wat.wasm")).build();
var add = instance.export("add");
var result = add.apply(Value.i32(5), Value.i32(6))[0];
assertEquals(11, result.asInt());
}

@Test
public void shouldSupportBrTable() {
var instance = Instance.builder(loadModule("compiled/br_table.wat.wasm")).build();
Expand Down
Binary file not shown.
6 changes: 6 additions & 0 deletions wasm-corpus/src/main/resources/wat/add.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(module
;; add(a, b) returns a+b
(func $add (export "add") (param $a i32) (param $b i32) (result i32)
(i32.add (local.get $a) (local.get $b))
)
)

0 comments on commit 5a2d9fc

Please sign in to comment.