-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(parser): add more tests for interpolation.
- Loading branch information
Showing
6 changed files
with
230 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
crates/fuse-parser/tests/cases/pass/string-interpolation-04/ast.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
)), | ||
], | ||
))), | ||
], | ||
), | ||
)) |
1 change: 1 addition & 0 deletions
1
crates/fuse-parser/tests/cases/pass/string-interpolation-04/case.fuse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"Hello, ${true}, World" |
81 changes: 81 additions & 0 deletions
81
crates/fuse-parser/tests/cases/pass/string-interpolation-04/tokens.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [], | ||
), | ||
] |
33 changes: 33 additions & 0 deletions
33
crates/fuse-parser/tests/cases/pass/string-interpolation-05/ast.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
)), | ||
], | ||
))), | ||
], | ||
), | ||
)) |
1 change: 1 addition & 0 deletions
1
crates/fuse-parser/tests/cases/pass/string-interpolation-05/case.fuse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"Hello, ${false}, World" |
81 changes: 81 additions & 0 deletions
81
crates/fuse-parser/tests/cases/pass/string-interpolation-05/tokens.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: [], | ||
), | ||
] |