Skip to content

Commit

Permalink
test(parser): add some number literal pass cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
rzvxa committed Feb 27, 2024
1 parent bd511c1 commit 912ac85
Show file tree
Hide file tree
Showing 18 changed files with 306 additions and 0 deletions.
24 changes: 24 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-01/ast.snap
Original file line number Diff line number Diff line change
@@ -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,
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
123
26 changes: 26 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-01/tokens.snap
Original file line number Diff line number Diff line change
@@ -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,
),
],
),
]
24 changes: 24 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-02/ast.snap
Original file line number Diff line number Diff line change
@@ -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,
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.23
26 changes: 26 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-02/tokens.snap
Original file line number Diff line number Diff line change
@@ -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,
),
],
),
]
24 changes: 24 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-03/ast.snap
Original file line number Diff line number Diff line change
@@ -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,
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.2e3
26 changes: 26 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-03/tokens.snap
Original file line number Diff line number Diff line change
@@ -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,
),
],
),
]
24 changes: 24 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-04/ast.snap
Original file line number Diff line number Diff line change
@@ -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,
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.2e+3
26 changes: 26 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-04/tokens.snap
Original file line number Diff line number Diff line change
@@ -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,
),
],
),
]
24 changes: 24 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-05/ast.snap
Original file line number Diff line number Diff line change
@@ -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,
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.2e-3
26 changes: 26 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-05/tokens.snap
Original file line number Diff line number Diff line change
@@ -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,
),
],
),
]
24 changes: 24 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-06/ast.snap
Original file line number Diff line number Diff line change
@@ -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,
))),
],
),
))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
123_456
26 changes: 26 additions & 0 deletions crates/fuse-parser/tests/cases/pass/number-literal-06/tokens.snap
Original file line number Diff line number Diff line change
@@ -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,
),
],
),
]

0 comments on commit 912ac85

Please sign in to comment.