-
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 cases for parsing constants and mutable variables.
- Loading branch information
Showing
6 changed files
with
273 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
crates/fuse-parser/tests/cases/pass/variable-declaration-03/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,43 @@ | ||
--- | ||
source: crates/fuse-parser/tests/cases/mod.rs | ||
expression: parsed.chunk | ||
input_file: crates/fuse-parser/tests/cases/pass/variable-declaration-03/case.fuse | ||
--- | ||
Some(Chunk( | ||
span: Span( | ||
start: 0, | ||
end: 18, | ||
), | ||
body: Block( | ||
statements: [ | ||
VariableDeclaration(VariableDeclaration( | ||
span: Span( | ||
start: 0, | ||
end: 17, | ||
), | ||
kind: Let, | ||
binding: BindingPattern( | ||
kind: Identifier(BindingIdentifier( | ||
span: Span( | ||
start: 4, | ||
end: 11, | ||
), | ||
atom: Atom("num"), | ||
mutable: true, | ||
)), | ||
type_annotation: None, | ||
optional: false, | ||
), | ||
expression: Some(NumberLiteral(NumberLiteral( | ||
span: Span( | ||
start: 14, | ||
end: 17, | ||
), | ||
raw: Atom("123"), | ||
value: 123.0, | ||
kind: Decimal, | ||
))), | ||
)), | ||
], | ||
), | ||
)) |
1 change: 1 addition & 0 deletions
1
crates/fuse-parser/tests/cases/pass/variable-declaration-03/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 @@ | ||
let mut num = 123 |
102 changes: 102 additions & 0 deletions
102
crates/fuse-parser/tests/cases/pass/variable-declaration-03/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,102 @@ | ||
--- | ||
source: crates/fuse-parser/tests/cases/mod.rs | ||
expression: tokens | ||
input_file: crates/fuse-parser/tests/cases/pass/variable-declaration-03/case.fuse | ||
--- | ||
[ | ||
TokenReference( | ||
token: Token( | ||
span: Span( | ||
start: 0, | ||
end: 3, | ||
), | ||
kind: Let, | ||
), | ||
leading_trivia: [], | ||
trailing_trivia: [ | ||
Token( | ||
span: Span( | ||
start: 3, | ||
end: 4, | ||
), | ||
kind: Whitespace, | ||
), | ||
], | ||
), | ||
TokenReference( | ||
token: Token( | ||
span: Span( | ||
start: 4, | ||
end: 7, | ||
), | ||
kind: Mut, | ||
), | ||
leading_trivia: [], | ||
trailing_trivia: [ | ||
Token( | ||
span: Span( | ||
start: 7, | ||
end: 8, | ||
), | ||
kind: Whitespace, | ||
), | ||
], | ||
), | ||
TokenReference( | ||
token: Token( | ||
span: Span( | ||
start: 8, | ||
end: 11, | ||
), | ||
kind: Identifier, | ||
), | ||
leading_trivia: [], | ||
trailing_trivia: [ | ||
Token( | ||
span: Span( | ||
start: 11, | ||
end: 12, | ||
), | ||
kind: Whitespace, | ||
), | ||
], | ||
), | ||
TokenReference( | ||
token: Token( | ||
span: Span( | ||
start: 12, | ||
end: 13, | ||
), | ||
kind: Eq, | ||
), | ||
leading_trivia: [], | ||
trailing_trivia: [ | ||
Token( | ||
span: Span( | ||
start: 13, | ||
end: 14, | ||
), | ||
kind: Whitespace, | ||
), | ||
], | ||
), | ||
TokenReference( | ||
token: Token( | ||
span: Span( | ||
start: 14, | ||
end: 17, | ||
), | ||
kind: NumberLiteral, | ||
), | ||
leading_trivia: [], | ||
trailing_trivia: [ | ||
Token( | ||
span: Span( | ||
start: 17, | ||
end: 18, | ||
), | ||
kind: Whitespace, | ||
), | ||
], | ||
), | ||
] |
43 changes: 43 additions & 0 deletions
43
crates/fuse-parser/tests/cases/pass/variable-declaration-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,43 @@ | ||
--- | ||
source: crates/fuse-parser/tests/cases/mod.rs | ||
expression: parsed.chunk | ||
input_file: crates/fuse-parser/tests/cases/pass/variable-declaration-04/case.fuse | ||
--- | ||
Some(Chunk( | ||
span: Span( | ||
start: 0, | ||
end: 16, | ||
), | ||
body: Block( | ||
statements: [ | ||
VariableDeclaration(VariableDeclaration( | ||
span: Span( | ||
start: 0, | ||
end: 15, | ||
), | ||
kind: Const, | ||
binding: BindingPattern( | ||
kind: Identifier(BindingIdentifier( | ||
span: Span( | ||
start: 6, | ||
end: 8, | ||
), | ||
atom: Atom("PI"), | ||
mutable: false, | ||
)), | ||
type_annotation: None, | ||
optional: false, | ||
), | ||
expression: Some(NumberLiteral(NumberLiteral( | ||
span: Span( | ||
start: 11, | ||
end: 15, | ||
), | ||
raw: Atom("3.14"), | ||
value: 3.14, | ||
kind: Float, | ||
))), | ||
)), | ||
], | ||
), | ||
)) |
1 change: 1 addition & 0 deletions
1
crates/fuse-parser/tests/cases/pass/variable-declaration-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 @@ | ||
const PI = 3.14 |
83 changes: 83 additions & 0 deletions
83
crates/fuse-parser/tests/cases/pass/variable-declaration-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,83 @@ | ||
--- | ||
source: crates/fuse-parser/tests/cases/mod.rs | ||
expression: tokens | ||
input_file: crates/fuse-parser/tests/cases/pass/variable-declaration-04/case.fuse | ||
--- | ||
[ | ||
TokenReference( | ||
token: Token( | ||
span: Span( | ||
start: 0, | ||
end: 5, | ||
), | ||
kind: Const, | ||
), | ||
leading_trivia: [], | ||
trailing_trivia: [ | ||
Token( | ||
span: Span( | ||
start: 5, | ||
end: 6, | ||
), | ||
kind: Whitespace, | ||
), | ||
], | ||
), | ||
TokenReference( | ||
token: Token( | ||
span: Span( | ||
start: 6, | ||
end: 8, | ||
), | ||
kind: Identifier, | ||
), | ||
leading_trivia: [], | ||
trailing_trivia: [ | ||
Token( | ||
span: Span( | ||
start: 8, | ||
end: 9, | ||
), | ||
kind: Whitespace, | ||
), | ||
], | ||
), | ||
TokenReference( | ||
token: Token( | ||
span: Span( | ||
start: 9, | ||
end: 10, | ||
), | ||
kind: Eq, | ||
), | ||
leading_trivia: [], | ||
trailing_trivia: [ | ||
Token( | ||
span: Span( | ||
start: 10, | ||
end: 11, | ||
), | ||
kind: Whitespace, | ||
), | ||
], | ||
), | ||
TokenReference( | ||
token: Token( | ||
span: Span( | ||
start: 11, | ||
end: 15, | ||
), | ||
kind: NumberLiteral, | ||
), | ||
leading_trivia: [], | ||
trailing_trivia: [ | ||
Token( | ||
span: Span( | ||
start: 15, | ||
end: 16, | ||
), | ||
kind: Whitespace, | ||
), | ||
], | ||
), | ||
] |