diff --git a/src/protocol/tests/parser_validation.rs b/src/protocol/tests/parser_validation.rs index 863a9b294fd694e58c142ac58e70bc296ebfbd55..1294724006b3c63165ccee5466b58d3b7f037468 100644 --- a/src/protocol/tests/parser_validation.rs +++ b/src/protocol/tests/parser_validation.rs @@ -352,6 +352,71 @@ fn test_incorrect_union_instance() { }); } +#[test] +fn test_correct_tuple_members() { + // Tuples with zero members + Tester::new_single_source_expect_ok( + "single zero-tuple", + "struct Foo{ () bar }" + ).for_struct("Foo", |s| { s + .for_field("bar", |f| { f.assert_parser_type("()"); }) + .assert_size_alignment("Foo", 0, 1); + }); + + Tester::new_single_source_expect_ok( + "triple zero-tuple", + "struct Foo{ () bar, () baz, () qux }" + ).for_struct("Foo", |s| { s + .assert_size_alignment("Foo", 0, 1); + }); + + // Tuples with one member (which are elided, because due to ambiguity + // between a one-tuple literal and a parenthesized expression, we're not + // going to be able to construct one-tuples). + Tester::new_single_source_expect_ok( + "single elided one-tuple", + "struct Foo{ (u32) bar }" + ).for_struct("Foo", |s| { s + .for_field("bar", |f| { f.assert_parser_type("u32"); }) + .assert_size_alignment("Foo", 4, 4); + }); + + Tester::new_single_source_expect_ok( + "triple elided one-tuple", + "struct Foo{ (u8) bar, (u16) baz, (u32) qux }" + ).for_struct("Foo", |s| { s + .assert_size_alignment("Foo", 8, 4); + }); + + // Tuples with three members + Tester::new_single_source_expect_ok( + "single three-tuple", + "struct Foo{ (u8, u16, u32) bar }" + ).for_struct("Foo", |s| { s + .for_field("bar", |f| { f.assert_parser_type("(u8,u16,u32)"); }) + .assert_size_alignment("Foo", 8, 4); + }); + + Tester::new_single_source_expect_ok( + "double three-tuple", + "struct Foo{ (u8,u16,u32,) bar, (s8,s16,s32,) baz }" + ).for_struct("Foo", |s| { s + .for_field("bar", |f| { f.assert_parser_type("(u8,u16,u32)"); }) + .for_field("baz", |f| { f.assert_parser_type("(s8,s16,s32)"); }) + .assert_size_alignment("Foo", 16, 4); + }); +} + +#[test] +fn test_correct_tuple_polymorph_args() { + todo!("write"); +} + +#[test] +fn test_incorrect_tuple_polymorph_args() { + todo!("write"); +} + #[test] fn test_polymorph_array_types() { Tester::new_single_source_expect_ok(