Skip to content

Commit

Permalink
test(parser): add case combining unary and binary operator precedence.
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Mar 6, 2024
1 parent 58d576e commit 19a314d
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 0 deletions.
43 changes: 43 additions & 0 deletions crates/fuse-parser/tests/cases/pass/binary-operator-07/ast.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
expression: parsed.chunk
input_file: crates/fuse-parser/tests/cases/pass/binary-operator-07/case.fuse
---
Some(Chunk(
span: Span(
start: 0,
end: 7,
),
body: Block(
statements: [
Expression(BinaryOperator(BinaryOperator(
kind: Multiply(Span(
start: 3,
end: 4,
)),
lhs: UnaryOperator(UnaryOperator(
kind: Minus(Span(
start: 0,
end: 1,
)),
expression: Identifier(Identifier(
span: Span(
start: 1,
end: 2,
),
name: Atom("x"),
)),
)),
rhs: NumberLiteral(NumberLiteral(
span: Span(
start: 5,
end: 6,
),
raw: Atom("2"),
value: 2.0,
kind: Decimal,
)),
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-x * 2
75 changes: 75 additions & 0 deletions crates/fuse-parser/tests/cases/pass/binary-operator-07/tokens.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
expression: tokens
input_file: crates/fuse-parser/tests/cases/pass/binary-operator-07/case.fuse
---
[
TokenReference(
token: Token(
span: Span(
start: 0,
end: 1,
),
kind: Minus,
),
leading_trivia: [],
trailing_trivia: [],
),
TokenReference(
token: Token(
span: Span(
start: 1,
end: 2,
),
kind: Identifier,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 2,
end: 3,
),
kind: Whitespace,
),
],
),
TokenReference(
token: Token(
span: Span(
start: 3,
end: 4,
),
kind: Star,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 4,
end: 5,
),
kind: Whitespace,
),
],
),
TokenReference(
token: Token(
span: Span(
start: 5,
end: 6,
),
kind: NumberLiteral,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 6,
end: 7,
),
kind: Whitespace,
),
],
),
]

0 comments on commit 19a314d

Please sign in to comment.