aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/underscore.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-04-29 15:54:04 -0700
committerAndrew Kelley <andrew@ziglang.org>2021-04-29 15:54:04 -0700
commit4307436b9945f814ff5731981df1d19febf3ba0a (patch)
treeefaaec94a41d632d45f255d464d9787eb02c4c9b /test/behavior/underscore.zig
parent5a02c938dafdf2bb11b2350b6ad3161ef93744f0 (diff)
downloadzig-4307436b9945f814ff5731981df1d19febf3ba0a.tar.gz
zig-4307436b9945f814ff5731981df1d19febf3ba0a.zip
move behavior tests from test/stage1/ to test/
And fix test cases to make them pass. This is in preparation for starting to pass behavior tests with self-hosted.
Diffstat (limited to 'test/behavior/underscore.zig')
-rw-r--r--test/behavior/underscore.zig28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/behavior/underscore.zig b/test/behavior/underscore.zig
new file mode 100644
index 0000000000..516d33a4eb
--- /dev/null
+++ b/test/behavior/underscore.zig
@@ -0,0 +1,28 @@
+const std = @import("std");
+const expect = std.testing.expect;
+
+test "ignore lval with underscore" {
+ _ = false;
+}
+
+test "ignore lval with underscore (for loop)" {
+ for ([_]void{}) |_, i| {
+ for ([_]void{}) |_, j| {
+ break;
+ }
+ break;
+ }
+}
+
+test "ignore lval with underscore (while loop)" {
+ while (optionalReturnError()) |_| {
+ while (optionalReturnError()) |_| {
+ break;
+ } else |_| {}
+ break;
+ } else |_| {}
+}
+
+fn optionalReturnError() !?u32 {
+ return error.optionalReturnError;
+}