diff --git a/src/protocol/tests/parser_validation.rs b/src/protocol/tests/parser_validation.rs index 741203c921e0b370a23cc3cb94ebd22a5f41cd31..6a414915213d4489b8501aab995fefb260e97779 100644 --- a/src/protocol/tests/parser_validation.rs +++ b/src/protocol/tests/parser_validation.rs @@ -30,4 +30,59 @@ fn test_correct_struct_instance() { Foo bar(int arg) { return Foo{ field: arg }; } " ); + + Tester::new_single_source_expect_ok( + "single field, implicit polymorph", + " + struct Foo{ T field } + int bar(int arg) { + auto thingo = Foo{ field: arg }; + return arg; + } + " + ); + + Tester::new_single_source_expect_ok( + "multiple fields, same explicit polymorph", + " + struct Pair{ T1 first, T2 second } + int bar(int arg) { + auto qux = Pair{ first: arg, second: arg }; + return arg; + } + " + ); + + Tester::new_single_source_expect_ok( + "multiple fields, same implicit polymorph", + " + struct Pair{ T1 first, T2 second } + int bar(int arg) { + auto wup = Pair{ first: arg, second: arg }; + return arg; + } + " + ); + + Tester::new_single_source_expr_ok( + "multiple fields, different explicit polymorph", + " + struct Pair{ T1 first, T2 second } + int bar(int arg1, byte arg2) { + auto shoo = Pair{ first: arg1, second: arg2 }; + return arg1; + } + " + ); + + Tester::new_single_source_expect_ok( + "multiple fields, different implicit polymorph", + " + struct Pair{ T1 first, T2 second } + int bar(int arg1, byte arg2) { + auto shrubbery = Pair{ first: arg1, second: arg2 }; + return arg1; + } + " + ); } \ No newline at end of file