Ruby: add test case of destructured assignment with contants

This commit is contained in:
Arthur Baars
2023-03-21 18:45:07 +01:00
parent 8b90d021fa
commit a819797508
8 changed files with 88 additions and 0 deletions

View File

@@ -2878,6 +2878,16 @@ operations/operations.rb:
# 103| getStmt: [AssignLogicalOrExpr] ... ||= ...
# 103| getAnOperand/getLeftOperand: [ConstantAssignment, ConstantReadAccess] CONSTANT4
# 103| getAnOperand/getRightOperand: [IntegerLiteral] 7
# 104| getStmt: [AssignExpr] ... = ...
# 104| getAnOperand/getLeftOperand: [DestructuredLhsExpr] (..., ...)
# 104| getElement: [ConstantAssignment] FOO
# 104| getElement: [ConstantAssignment] BAR
# 104| getElement: [ConstantAssignment] FOO
# 104| getScopeExpr: [LocalVariableAccess] foo
# 104| getAnOperand/getRightOperand: [ArrayLiteral] [...]
# 104| getElement: [IntegerLiteral] 1
# 104| getElement: [IntegerLiteral] 2
# 104| getElement: [IntegerLiteral] 3
params/params.rb:
# 1| [Toplevel] params.rb
# 4| getStmt: [Method] identifier_method_params

View File

@@ -946,6 +946,33 @@ operations/operations.rb:
# 103| getAnOperand/getRightOperand: [LogicalOrExpr] ... || ...
# 103| getAnOperand/getLeftOperand/getReceiver: [ConstantReadAccess] CONSTANT4
# 103| getAnOperand/getArgument/getRightOperand: [IntegerLiteral] 7
# 104| [AssignExpr] ... = ...
# 104| getDesugared: [StmtSequence] ...
# 104| getStmt: [AssignExpr] ... = ...
# 104| getAnOperand/getLeftOperand: [ConstantAssignment] FOO
# 104| getAnOperand/getRightOperand: [MethodCall] call to []
# 104| getReceiver: [LocalVariableAccess] __synth__3
# 104| getArgument: [IntegerLiteral] 0
# 104| getStmt: [AssignExpr] ... = ...
# 104| getAnOperand/getLeftOperand: [ConstantAssignment] BAR
# 104| getAnOperand/getRightOperand: [MethodCall] call to []
# 104| getReceiver: [LocalVariableAccess] __synth__3
# 104| getArgument: [IntegerLiteral] 1
# 104| getStmt: [AssignExpr] ... = ...
# 104| getAnOperand/getLeftOperand: [ConstantAssignment] FOO
# 104| getScopeExpr: [LocalVariableAccess] foo
# 104| getAnOperand/getRightOperand: [MethodCall] call to []
# 104| getReceiver: [LocalVariableAccess] __synth__3
# 104| getArgument: [IntegerLiteral] 2
# 104| getStmt: [AssignExpr] ... = ...
# 104| getAnOperand/getLeftOperand: [LocalVariableAccess] __synth__3
# 104| getAnOperand/getRightOperand: [SplatExpr] * ...
# 104| getAnOperand/getOperand/getReceiver: [ArrayLiteral] [...]
# 104| getDesugared: [MethodCall] call to []
# 104| getReceiver: [ConstantReadAccess] Array
# 104| getArgument: [IntegerLiteral] 1
# 104| getArgument: [IntegerLiteral] 2
# 104| getArgument: [IntegerLiteral] 3
params/params.rb:
# 8| [HashLiteral] {...}
# 8| getDesugared: [MethodCall] call to []

View File

