From 87b3c786f2e75cde9756cf9db6f1d4e74d3d44fe Mon Sep 17 00:00:00 2001 From: Igor Matuszewski Date: Tue, 5 Mar 2024 13:37:36 +0100 Subject: [PATCH] tests: Add a try expr with call options This needs a lookahead of two tokens (ident, colon) to disambiguate between the try block and the call options. --- .../src/cst_output/generated/try_statement.rs | 5 ++ .../generated/0.4.11-failure.yml | 22 +++++++ .../generated/0.6.0-failure.yml | 48 +++++++++++++++ .../generated/0.6.2-success.yml | 59 +++++++++++++++++++ .../try_expr_call_options/input.sol | 4 ++ 5 files changed, 138 insertions(+) create mode 100644 crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.4.11-failure.yml create mode 100644 crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.0-failure.yml create mode 100644 crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.2-success.yml create mode 100644 crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol diff --git a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/try_statement.rs b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/try_statement.rs index 237a42c724..832f99e243 100644 --- a/crates/solidity/outputs/cargo/tests/src/cst_output/generated/try_statement.rs +++ b/crates/solidity/outputs/cargo/tests/src/cst_output/generated/try_statement.rs @@ -8,3 +8,8 @@ use crate::cst_output::runner::run; fn try_catch() -> Result<()> { run("TryStatement", "try_catch") } + +#[test] +fn try_expr_call_options() -> Result<()> { + run("TryStatement", "try_expr_call_options") +} diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.4.11-failure.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.4.11-failure.yml new file mode 100644 index 0000000000..5c51b74598 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.4.11-failure.yml @@ -0,0 +1,22 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ try foo() { x: 1 } { │ 0..20 + 2 │ bar(); │ 21..29 + 3 │ } catch { │ 30..39 + 4 │ } │ 40..41 + +Errors: # 1 total + - > + Error: Expected end of file. + ╭─[crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol:1:1] + │ + 1 │ ╭─▶ try foo() { x: 1 } { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. + ───╯ + +Tree: + - (SKIPPED): "try foo() { x: 1 } {\n bar();\n} catch {\n}\n" # (0..42) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.0-failure.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.0-failure.yml new file mode 100644 index 0000000000..a2b8db7a2f --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.0-failure.yml @@ -0,0 +1,48 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ try foo() { x: 1 } { │ 0..20 + 2 │ bar(); │ 21..29 + 3 │ } catch { │ 30..39 + 4 │ } │ 40..41 + +Errors: # 2 total + - > + Error: Expected Ampersand or AmpersandAmpersand or AmpersandEqual or Asterisk or AsteriskAsterisk or AsteriskEqual or BangEqual or Bar or BarBar or BarEqual or Caret or CaretEqual or Equal or EqualEqual or GreaterThan or GreaterThanEqual or GreaterThanGreaterThan or GreaterThanGreaterThanEqual or GreaterThanGreaterThanGreaterThan or GreaterThanGreaterThanGreaterThanEqual or LessThan or LessThanEqual or LessThanLessThan or LessThanLessThanEqual or Minus or MinusEqual or Percent or PercentEqual or Plus or PlusEqual or Semicolon or Slash or SlashEqual. + ╭─[crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol:1:14] + │ + 1 │ try foo() { x: 1 } { + │ ──┬─ + │ ╰─── Error occurred here. + ───╯ + - > + Error: Expected CatchKeyword. + ╭─[crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol:1:19] + │ + 1 │ ╭─▶ try foo() { x: 1 } { + ┆ ┆ + 4 │ ├─▶ } + │ │ + │ ╰─────── Error occurred here. + ───╯ + +Tree: + - (TryStatement): # "try foo() { x: 1 } {\n bar();\n} catch {\n}\n" (0..42) + - (try_keyword꞉ TryKeyword): "try" # (0..3) + - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " foo()" (3..9) + - (operand꞉ Expression): # " foo" (3..7) + - (LeadingTrivia) ► (Whitespace): " " # (3..4) + - (variant꞉ Identifier): "foo" # (4..7) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (7..9) + - (open_paren꞉ OpenParen): "(" # (7..8) + - (close_paren꞉ CloseParen): ")" # (8..9) + - (body꞉ Block): # " { x: 1 }" (9..18) + - (LeadingTrivia) ► (Whitespace): " " # (9..10) + - (open_brace꞉ OpenBrace): "{" # (10..11) + - (statements꞉ Statements): # " x" (11..13) + - (item꞉ Statement) ► (variant꞉ ExpressionStatement) ► (expression꞉ Expression): # " x" (11..13) + - (LeadingTrivia) ► (Whitespace): " " # (11..12) + - (variant꞉ Identifier): "x" # (12..13) + - (SKIPPED): ": 1 " # (13..17) + - (close_brace꞉ CloseBrace): "}" # (17..18) + - (SKIPPED): " {\n bar();\n} catch {\n}\n" # (18..42) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.2-success.yml b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.2-success.yml new file mode 100644 index 0000000000..8d2d4434f1 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/generated/0.6.2-success.yml @@ -0,0 +1,59 @@ +# This file is generated automatically by infrastructure scripts. Please don't edit by hand. + +Source: > + 1 │ try foo() { x: 1 } { │ 0..20 + 2 │ bar(); │ 21..29 + 3 │ } catch { │ 30..39 + 4 │ } │ 40..41 + +Errors: [] + +Tree: + - (TryStatement): # "try foo() { x: 1 } {\n bar();\n} catch {\n}\n" (0..42) + - (try_keyword꞉ TryKeyword): "try" # (0..3) + - (expression꞉ Expression) ► (variant꞉ CallOptionsExpression): # " foo() { x: 1 }" (3..18) + - (operand꞉ Expression) ► (variant꞉ FunctionCallExpression): # " foo()" (3..9) + - (operand꞉ Expression): # " foo" (3..7) + - (LeadingTrivia) ► (Whitespace): " " # (3..4) + - (variant꞉ Identifier): "foo" # (4..7) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (7..9) + - (open_paren꞉ OpenParen): "(" # (7..8) + - (close_paren꞉ CloseParen): ")" # (8..9) + - (LeadingTrivia) ► (Whitespace): " " # (9..10) + - (open_brace꞉ OpenBrace): "{" # (10..11) + - (arguments꞉ NamedArguments): # " x: 1" (11..16) + - (item꞉ NamedArgument): # " x: 1" (11..16) + - (LeadingTrivia) ► (Whitespace): " " # (11..12) + - (name꞉ Identifier): "x" # (12..13) + - (colon꞉ Colon): ":" # (13..14) + - (value꞉ Expression) ► (variant꞉ DecimalNumberExpression): # " 1" (14..16) + - (LeadingTrivia) ► (Whitespace): " " # (14..15) + - (literal꞉ DecimalLiteral): "1" # (15..16) + - (LeadingTrivia) ► (Whitespace): " " # (16..17) + - (close_brace꞉ CloseBrace): "}" # (17..18) + - (body꞉ Block): # " {\n bar();\n}" (18..31) + - (LeadingTrivia) ► (Whitespace): " " # (18..19) + - (open_brace꞉ OpenBrace): "{" # (19..20) + - (TrailingTrivia) ► (EndOfLine): "\n" # (20..21) + - (statements꞉ Statements): # " bar();\n" (21..30) + - (item꞉ Statement) ► (variant꞉ ExpressionStatement): # " bar();\n" (21..30) + - (expression꞉ Expression) ► (variant꞉ FunctionCallExpression): # " bar()" (21..28) + - (operand꞉ Expression): # " bar" (21..26) + - (LeadingTrivia) ► (Whitespace): " " # (21..23) + - (variant꞉ Identifier): "bar" # (23..26) + - (arguments꞉ ArgumentsDeclaration) ► (variant꞉ PositionalArgumentsDeclaration): # "()" (26..28) + - (open_paren꞉ OpenParen): "(" # (26..27) + - (close_paren꞉ CloseParen): ")" # (27..28) + - (semicolon꞉ Semicolon): ";" # (28..29) + - (TrailingTrivia) ► (EndOfLine): "\n" # (29..30) + - (close_brace꞉ CloseBrace): "}" # (30..31) + - (catch_clauses꞉ CatchClauses): # " catch {\n}\n" (31..42) + - (item꞉ CatchClause): # " catch {\n}\n" (31..42) + - (LeadingTrivia) ► (Whitespace): " " # (31..32) + - (catch_keyword꞉ CatchKeyword): "catch" # (32..37) + - (body꞉ Block): # " {\n}\n" (37..42) + - (LeadingTrivia) ► (Whitespace): " " # (37..38) + - (open_brace꞉ OpenBrace): "{" # (38..39) + - (TrailingTrivia) ► (EndOfLine): "\n" # (39..40) + - (close_brace꞉ CloseBrace): "}" # (40..41) + - (TrailingTrivia) ► (EndOfLine): "\n" # (41..42) diff --git a/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol new file mode 100644 index 0000000000..502285c359 --- /dev/null +++ b/crates/solidity/testing/snapshots/cst_output/TryStatement/try_expr_call_options/input.sol @@ -0,0 +1,4 @@ +try foo() { x: 1 } { + bar(); +} catch { +}