Skip to content

Commit

Permalink
Test formatting logical operator expressions. (#1272)
Browse files Browse the repository at this point in the history
Test formatting logical operator expressions.

(They were already working but not tested.)

Also format boolean literals.
  • Loading branch information
munificent authored Sep 18, 2023
1 parent 5081f21 commit 3947cb5
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/src/front_end/ast_node_visitor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class AstNodeVisitor extends ThrowingAstVisitor<void>

@override
void visitBooleanLiteral(BooleanLiteral node) {
throw UnimplementedError();
token(node.literal);
}

@override
Expand Down
42 changes: 42 additions & 0 deletions test/expression/logical.stmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
40 columns |
>>> Unsplit mixed.
true||false&&true||false&&false;
<<<
true || false && true || false && false;
>>> If any `&&` operator splits, they all do.
operand1 && operand2 && operand3 && operand4;
<<<
operand1 &&
operand2 &&
operand3 &&
operand4;
>>> If any `||` operator splits, they all do.
operand1 || operand2 || operand3 || operand4;
<<<
operand1 ||
operand2 ||
operand3 ||
operand4;
>>> Prefer to split `||` over `&&`.
operand1 || operand2 && operand3 || operand4;
<<<
operand1 ||
operand2 && operand3 ||
operand4;
>>>
operand1 && operand2 || operand3 && operand4;
<<<
operand1 && operand2 ||
operand3 && operand4;
>>> Mix `&&` with other binary operators.
operand1 > operand2 && operand3 == operand4 && operand5 + operand6;
<<<
operand1 > operand2 &&
operand3 == operand4 &&
operand5 + operand6;
>>> Mix `||` with other binary operators.
operand1 > operand2 || operand3 == operand4 || operand5 + operand6;
<<<
operand1 > operand2 ||
operand3 == operand4 ||
operand5 + operand6;

0 comments on commit 3947cb5

Please sign in to comment.