Skip to content

Commit

Permalink
Split the NumericExpression CST tests
Browse files Browse the repository at this point in the history
Now that we can't reliably expose this parser starting from DSL v2,
let's test individual choices
  • Loading branch information
Xanewok committed Nov 15, 2023
1 parent 05203a5 commit 9246eb0
Show file tree
Hide file tree
Showing 54 changed files with 160 additions and 154 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crates/solidity/outputs/npm/tests/src/tests/cst-cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ test("use cursor", () => {
expectRule(cursor.node(), RuleKind.Expression);
expect(cursor.goToNext()).toBe(true);

expectRule(cursor.node(), RuleKind.NumericExpression);
expectRule(cursor.node(), RuleKind.DecimalNumberExpression);
expect(cursor.goToNext()).toBe(true);

expectRule(cursor.node(), RuleKind.LeadingTrivia);
Expand All @@ -85,7 +85,7 @@ test("use cursor", () => {
expectRule(cursor.node(), RuleKind.Expression);
expect(cursor.goToNext()).toBe(true);

expectRule(cursor.node(), RuleKind.NumericExpression);
expectRule(cursor.node(), RuleKind.DecimalNumberExpression);
expect(cursor.goToNext()).toBe(true);

expectRule(cursor.node(), RuleKind.LeadingTrivia);
Expand Down
4 changes: 2 additions & 2 deletions crates/solidity/outputs/npm/tests/src/tests/cst-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ test("parse token", () => {
const source = "5_286_981";
const language = new Language("0.8.1");

const parseTree = language.parse(ProductionKind.NumericExpression, source).tree();
expectRule(parseTree, RuleKind.NumericExpression);
const parseTree = language.parse(ProductionKind.DecimalNumberExpression, source).tree();
expectRule(parseTree, RuleKind.DecimalNumberExpression);

const children = parseTree.children();
expect(children).toHaveLength(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..7 "10 days"
- DecimalNumberExpression (Rule): # 0..7 "10 days"
- DecimalLiteral (Token): "10" # 0..2
- DaysKeyword (Token): "days" # 3..7
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..9 "123456789"
- DecimalNumberExpression (Rule): # 0..9 "123456789"
- DecimalLiteral (Token): "123456789" # 0..9
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Source: >
Errors: # 1 total
- >
Error: Expected DecimalLiteral or HexLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/decimal_trailing_ident_start/input.sol:1:1]
Error: Expected DecimalLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/DecimalNumberExpression/decimal_trailing_ident_start/input.sol:1:1]
1 │ 1a
│ ─┬─
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..8 "10 ether"
- DecimalNumberExpression (Rule): # 0..8 "10 ether"
- DecimalLiteral (Token): "10" # 0..2
- EtherKeyword (Token): "ether" # 3..8
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..3 "1.2"
- DecimalNumberExpression (Rule): # 0..3 "1.2"
- DecimalLiteral (Token): "1.2" # 0..3
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..2 "1."
- DecimalNumberExpression (Rule): # 0..2 "1."
- DecimalLiteral (Token): "1." # 0..2
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Source: >
Errors: # 1 total
- >
Error: Expected DecimalLiteral or HexLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/float_no_fraction/input.sol:1:1]
Error: Expected DecimalLiteral.
╭─[crates/solidity/testing/snapshots/cst_output/DecimalNumberExpression/float_no_fraction/input.sol:1:1]
1 │ 1.
│ ─┬
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..2 ".2"
- DecimalNumberExpression (Rule): # 0..2 ".2"
- DecimalLiteral (Token): ".2" # 0..2
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..3 "123"
- DecimalNumberExpression (Rule): # 0..3 "123"
- DecimalLiteral (Token): "123" # 0..3
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..3 "1e2"
- DecimalNumberExpression (Rule): # 0..3 "1e2"
- DecimalLiteral (Token): "1e2" # 0..3
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..5 "1_2_3"
- DecimalNumberExpression (Rule): # 0..5 "1_2_3"
- DecimalLiteral (Token): "1_2_3" # 0..5
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Source: >
Errors: []

Tree:
- NumericExpression (Rule): # 0..9 "10 years\n"
- DecimalNumberExpression (Rule): # 0..9 "10 years\n"
- DecimalLiteral (Token): "10" # 0..2
- YearsKeyword (Token): "years" # 3..8
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ Source: >
Errors: # 1 total
- >
Error: Expected DaysKeyword or EtherKeyword or FinneyKeyword or HoursKeyword or MinutesKeyword or SecondsKeyword or SzaboKeyword or WeeksKeyword or WeiKeyword.
╭─[crates/solidity/testing/snapshots/cst_output/NumericExpression/years_unit/input.sol:1:3]
╭─[crates/solidity/testing/snapshots/cst_output/DecimalNumberExpression/years_unit/input.sol:1:3]
1 │ 10 years
│ ───┬───
│ ╰───── Error occurred here.
───╯
Tree:
- NumericExpression (Rule): # 0..9 "10 years\n"
- DecimalNumberExpression (Rule): # 0..9 "10 years\n"
- DecimalLiteral (Token): "10" # 0..2
- SKIPPED (Token): " years\n" # 2..9
Loading

0 comments on commit 9246eb0

Please sign in to comment.