Skip to content

Commit

Permalink
Add test for module instance command
Browse files Browse the repository at this point in the history
  • Loading branch information
titzer committed Oct 25, 2024
1 parent 882872a commit 9cbddfb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions test/unittest/SpecTestParserTest.v3
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 9cbddfb

Please sign in to comment.