diff options
Diffstat (limited to 'src/test/java')
| -rw-r--r-- | src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java index 87a6dee6..d32f716a 100644 --- a/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java +++ b/src/test/java/org/shedlang/compiler/backends/wasm/WasmCodeGenDefineFunctionTests.java @@ -58,4 +58,31 @@ public class WasmCodeGenDefineFunctionTests { snapshotter.assertSnapshot(objdumpContext(result)); } + + @Test + public void positionalAndNamedParamsAreDefined(Snapshotter snapshotter) throws IOException, InterruptedException { + var instruction = new DefineFunctionInstruction( + "f", + List.of(Instructions.param("param1"), Instructions.param("param2")), + List.of(Instructions.param("paramA"), Instructions.param("paramB")), + FreeVariables.of("a", "b"), + List.of( + Instructions.localLoad("a"), + Instructions.localLoad("param1"), + Instructions.intAdd(), + Instructions.localLoad("paramA"), + Instructions.intAdd(), + Instructions.return_() + ), + Sources.NULL + ); + var context = WasmCodeGenContext.EMPTY + .addShedLocal("b").context() + .addShedLocal("c").context() + .addShedLocal("a").context(); + + var result = WasmCodeGen.generateInstruction(instruction, context); + + snapshotter.assertSnapshot(objdumpContext(result)); + } } |