@@ -5615,6 +5615,27 @@ operations/operations.rb:
# 103| 1: [Constant] CONSTANT4
# 103| 1: [ReservedWord] ||=
# 103| 2: [Integer] 7
# 104| 72: [Assignment] Assignment
# 104| 0: [LeftAssignmentList] LeftAssignmentList
# 104| 0: [Constant] FOO
# 104| 1: [ReservedWord] ,
# 104| 2: [ScopeResolution] ScopeResolution
# 104| 0: [ReservedWord] ::
# 104| 1: [Constant] BAR
# 104| 3: [ReservedWord] ,
# 104| 4: [ScopeResolution] ScopeResolution
# 104| 0: [Identifier] foo
# 104| 1: [ReservedWord] ::
# 104| 2: [Constant] FOO
# 104| 1: [ReservedWord] =
# 104| 2: [Array] Array
# 104| 0: [ReservedWord] [
# 104| 1: [Integer] 1
# 104| 2: [ReservedWord] ,
# 104| 3: [Integer] 2
# 104| 4: [ReservedWord] ,
# 104| 5: [Integer] 3
# 104| 6: [ReservedWord] ]
# 1| [Comment] # Start with assignments to all the identifiers used below, so that they are
# 2| [Comment] # interpreted as variables.
# 22| [Comment] # Unary operations

View File

@@ -903,6 +903,12 @@ exprValue
| operations/operations.rb:102:5:102:5 | 1 | 1 | int |
| operations/operations.rb:102:31:102:31 | 7 | 7 | int |
| operations/operations.rb:103:17:103:17 | 7 | 7 | int |
| operations/operations.rb:104:1:104:3 | 0 | 0 | int |
| operations/operations.rb:104:6:104:10 | 1 | 1 | int |
| operations/operations.rb:104:13:104:20 | 2 | 2 | int |
| operations/operations.rb:104:25:104:25 | 1 | 1 | int |
| operations/operations.rb:104:28:104:28 | 2 | 2 | int |
| operations/operations.rb:104:31:104:31 | 3 | 3 | int |
| params/params.rb:41:46:41:46 | 7 | 7 | int |
| params/params.rb:47:19:47:21 | :bar | :bar | symbol |
| params/params.rb:47:24:47:24 | 2 | 2 | int |
@@ -1792,6 +1798,12 @@ exprCfgNodeValue
| operations/operations.rb:102:5:102:5 | 1 | 1 | int |
| operations/operations.rb:102:31:102:31 | 7 | 7 | int |
| operations/operations.rb:103:17:103:17 | 7 | 7 | int |
| operations/operations.rb:104:1:104:3 | 0 | 0 | int |
| operations/operations.rb:104:6:104:10 | 1 | 1 | int |
| operations/operations.rb:104:13:104:20 | 2 | 2 | int |
| operations/operations.rb:104:25:104:25 | 1 | 1 | int |
| operations/operations.rb:104:28:104:28 | 2 | 2 | int |
| operations/operations.rb:104:31:104:31 | 3 | 3 | int |
| params/params.rb:41:46:41:46 | 7 | 7 | int |
| params/params.rb:47:19:47:21 | :bar | :bar | symbol |
| params/params.rb:47:24:47:24 | 2 | 2 | int |

View File

@@ -65,6 +65,11 @@ assignments
| operations.rb:102:1:102:31 | ... \|\|= ... | \|\|= | operations.rb:102:1:102:25 | OtherConstant | operations.rb:102:31:102:31 | 7 | AssignLogicalOrExpr |
| operations.rb:103:1:103:17 | ... = ... | = | operations.rb:103:1:103:11 | CONSTANT4 | operations.rb:103:13:103:15 | ... \|\| ... | AssignExpr |
| operations.rb:103:1:103:17 | ... \|\|= ... | \|\|= | operations.rb:103:1:103:11 | CONSTANT4 | operations.rb:103:17:103:17 | 7 | AssignLogicalOrExpr |
| operations.rb:104:1:104:3 | ... = ... | = | operations.rb:104:1:104:3 | FOO | operations.rb:104:1:104:3 | call to [] | AssignExpr |
| operations.rb:104:1:104:32 | ... = ... | = | operations.rb:104:1:104:20 | (..., ...) | operations.rb:104:24:104:32 | [...] | AssignExpr |
| operations.rb:104:6:104:10 | ... = ... | = | operations.rb:104:6:104:10 | BAR | operations.rb:104:6:104:10 | call to [] | AssignExpr |
| operations.rb:104:13:104:20 | ... = ... | = | operations.rb:104:13:104:20 | FOO | operations.rb:104:13:104:20 | call to [] | AssignExpr |
| operations.rb:104:24:104:32 | ... = ... | = | operations.rb:104:24:104:32 | __synth__3 | operations.rb:104:24:104:32 | * ... | AssignExpr |
assignOperations
| operations.rb:69:1:69:8 | ... += ... | += | operations.rb:69:1:69:1 | x | operations.rb:69:6:69:8 | 128 | AssignAddExpr |
| operations.rb:70:1:70:7 | ... -= ... | -= | operations.rb:70:1:70:1 | y | operations.rb:70:6:70:7 | 32 | AssignSubExpr |

