diff options
| author | Lachlan Easton <lachlan@lakebythewoods.xyz> | 2020-09-11 13:02:06 +1000 |
|---|---|---|
| committer | Lachlan Easton <lachlan@lakebythewoods.xyz> | 2020-09-18 20:34:00 +1000 |
| commit | ea6181aaf6c3e22ced8b8ac202c5fc93a8e90674 (patch) | |
| tree | 1bbc5196ea1acc1726f50fe300a94e0524c99ecb /lib/std | |
| parent | 601331833a148ff3a1ab5cb4bba8bc63f4850e13 (diff) | |
| download | zig-ea6181aaf6c3e22ced8b8ac202c5fc93a8e90674.tar.gz zig-ea6181aaf6c3e22ced8b8ac202c5fc93a8e90674.zip | |
zig fmt: Add test for nesting if expressions
Diffstat (limited to 'lib/std')
| -rw-r--r-- | lib/std/zig/parser_test.zig | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index 6b8734c9d4..fe32a371e9 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -3392,6 +3392,43 @@ test "zig fmt: Indent comma correctly after multiline string literals in arg lis ); } +test "zig fmt: Control flow statement as body of blockless if" { + try testCanonical( + \\pub fn main() void { + \\ const zoom_node = if (focused_node == layout_first) + \\ if (it.next()) { + \\ if (!node.view.pending.float and !node.view.pending.fullscreen) break node; + \\ } else null + \\ else + \\ focused_node; + \\ + \\ const zoom_node = if (focused_node == layout_first) while (it.next()) |node| { + \\ if (!node.view.pending.float and !node.view.pending.fullscreen) break node; + \\ } else null else + \\ focused_node; + \\ + \\ const zoom_node = if (focused_node == layout_first) + \\ if (it.next()) { + \\ if (!node.view.pending.float and !node.view.pending.fullscreen) break node; + \\ } else null; + \\ + \\ const zoom_node = if (focused_node == layout_first) while (it.next()) |node| { + \\ if (!node.view.pending.float and !node.view.pending.fullscreen) break node; + \\ }; + \\ + \\ const zoom_node = if (focused_node == layout_first) for (nodes) |node| { + \\ break node; + \\ }; + \\ + \\ const zoom_node = if (focused_node == layout_first) switch (nodes) { + \\ 0 => 0, + \\ } else + \\ focused_node; + \\} + \\ + ); +} + const std = @import("std"); const mem = std.mem; const warn = std.debug.warn; |
