diff --git a/src/protocol/tests/parser_validation.rs b/src/protocol/tests/parser_validation.rs index 2d142af3f451423a6e95b4a7ee72d0f1b64cf2c0..00df347f92e8489a54d993c33c798ad7ba02c3ec 100644 --- a/src/protocol/tests/parser_validation.rs +++ b/src/protocol/tests/parser_validation.rs @@ -422,14 +422,45 @@ fn test_correct_tuple_polymorph_args() { " ).for_union("Option", |u| { u .assert_has_monomorph("Option<()>") - .assert_has_monomorph("Option<(u32, u64)>") - .assert_has_monomorph("Option<(Option<(u8,s8)>,Option<(s8,u8)>)>"); + .assert_has_monomorph("Option<(u32,u64)>") + .assert_has_monomorph("Option<(Option<(u8,s8)>,Option<(s8,u8)>)>") + .assert_size_alignment("Option<()>", 1, 1, 0, 0) + .assert_size_alignment("Option<(u32,u64)>", 24, 8, 0, 0) // (u32, u64) becomes size 16, alignment 8. Hence union tag is aligned to 8 + .assert_size_alignment("Option<(Option<(u8,s8)>,Option<(s8,u8)>)>", 7, 1, 0, 0); // inner unions are size 3, alignment 1. Two of those with a tag is size 7 }); } #[test] fn test_incorrect_tuple_polymorph_args() { - todo!("write"); + // Do some mismatching brackets. I don't know what else to test + Tester::new_single_source_expect_err( + "mismatch angle bracket", + " + union Option{ Some(T), None } + func f() -> u32 { + auto a = Option<(u32>)::None; + return 0; + }" + ).error(|e| { e + .assert_num(2) + .assert_msg_has(0, "closing '>'").assert_occurs_at(0, ">)::None") + .assert_msg_has(1, "match this '('").assert_occurs_at(1, "(u32>"); + }); + + Tester::new_single_source_expect_err( + "wrongly placed angle", + " + union O{ S(T), N } + func f() -> u32 { + auto a = O<()>::None; + return 0; + } + " + ).error(|e| { e + .assert_num(1) + .assert_msg_has(0, "expected typename") + .assert_occurs_at(0, "