Skip to content

Commit

Permalink
test(parser): add a more complex if expression.
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Mar 7, 2024
1 parent 65f82a8 commit a436b6b
Show file tree
Hide file tree
Showing 3 changed files with 507 additions and 0 deletions.
132 changes: 132 additions & 0 deletions crates/fuse-parser/tests/cases/pass/if-expression-04/ast.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
expression: parsed.chunk
input_file: crates/fuse-parser/tests/cases/pass/if-expression-04/case.fuse
---
Some(Chunk(
span: Span(
start: 0,
end: 71,
),
body: Block(
statements: [
Expression(If(If(
span: Span(
start: 0,
end: 70,
),
cond: BinaryOperator(BinaryOperator(
kind: LogicalOr(Span(
start: 5,
end: 7,
)),
lhs: Identifier(Identifier(
span: Span(
start: 3,
end: 4,
),
name: Atom("x"),
)),
rhs: BinaryOperator(BinaryOperator(
kind: LogicalAnd(Span(
start: 10,
end: 13,
)),
lhs: Identifier(Identifier(
span: Span(
start: 8,
end: 9,
),
name: Atom("y"),
)),
rhs: Identifier(Identifier(
span: Span(
start: 14,
end: 15,
),
name: Atom("z"),
)),
)),
)),
body: Block(
statements: [
Expression(NumberLiteral(NumberLiteral(
span: Span(
start: 23,
end: 26,
),
raw: Atom("123"),
value: 123.0,
kind: Decimal,
))),
],
),
else: Some(If(If(
span: Span(
start: 27,
end: 70,
),
cond: BinaryOperator(BinaryOperator(
kind: LogicalOr(Span(
start: 42,
end: 44,
)),
lhs: BinaryOperator(BinaryOperator(
kind: LogicalAnd(Span(
start: 36,
end: 39,
)),
lhs: Identifier(Identifier(
span: Span(
start: 34,
end: 35,
),
name: Atom("x"),
)),
rhs: Identifier(Identifier(
span: Span(
start: 40,
end: 41,
),
name: Atom("y"),
)),
)),
rhs: Identifier(Identifier(
span: Span(
start: 45,
end: 46,
),
name: Atom("z"),
)),
)),
body: Block(
statements: [
Expression(NumberLiteral(NumberLiteral(
span: Span(
start: 54,
end: 57,
),
raw: Atom("321"),
value: 321.0,
kind: Decimal,
))),
],
),
else: Some(Block(Block(
statements: [
Expression(NumberLiteral(NumberLiteral(
span: Span(
start: 65,
end: 66,
),
raw: Atom("0"),
value: 0.0,
kind: Decimal,
))),
],
))),
))),
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
if x or y and z then
123
elseif x and y or z then
321
else
0
end
Loading

0 comments on commit a436b6b

Please sign in to comment.