diff --git a/crates/fuse-parser/tests/cases/pass/variable-declaration-03/ast.snap b/crates/fuse-parser/tests/cases/pass/variable-declaration-03/ast.snap new file mode 100644 index 0000000..ca51d42 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/variable-declaration-03/ast.snap @@ -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, + ))), + )), + ], + ), +)) diff --git a/crates/fuse-parser/tests/cases/pass/variable-declaration-03/case.fuse b/crates/fuse-parser/tests/cases/pass/variable-declaration-03/case.fuse new file mode 100644 index 0000000..f380e0c --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/variable-declaration-03/case.fuse @@ -0,0 +1 @@ +let mut num = 123 diff --git a/crates/fuse-parser/tests/cases/pass/variable-declaration-03/tokens.snap b/crates/fuse-parser/tests/cases/pass/variable-declaration-03/tokens.snap new file mode 100644 index 0000000..014ed18 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/variable-declaration-03/tokens.snap @@ -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, + ), + ], + ), +] diff --git a/crates/fuse-parser/tests/cases/pass/variable-declaration-04/ast.snap b/crates/fuse-parser/tests/cases/pass/variable-declaration-04/ast.snap new file mode 100644 index 0000000..93f509e --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/variable-declaration-04/ast.snap @@ -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, + ))), + )), + ], + ), +)) diff --git a/crates/fuse-parser/tests/cases/pass/variable-declaration-04/case.fuse b/crates/fuse-parser/tests/cases/pass/variable-declaration-04/case.fuse new file mode 100644 index 0000000..85fd632 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/variable-declaration-04/case.fuse @@ -0,0 +1 @@ +const PI = 3.14 diff --git a/crates/fuse-parser/tests/cases/pass/variable-declaration-04/tokens.snap b/crates/fuse-parser/tests/cases/pass/variable-declaration-04/tokens.snap new file mode 100644 index 0000000..b1985c4 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/variable-declaration-04/tokens.snap @@ -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, + ), + ], + ), +]