From 9cbddfb8d39bfb2afe4e4b8a25dcc606b155a352 Mon Sep 17 00:00:00 2001 From: "Ben L. Titzer" Date: Fri, 25 Oct 2024 08:52:40 -0700 Subject: [PATCH] Add test for module instance command --- test/unittest/SpecTestParserTest.v3 | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/test/unittest/SpecTestParserTest.v3 b/test/unittest/SpecTestParserTest.v3 index 3f87868b..3865cf3a 100644 --- a/test/unittest/SpecTestParserTest.v3 +++ b/test/unittest/SpecTestParserTest.v3 @@ -38,6 +38,7 @@ def X_ = void( T("mod_named", test_mod_named), T("moddef", test_moddef), T("moddef_named", test_moddef_named), + T("modinst", test_modinst), T("invoke1", test_invoke1), T("invokex", test_invokex), T("invoke_named", test_invoke_named), @@ -269,6 +270,12 @@ class SpecTestParserTester(t: Tester) { expected_bytes)); assert_cmd(exp, c.cmd); } + def assert_inst(input: string, expected_instname: string, expected_modname: string) { + var c = parseCommand(input); + if (c == null) return t.fail("expected module instance, but got error"); + var exp = StCommand.Module(StModule.Instance(expected_instname, expected_modname)); + assert_cmd(exp, c.cmd); + } def assert_quote(input: string, expected_isdef: bool, expected_varname: string, expected_source: string) { var c = parseCommand(input); if (c == null) return t.fail("expected quote module, but got error"); @@ -942,6 +949,12 @@ def test_moddef_named(t: SpecTestParserTester) { t.assert_quote("(module $__ quote \"(foo)\")", false, "$__", "(foo)"); } +def test_modinst(t: SpecTestParserTester) { + t.assert_inst("(module instance)", null, null); + t.assert_inst("(module instance $az)", "$az", null); + t.assert_inst("(module instance $__ $_f)", "$__", "$_f"); +} + def test_invoke1(t: SpecTestParserTester) { t.assert_invoke("(invoke \"foo\")", null, "foo"); t.assert_invoke("(invoke \"ABCDEG\")", null, "ABCDEG");