View File

@@ -230,3 +230,14 @@
| operations.rb:103:1:103:17 | ... \|\|= ... | \|\|= | operations.rb:103:17:103:17 | 7 | AssignLogicalOrExpr |
| operations.rb:103:13:103:15 | ... \|\| ... | \|\| | operations.rb:103:1:103:11 | CONSTANT4 | LogicalOrExpr |
| operations.rb:103:13:103:15 | ... \|\| ... | \|\| | operations.rb:103:17:103:17 | 7 | LogicalOrExpr |
| operations.rb:104:1:104:3 | ... = ... | = | operations.rb:104:1:104:3 | FOO | AssignExpr |
| operations.rb:104:1:104:3 | ... = ... | = | operations.rb:104:1:104:3 | call to [] | AssignExpr |
| operations.rb:104:1:104:32 | ... = ... | = | operations.rb:104:1:104:20 | (..., ...) | AssignExpr |
| operations.rb:104:1:104:32 | ... = ... | = | operations.rb:104:24:104:32 | [...] | AssignExpr |
| operations.rb:104:6:104:10 | ... = ... | = | operations.rb:104:6:104:10 | BAR | AssignExpr |
| operations.rb:104:6:104:10 | ... = ... | = | operations.rb:104:6:104:10 | call to [] | AssignExpr |
| operations.rb:104:13:104:20 | ... = ... | = | operations.rb:104:13:104:20 | FOO | AssignExpr |
| operations.rb:104:13:104:20 | ... = ... | = | operations.rb:104:13:104:20 | call to [] | AssignExpr |
| operations.rb:104:24:104:32 | * ... | * | operations.rb:104:24:104:32 | [...] | SplatExpr |
| operations.rb:104:24:104:32 | ... = ... | = | operations.rb:104:24:104:32 | * ... | AssignExpr |
| operations.rb:104:24:104:32 | ... = ... | = | operations.rb:104:24:104:32 | __synth__3 | AssignExpr |

View File

@@ -101,3 +101,4 @@ CONSTANT3 ||= 7
Foo::MemberConstant ||= 8
foo(1).bar::OtherConstant ||= 7
::CONSTANT4 ||= 7
FOO, ::BAR, foo::FOO = [1, 2, 3]

View File

@@ -7,6 +7,7 @@ unaryOperations
| operations.rb:28:1:28:12 | defined? ... | defined? | operations.rb:28:10:28:12 | foo | DefinedExpr |
| operations.rb:29:20:29:23 | * ... | * | operations.rb:29:21:29:23 | [...] | SplatExpr |
| operations.rb:29:31:29:42 | ** ... | ** | operations.rb:29:33:29:42 | {...} | HashSplatExpr |
| operations.rb:104:24:104:32 | * ... | * | operations.rb:104:24:104:32 | [...] | SplatExpr |
unaryLogicalOperations
| operations.rb:23:1:23:2 | ! ... | ! | operations.rb:23:2:23:2 | a | NotExpr |
| operations.rb:24:1:24:5 | not ... | not | operations.rb:24:5:24:5 | b | NotExpr |