aboutsummaryrefslogtreecommitdiff
path: root/test/run_tests.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2016-04-09 16:41:17 -0700
committerAndrew Kelley <superjoe30@gmail.com>2016-04-09 16:41:17 -0700
commit21eca6478f80f871f839b20044869cead55582a5 (patch)
treee638b655a8873ec255cc66493ed7cc6778a91c39 /test/run_tests.cpp
parentfdf6a184615abab3314664b940ea18bc44de4546 (diff)
downloadzig-21eca6478f80f871f839b20044869cead55582a5.tar.gz
zig-21eca6478f80f871f839b20044869cead55582a5.zip
re-introduce goto
see #44
Diffstat (limited to 'test/run_tests.cpp')
-rw-r--r--test/run_tests.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/test/run_tests.cpp b/test/run_tests.cpp
index 0ff7385d94..431452a23c 100644
--- a/test/run_tests.cpp
+++ b/test/run_tests.cpp
@@ -1788,6 +1788,28 @@ fn test1(a: i32, b: i32) -> i32 {
return foo(a)(b);
}
)SOURCE", 1, ".tmp_source.zig:4:16: error: unable to resolve constant expression");
+
+ add_compile_fail_case("goto jumping into block", R"SOURCE(
+fn f() {
+ {
+a_label:
+ }
+ goto a_label;
+}
+ )SOURCE", 2,
+ ".tmp_source.zig:4:1: error: label 'a_label' defined but not used",
+ ".tmp_source.zig:6:5: error: no label in scope named 'a_label'");
+
+ add_compile_fail_case("goto jumping past a defer", R"SOURCE(
+fn f(b: bool) {
+ if (b) goto label;
+ defer derp();
+label:
+}
+fn derp(){}
+ )SOURCE", 2,
+ ".tmp_source.zig:3:12: error: no label in scope named 'label'",
+ ".tmp_source.zig:5:1: error: label 'label' defined but not used");
}
//////////////////////////////////////////////////////////////////////////////