authorgravatar for lachlan@lakebythewoods.xyzLachlan Easton <lachlan@lakebythewoods.xyz> 2020-09-11 13:02:06+10:00
committergravatar for lachlan@lakebythewoods.xyzLachlan Easton <lachlan@lakebythewoods.xyz> 2020-09-18 20:34:00+10:00
logea6181aaf6c3e22ced8b8ac202c5fc93a8e90674
tree1bbc5196ea1acc1726f50fe300a94e0524c99ecb
parent601331833a148ff3a1ab5cb4bba8bc63f4850e13

zig fmt: Add test for nesting if expressions


1 files changed, 37 insertions(+), 0 deletions(-)

lib/std/zig/parser_test.zig+37
...@@ -3392,6 +3392,43 @@ test "zig fmt: Indent comma correctly after multiline string literals in arg lis...@@ -3392,6 +3392,43 @@ test "zig fmt: Indent comma correctly after multiline string literals in arg lis
3392 );3392 );
3393}3393}
33943394
3395test "zig fmt: Control flow statement as body of blockless if" {
3396 try testCanonical(
3397 \\pub fn main() void {
3398 \\ const zoom_node = if (focused_node == layout_first)
3399 \\ if (it.next()) {
3400 \\ if (!node.view.pending.float and !node.view.pending.fullscreen) break node;
3401 \\ } else null
3402 \\ else
3403 \\ focused_node;
3404 \\
3405 \\ const zoom_node = if (focused_node == layout_first) while (it.next()) |node| {
3406 \\ if (!node.view.pending.float and !node.view.pending.fullscreen) break node;
3407 \\ } else null else
3408 \\ focused_node;
3409 \\
3410 \\ const zoom_node = if (focused_node == layout_first)
3411 \\ if (it.next()) {
3412 \\ if (!node.view.pending.float and !node.view.pending.fullscreen) break node;
3413 \\ } else null;
3414 \\
3415 \\ const zoom_node = if (focused_node == layout_first) while (it.next()) |node| {
3416 \\ if (!node.view.pending.float and !node.view.pending.fullscreen) break node;
3417 \\ };
3418 \\
3419 \\ const zoom_node = if (focused_node == layout_first) for (nodes) |node| {
3420 \\ break node;
3421 \\ };
3422 \\
3423 \\ const zoom_node = if (focused_node == layout_first) switch (nodes) {
3424 \\ 0 => 0,
3425 \\ } else
3426 \\ focused_node;
3427 \\}
3428 \\
3429 );
3430}
3431
3395const std = @import("std");3432const std = @import("std");
3396const mem = std.mem;3433const mem = std.mem;
3397const warn = std.debug.warn;3434const warn = std.debug.warn;