From 863da17c9dc351f72457ce194853331fa399245c 2022-02-08 15:17:28 From: MH Date: 2022-02-08 15:17:28 Subject: [PATCH] Add some tests for goto/select interaction --- diff --git a/src/protocol/tests/parser_validation.rs b/src/protocol/tests/parser_validation.rs index f6cb386849c640aa79f36a3f3d96477e9161917b..3b8dfcb0602f276740252c11130e9a4e659f525a 100644 --- a/src/protocol/tests/parser_validation.rs +++ b/src/protocol/tests/parser_validation.rs @@ -734,7 +734,35 @@ fn test_incorrect_goto_statement() { .assert_occurs_at(0, "goto exit;").assert_msg_has(0, "not escape the surrounding sync") .assert_occurs_at(1, "exit: u32 v").assert_msg_has(1, "target of the goto") .assert_occurs_at(2, "sync {").assert_msg_has(2, "jump past this"); - }) + }); + + Tester::new_single_source_expect_err( + "goto jumping to select case", + "primitive f(in i) { + sync select { + hello: auto a = get(i) -> i += 1 + } + goto hello; + }" + ).error(|e| { e + .assert_msg_has(0, "expected '->'"); + }); + + Tester::new_single_source_expect_err( + "goto jumping into select case skipping variable", + "primitive f(in i) { + goto waza; + sync select { + auto a = get(i) -> { + waza: a += 1; + } + } + }" + ).error(|e| { e + .assert_num(1) + .assert_msg_has(0, "not find this label") + .assert_occurs_at(0, "waza;"); + }); } #[test]