From 912ac85adcdc896d0de1b8cddaeffb3cfac795aa Mon Sep 17 00:00:00 2001 From: rzvxa Date: Tue, 27 Feb 2024 21:01:14 +0330 Subject: [PATCH] test(parser): add some number literal pass cases. --- .../cases/pass/number-literal-01/ast.snap | 24 +++++++++++++++++ .../cases/pass/number-literal-01/case.fuse | 1 + .../cases/pass/number-literal-01/tokens.snap | 26 +++++++++++++++++++ .../cases/pass/number-literal-02/ast.snap | 24 +++++++++++++++++ .../cases/pass/number-literal-02/case.fuse | 1 + .../cases/pass/number-literal-02/tokens.snap | 26 +++++++++++++++++++ .../cases/pass/number-literal-03/ast.snap | 24 +++++++++++++++++ .../cases/pass/number-literal-03/case.fuse | 1 + .../cases/pass/number-literal-03/tokens.snap | 26 +++++++++++++++++++ .../cases/pass/number-literal-04/ast.snap | 24 +++++++++++++++++ .../cases/pass/number-literal-04/case.fuse | 1 + .../cases/pass/number-literal-04/tokens.snap | 26 +++++++++++++++++++ .../cases/pass/number-literal-05/ast.snap | 24 +++++++++++++++++ .../cases/pass/number-literal-05/case.fuse | 1 + .../cases/pass/number-literal-05/tokens.snap | 26 +++++++++++++++++++ .../cases/pass/number-literal-06/ast.snap | 24 +++++++++++++++++ .../cases/pass/number-literal-06/case.fuse | 1 + .../cases/pass/number-literal-06/tokens.snap | 26 +++++++++++++++++++ 18 files changed, 306 insertions(+) create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-01/ast.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-01/case.fuse create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-01/tokens.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-02/ast.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-02/case.fuse create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-02/tokens.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-03/ast.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-03/case.fuse create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-03/tokens.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-04/ast.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-04/case.fuse create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-04/tokens.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-05/ast.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-05/case.fuse create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-05/tokens.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-06/ast.snap create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-06/case.fuse create mode 100644 crates/fuse-parser/tests/cases/pass/number-literal-06/tokens.snap diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-01/ast.snap b/crates/fuse-parser/tests/cases/pass/number-literal-01/ast.snap new file mode 100644 index 0000000..aa68835 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-01/ast.snap @@ -0,0 +1,24 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: parsed.chunk +input_file: crates/fuse-parser/tests/cases/pass/number-literal-01/case.fuse +--- +Some(Chunk( + span: Span( + start: 0, + end: 4, + ), + body: Block( + statements: [ + Expression(NumberLiteral(NumberLiteral( + span: Span( + start: 0, + end: 3, + ), + raw: Atom("123"), + value: 123.0, + kind: Decimal, + ))), + ], + ), +)) diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-01/case.fuse b/crates/fuse-parser/tests/cases/pass/number-literal-01/case.fuse new file mode 100644 index 0000000..190a180 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-01/case.fuse @@ -0,0 +1 @@ +123 diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-01/tokens.snap b/crates/fuse-parser/tests/cases/pass/number-literal-01/tokens.snap new file mode 100644 index 0000000..f87c09a --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-01/tokens.snap @@ -0,0 +1,26 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: tokens +input_file: crates/fuse-parser/tests/cases/panic/number-literal-01/case.fuse +--- +[ + TokenReference( + token: Token( + span: Span( + start: 0, + end: 3, + ), + kind: NumberLiteral, + ), + leading_trivia: [], + trailing_trivia: [ + Token( + span: Span( + start: 3, + end: 4, + ), + kind: Whitespace, + ), + ], + ), +] diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-02/ast.snap b/crates/fuse-parser/tests/cases/pass/number-literal-02/ast.snap new file mode 100644 index 0000000..8c52cee --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-02/ast.snap @@ -0,0 +1,24 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: parsed.chunk +input_file: crates/fuse-parser/tests/cases/pass/number-literal-02/case.fuse +--- +Some(Chunk( + span: Span( + start: 0, + end: 5, + ), + body: Block( + statements: [ + Expression(NumberLiteral(NumberLiteral( + span: Span( + start: 0, + end: 4, + ), + raw: Atom("1.23"), + value: 1.23, + kind: Float, + ))), + ], + ), +)) diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-02/case.fuse b/crates/fuse-parser/tests/cases/pass/number-literal-02/case.fuse new file mode 100644 index 0000000..a1b6e17 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-02/case.fuse @@ -0,0 +1 @@ +1.23 diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-02/tokens.snap b/crates/fuse-parser/tests/cases/pass/number-literal-02/tokens.snap new file mode 100644 index 0000000..04a2a35 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-02/tokens.snap @@ -0,0 +1,26 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: tokens +input_file: crates/fuse-parser/tests/cases/pass/number-literal-02/case.fuse +--- +[ + TokenReference( + token: Token( + span: Span( + start: 0, + end: 4, + ), + kind: NumberLiteral, + ), + leading_trivia: [], + trailing_trivia: [ + Token( + span: Span( + start: 4, + end: 5, + ), + kind: Whitespace, + ), + ], + ), +] diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-03/ast.snap b/crates/fuse-parser/tests/cases/pass/number-literal-03/ast.snap new file mode 100644 index 0000000..0ca17cb --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-03/ast.snap @@ -0,0 +1,24 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: parsed.chunk +input_file: crates/fuse-parser/tests/cases/pass/number-literal-03/case.fuse +--- +Some(Chunk( + span: Span( + start: 0, + end: 6, + ), + body: Block( + statements: [ + Expression(NumberLiteral(NumberLiteral( + span: Span( + start: 0, + end: 5, + ), + raw: Atom("1.2e3"), + value: 1200.0, + kind: Float, + ))), + ], + ), +)) diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-03/case.fuse b/crates/fuse-parser/tests/cases/pass/number-literal-03/case.fuse new file mode 100644 index 0000000..0e957c6 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-03/case.fuse @@ -0,0 +1 @@ +1.2e3 diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-03/tokens.snap b/crates/fuse-parser/tests/cases/pass/number-literal-03/tokens.snap new file mode 100644 index 0000000..8a8c1ce --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-03/tokens.snap @@ -0,0 +1,26 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: tokens +input_file: crates/fuse-parser/tests/cases/pass/number-literal-03/case.fuse +--- +[ + TokenReference( + token: Token( + span: Span( + start: 0, + end: 5, + ), + kind: NumberLiteral, + ), + leading_trivia: [], + trailing_trivia: [ + Token( + span: Span( + start: 5, + end: 6, + ), + kind: Whitespace, + ), + ], + ), +] diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-04/ast.snap b/crates/fuse-parser/tests/cases/pass/number-literal-04/ast.snap new file mode 100644 index 0000000..988746a --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-04/ast.snap @@ -0,0 +1,24 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: parsed.chunk +input_file: crates/fuse-parser/tests/cases/pass/number-literal-04/case.fuse +--- +Some(Chunk( + span: Span( + start: 0, + end: 7, + ), + body: Block( + statements: [ + Expression(NumberLiteral(NumberLiteral( + span: Span( + start: 0, + end: 6, + ), + raw: Atom("1.2e+3"), + value: 1200.0, + kind: Float, + ))), + ], + ), +)) diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-04/case.fuse b/crates/fuse-parser/tests/cases/pass/number-literal-04/case.fuse new file mode 100644 index 0000000..3d011c3 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-04/case.fuse @@ -0,0 +1 @@ +1.2e+3 diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-04/tokens.snap b/crates/fuse-parser/tests/cases/pass/number-literal-04/tokens.snap new file mode 100644 index 0000000..3e19547 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-04/tokens.snap @@ -0,0 +1,26 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: tokens +input_file: crates/fuse-parser/tests/cases/pass/number-literal-04/case.fuse +--- +[ + TokenReference( + token: Token( + span: Span( + start: 0, + end: 6, + ), + kind: NumberLiteral, + ), + leading_trivia: [], + trailing_trivia: [ + Token( + span: Span( + start: 6, + end: 7, + ), + kind: Whitespace, + ), + ], + ), +] diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-05/ast.snap b/crates/fuse-parser/tests/cases/pass/number-literal-05/ast.snap new file mode 100644 index 0000000..4942635 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-05/ast.snap @@ -0,0 +1,24 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: parsed.chunk +input_file: crates/fuse-parser/tests/cases/pass/number-literal-05/case.fuse +--- +Some(Chunk( + span: Span( + start: 0, + end: 7, + ), + body: Block( + statements: [ + Expression(NumberLiteral(NumberLiteral( + span: Span( + start: 0, + end: 6, + ), + raw: Atom("1.2e-3"), + value: 0.0012, + kind: Float, + ))), + ], + ), +)) diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-05/case.fuse b/crates/fuse-parser/tests/cases/pass/number-literal-05/case.fuse new file mode 100644 index 0000000..f71f4f0 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-05/case.fuse @@ -0,0 +1 @@ +1.2e-3 diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-05/tokens.snap b/crates/fuse-parser/tests/cases/pass/number-literal-05/tokens.snap new file mode 100644 index 0000000..9c61701 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-05/tokens.snap @@ -0,0 +1,26 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: tokens +input_file: crates/fuse-parser/tests/cases/pass/number-literal-05/case.fuse +--- +[ + TokenReference( + token: Token( + span: Span( + start: 0, + end: 6, + ), + kind: NumberLiteral, + ), + leading_trivia: [], + trailing_trivia: [ + Token( + span: Span( + start: 6, + end: 7, + ), + kind: Whitespace, + ), + ], + ), +] diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-06/ast.snap b/crates/fuse-parser/tests/cases/pass/number-literal-06/ast.snap new file mode 100644 index 0000000..d2924ca --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-06/ast.snap @@ -0,0 +1,24 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: parsed.chunk +input_file: crates/fuse-parser/tests/cases/pass/number-literal-06/case.fuse +--- +Some(Chunk( + span: Span( + start: 0, + end: 8, + ), + body: Block( + statements: [ + Expression(NumberLiteral(NumberLiteral( + span: Span( + start: 0, + end: 7, + ), + raw: Atom("123_456"), + value: 123456.0, + kind: Decimal, + ))), + ], + ), +)) diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-06/case.fuse b/crates/fuse-parser/tests/cases/pass/number-literal-06/case.fuse new file mode 100644 index 0000000..d302f6f --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-06/case.fuse @@ -0,0 +1 @@ +123_456 diff --git a/crates/fuse-parser/tests/cases/pass/number-literal-06/tokens.snap b/crates/fuse-parser/tests/cases/pass/number-literal-06/tokens.snap new file mode 100644 index 0000000..b6410d3 --- /dev/null +++ b/crates/fuse-parser/tests/cases/pass/number-literal-06/tokens.snap @@ -0,0 +1,26 @@ +--- +source: crates/fuse-parser/tests/cases/mod.rs +expression: tokens +input_file: crates/fuse-parser/tests/cases/pass/number-literal-06/case.fuse +--- +[ + TokenReference( + token: Token( + span: Span( + start: 0, + end: 7, + ), + kind: NumberLiteral, + ), + leading_trivia: [], + trailing_trivia: [ + Token( + span: Span( + start: 7, + end: 8, + ), + kind: Whitespace, + ), + ], + ), +]