Skip to content

Commit

Permalink
test(parser): add more tests for interpolation.
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Mar 4, 2024
1 parent 0b95e37 commit 0450e48
Show file tree
Hide file tree
Showing 6 changed files with 230 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
expression: parsed.chunk
input_file: crates/fuse-parser/tests/cases/pass/string-interpolation-04/case.fuse
---
Some(Chunk(
span: Span(
start: 0,
end: 24,
),
body: Block(
statements: [
Expression(StringLiteral(StringLiteral(
span: Span(
start: 0,
end: 24,
),
segments: [
Interpolated(InterpolatedStringSegment(
expression: BooleanLiteral(BooleanLiteral(
span: Span(
start: 10,
end: 14,
),
value: true,
)),
format: Display,
)),
],
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"Hello, ${true}, World"
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
expression: tokens
input_file: crates/fuse-parser/tests/cases/pass/string-interpolation-04/case.fuse
---
[
TokenReference(
token: Token(
span: Span(
start: 0,
end: 10,
),
kind: InterpolatedStringHead,
),
leading_trivia: [],
trailing_trivia: [],
),
TokenReference(
token: Token(
span: Span(
start: 10,
end: 14,
),
kind: True,
),
leading_trivia: [],
trailing_trivia: [],
),
TokenReference(
token: Token(
span: Span(
start: 14,
end: 15,
),
kind: RCurly,
),
leading_trivia: [],
trailing_trivia: [],
),
TokenReference(
token: Token(
span: Span(
start: 15,
end: 16,
),
kind: Undetermined,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 16,
end: 17,
),
kind: Whitespace,
),
],
),
TokenReference(
token: Token(
span: Span(
start: 17,
end: 22,
),
kind: Identifier,
),
leading_trivia: [],
trailing_trivia: [],
),
TokenReference(
token: Token(
span: Span(
start: 22,
end: 24,
),
kind: StringLiteral,
),
leading_trivia: [],
trailing_trivia: [],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
expression: parsed.chunk
input_file: crates/fuse-parser/tests/cases/pass/string-interpolation-05/case.fuse
---
Some(Chunk(
span: Span(
start: 0,
end: 25,
),
body: Block(
statements: [
Expression(StringLiteral(StringLiteral(
span: Span(
start: 0,
end: 25,
),
segments: [
Interpolated(InterpolatedStringSegment(
expression: BooleanLiteral(BooleanLiteral(
span: Span(
start: 10,
end: 15,
),
value: false,
)),
format: Display,
)),
],
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"Hello, ${false}, World"
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
---
source: crates/fuse-parser/tests/cases/mod.rs
expression: tokens
input_file: crates/fuse-parser/tests/cases/pass/string-interpolation-05/case.fuse
---
[
TokenReference(
token: Token(
span: Span(
start: 0,
end: 10,
),
kind: InterpolatedStringHead,
),
leading_trivia: [],
trailing_trivia: [],
),
TokenReference(
token: Token(
span: Span(
start: 10,
end: 15,
),
kind: False,
),
leading_trivia: [],
trailing_trivia: [],
),
TokenReference(
token: Token(
span: Span(
start: 15,
end: 16,
),
kind: RCurly,
),
leading_trivia: [],
trailing_trivia: [],
),
TokenReference(
token: Token(
span: Span(
start: 16,
end: 17,
),
kind: Undetermined,
),
leading_trivia: [],
trailing_trivia: [
Token(
span: Span(
start: 17,
end: 18,
),
kind: Whitespace,
),
],
),
TokenReference(
token: Token(
span: Span(
start: 18,
end: 23,
),
kind: Identifier,
),
leading_trivia: [],
trailing_trivia: [],
),
TokenReference(
token: Token(
span: Span(
start: 23,
end: 25,
),
kind: StringLiteral,
),
leading_trivia: [],
trailing_trivia: [],
),
]

0 comments on commit 0450e48

Please sign in to comment.