Skip to content

Commit

Permalink
test(parser): add assignment operator to binarty operator tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Mar 8, 2024
1 parent b6fa98e commit a818c7f
Show file tree
Hide file tree
Showing 21 changed files with 655 additions and 298 deletions.
33 changes: 23 additions & 10 deletions crates/fuse-parser/tests/cases/pass/binary-operator-01/ast.snap
Original file line number Diff line number Diff line change
@@ -1,34 +1,47 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
description: "a and b\n"
description: "x = a and b\n"
expression: parsed.chunk
input_file: crates/fuse-parser/tests/cases/pass/binary-operator-01/case.fuse
---
Some(Chunk(
span: Span(
start: 0,
end: 8,
end: 12,
),
body: Block(
statements: [
Expression(BinaryOperator(BinaryOperator(
kind: LogicalAnd(Span(
kind: Assignment(Span(
start: 2,
end: 5,
end: 3,
)),
lhs: Identifier(Identifier(
span: Span(
start: 0,
end: 1,
),
name: Atom("a"),
name: Atom("x"),
)),
rhs: Identifier(Identifier(
span: Span(
rhs: BinaryOperator(BinaryOperator(
kind: LogicalAnd(Span(
start: 6,
end: 7,
),
name: Atom("b"),
end: 9,
)),
lhs: Identifier(Identifier(
span: Span(
start: 4,
end: 5,
),
name: Atom("a"),
)),
rhs: Identifier(Identifier(
span: Span(
start: 10,
end: 11,
),
name: Atom("b"),
)),
)),
))),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a and b
x = a and b
48 changes: 43 additions & 5 deletions crates/fuse-parser/tests/cases/pass/binary-operator-01/tokens.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
description: "a and b\n"
description: "x = a and b\n"
expression: tokens
input_file: crates/fuse-parser/tests/cases/pass/binary-operator-01/case.fuse
---
Expand Down Expand Up @@ -28,9 +28,28 @@ input_file: crates/fuse-parser/tests/cases/pass/binary-operator-01/case.fuse
token: Token(
span: Span(
start: 2,
end: 3,
),
kind: Eq,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 3,
end: 4,
),
kind: Whitespace,
),
],
),
TokenReference(
token: Token(
span: Span(
start: 4,
end: 5,
),
kind: And,
kind: Identifier,
),
leading_trivia: [],
trailing_trivia: [
Expand All @@ -47,16 +66,35 @@ input_file: crates/fuse-parser/tests/cases/pass/binary-operator-01/case.fuse
token: Token(
span: Span(
start: 6,
end: 7,
end: 9,
),
kind: And,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 9,
end: 10,
),
kind: Whitespace,
),
],
),
TokenReference(
token: Token(
span: Span(
start: 10,
end: 11,
),
kind: Identifier,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 7,
end: 8,
start: 11,
end: 12,
),
kind: Whitespace,
),
Expand Down
61 changes: 37 additions & 24 deletions crates/fuse-parser/tests/cases/pass/binary-operator-02/ast.snap
Original file line number Diff line number Diff line change
@@ -1,48 +1,61 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
description: "a and b and c\n"
description: "x = a and b and c\n"
expression: parsed.chunk
input_file: crates/fuse-parser/tests/cases/pass/binary-operator-02/case.fuse
---
Some(Chunk(
span: Span(
start: 0,
end: 14,
end: 18,
),
body: Block(
statements: [
Expression(BinaryOperator(BinaryOperator(
kind: LogicalAnd(Span(
start: 8,
end: 11,
kind: Assignment(Span(
start: 2,
end: 3,
)),
lhs: BinaryOperator(BinaryOperator(
lhs: Identifier(Identifier(
span: Span(
start: 0,
end: 1,
),
name: Atom("x"),
)),
rhs: BinaryOperator(BinaryOperator(
kind: LogicalAnd(Span(
start: 2,
end: 5,
start: 12,
end: 15,
)),
lhs: Identifier(Identifier(
span: Span(
start: 0,
end: 1,
),
name: Atom("a"),
lhs: BinaryOperator(BinaryOperator(
kind: LogicalAnd(Span(
start: 6,
end: 9,
)),
lhs: Identifier(Identifier(
span: Span(
start: 4,
end: 5,
),
name: Atom("a"),
)),
rhs: Identifier(Identifier(
span: Span(
start: 10,
end: 11,
),
name: Atom("b"),
)),
)),
rhs: Identifier(Identifier(
span: Span(
start: 6,
end: 7,
start: 16,
end: 17,
),
name: Atom("b"),
name: Atom("c"),
)),
)),
rhs: Identifier(Identifier(
span: Span(
start: 12,
end: 13,
),
name: Atom("c"),
)),
))),
],
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
a and b and c
x = a and b and c
60 changes: 49 additions & 11 deletions crates/fuse-parser/tests/cases/pass/binary-operator-02/tokens.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
description: "a and b and c\n"
description: "x = a and b and c\n"
expression: tokens
input_file: crates/fuse-parser/tests/cases/pass/binary-operator-02/case.fuse
---
Expand Down Expand Up @@ -28,9 +28,28 @@ input_file: crates/fuse-parser/tests/cases/pass/binary-operator-02/case.fuse
token: Token(
span: Span(
start: 2,
end: 3,
),
kind: Eq,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 3,
end: 4,
),
kind: Whitespace,
),
],
),
TokenReference(
token: Token(
span: Span(
start: 4,
end: 5,
),
kind: And,
kind: Identifier,
),
leading_trivia: [],
trailing_trivia: [
Expand All @@ -47,16 +66,16 @@ input_file: crates/fuse-parser/tests/cases/pass/binary-operator-02/case.fuse
token: Token(
span: Span(
start: 6,
end: 7,
end: 9,
),
kind: Identifier,
kind: And,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 7,
end: 8,
start: 9,
end: 10,
),
kind: Whitespace,
),
Expand All @@ -65,10 +84,10 @@ input_file: crates/fuse-parser/tests/cases/pass/binary-operator-02/case.fuse
TokenReference(
token: Token(
span: Span(
start: 8,
start: 10,
end: 11,
),
kind: And,
kind: Identifier,
),
leading_trivia: [],
trailing_trivia: [
Expand All @@ -85,16 +104,35 @@ input_file: crates/fuse-parser/tests/cases/pass/binary-operator-02/case.fuse
token: Token(
span: Span(
start: 12,
end: 13,
end: 15,
),
kind: And,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 15,
end: 16,
),
kind: Whitespace,
),
],
),
TokenReference(
token: Token(
span: Span(
start: 16,
end: 17,
),
kind: Identifier,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 13,
end: 14,
start: 17,
end: 18,
),
kind: Whitespace,
),
Expand Down
Loading

0 comments on commit a818c7f

Please sign in to comment.