diff options
| author | TSUYUSATO Kitsune <make.just.on@gmail.com> | 2023-11-23 00:06:59 +0900 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2023-11-23 14:39:30 +0000 |
| commit | 7b20dd9f91b4941e4f161dfd2d8b68b33a347a4c (patch) | |
| tree | f42dd47b085d9f1a43dd10f6c4852b5197b889f5 /test/prism | |
| parent | a31cdc6ee9bfe517e7eaffdca7c8bfeefd0c1df1 (diff) | |
[ruby/prism] Fix LocalVariableTargetNode depth in patterns
Fix https://github.com/ruby/prism/pull/1821
https://github.com/ruby/prism/commit/7d023a26b4
Diffstat (limited to 'test/prism')
| -rw-r--r-- | test/prism/fixtures/patterns.txt | 5 | ||||
| -rw-r--r-- | test/prism/snapshots/patterns.txt | 133 |
2 files changed, 110 insertions, 28 deletions
diff --git a/test/prism/fixtures/patterns.txt b/test/prism/fixtures/patterns.txt index 9f73e6ecc5..e4aa83bdf2 100644 --- a/test/prism/fixtures/patterns.txt +++ b/test/prism/fixtures/patterns.txt @@ -193,3 +193,8 @@ foo in A[ foo in bar => baz foo => bar => baz + +foo, bar, baz = 1, 2 +foo do + [1, 2] => [foo, bar] => baz +end diff --git a/test/prism/snapshots/patterns.txt b/test/prism/snapshots/patterns.txt index 665a345df0..44e15fb644 100644 --- a/test/prism/snapshots/patterns.txt +++ b/test/prism/snapshots/patterns.txt @@ -1,8 +1,8 @@ -@ ProgramNode (location: (1,0)-(195,17)) -├── locals: [:bar, :baz, :qux, :b, :a] +@ ProgramNode (location: (1,0)-(200,3)) +├── locals: [:bar, :baz, :qux, :b, :a, :foo] └── statements: - @ StatementsNode (location: (1,0)-(195,17)) - └── body: (length: 172) + @ StatementsNode (location: (1,0)-(200,3)) + └── body: (length: 174) ├── @ MatchRequiredNode (location: (1,0)-(1,10)) │ ├── value: │ │ @ CallNode (location: (1,0)-(1,3)) @@ -4575,27 +4575,104 @@ │ │ │ └── depth: 0 │ │ └── operator_loc: (194,11)-(194,13) = "=>" │ └── operator_loc: (194,4)-(194,6) = "in" - └── @ MatchRequiredNode (location: (195,0)-(195,17)) - ├── value: - │ @ CallNode (location: (195,0)-(195,3)) - │ ├── receiver: ∅ - │ ├── call_operator_loc: ∅ - │ ├── name: :foo - │ ├── message_loc: (195,0)-(195,3) = "foo" - │ ├── opening_loc: ∅ - │ ├── arguments: ∅ - │ ├── closing_loc: ∅ - │ ├── block: ∅ - │ └── flags: variable_call - ├── pattern: - │ @ CapturePatternNode (location: (195,7)-(195,17)) - │ ├── value: - │ │ @ LocalVariableTargetNode (location: (195,7)-(195,10)) - │ │ ├── name: :bar - │ │ └── depth: 0 - │ ├── target: - │ │ @ LocalVariableTargetNode (location: (195,14)-(195,17)) - │ │ ├── name: :baz - │ │ └── depth: 0 - │ └── operator_loc: (195,11)-(195,13) = "=>" - └── operator_loc: (195,4)-(195,6) = "=>" + ├── @ MatchRequiredNode (location: (195,0)-(195,17)) + │ ├── value: + │ │ @ CallNode (location: (195,0)-(195,3)) + │ │ ├── receiver: ∅ + │ │ ├── call_operator_loc: ∅ + │ │ ├── name: :foo + │ │ ├── message_loc: (195,0)-(195,3) = "foo" + │ │ ├── opening_loc: ∅ + │ │ ├── arguments: ∅ + │ │ ├── closing_loc: ∅ + │ │ ├── block: ∅ + │ │ └── flags: variable_call + │ ├── pattern: + │ │ @ CapturePatternNode (location: (195,7)-(195,17)) + │ │ ├── value: + │ │ │ @ LocalVariableTargetNode (location: (195,7)-(195,10)) + │ │ │ ├── name: :bar + │ │ │ └── depth: 0 + │ │ ├── target: + │ │ │ @ LocalVariableTargetNode (location: (195,14)-(195,17)) + │ │ │ ├── name: :baz + │ │ │ └── depth: 0 + │ │ └── operator_loc: (195,11)-(195,13) = "=>" + │ └── operator_loc: (195,4)-(195,6) = "=>" + ├── @ MultiWriteNode (location: (197,0)-(197,20)) + │ ├── lefts: (length: 3) + │ │ ├── @ LocalVariableTargetNode (location: (197,0)-(197,3)) + │ │ │ ├── name: :foo + │ │ │ └── depth: 0 + │ │ ├── @ LocalVariableTargetNode (location: (197,5)-(197,8)) + │ │ │ ├── name: :bar + │ │ │ └── depth: 0 + │ │ └── @ LocalVariableTargetNode (location: (197,10)-(197,13)) + │ │ ├── name: :baz + │ │ └── depth: 0 + │ ├── rest: ∅ + │ ├── rights: (length: 0) + │ ├── lparen_loc: ∅ + │ ├── rparen_loc: ∅ + │ ├── operator_loc: (197,14)-(197,15) = "=" + │ └── value: + │ @ ArrayNode (location: (197,16)-(197,20)) + │ ├── elements: (length: 2) + │ │ ├── @ IntegerNode (location: (197,16)-(197,17)) + │ │ │ └── flags: decimal + │ │ └── @ IntegerNode (location: (197,19)-(197,20)) + │ │ └── flags: decimal + │ ├── opening_loc: ∅ + │ ├── closing_loc: ∅ + │ └── flags: ∅ + └── @ CallNode (location: (198,0)-(200,3)) + ├── receiver: ∅ + ├── call_operator_loc: ∅ + ├── name: :foo + ├── message_loc: (198,0)-(198,3) = "foo" + ├── opening_loc: ∅ + ├── arguments: ∅ + ├── closing_loc: ∅ + ├── block: + │ @ BlockNode (location: (198,4)-(200,3)) + │ ├── locals: [] + │ ├── parameters: ∅ + │ ├── body: + │ │ @ StatementsNode (location: (199,2)-(199,29)) + │ │ └── body: (length: 1) + │ │ └── @ MatchRequiredNode (location: (199,2)-(199,29)) + │ │ ├── value: + │ │ │ @ ArrayNode (location: (199,2)-(199,8)) + │ │ │ ├── elements: (length: 2) + │ │ │ │ ├── @ IntegerNode (location: (199,3)-(199,4)) + │ │ │ │ │ └── flags: decimal + │ │ │ │ └── @ IntegerNode (location: (199,6)-(199,7)) + │ │ │ │ └── flags: decimal + │ │ │ ├── opening_loc: (199,2)-(199,3) = "[" + │ │ │ ├── closing_loc: (199,7)-(199,8) = "]" + │ │ │ └── flags: ∅ + │ │ ├── pattern: + │ │ │ @ CapturePatternNode (location: (199,12)-(199,29)) + │ │ │ ├── value: + │ │ │ │ @ ArrayPatternNode (location: (199,12)-(199,22)) + │ │ │ │ ├── constant: ∅ + │ │ │ │ ├── requireds: (length: 2) + │ │ │ │ │ ├── @ LocalVariableTargetNode (location: (199,13)-(199,16)) + │ │ │ │ │ │ ├── name: :foo + │ │ │ │ │ │ └── depth: 1 + │ │ │ │ │ └── @ LocalVariableTargetNode (location: (199,18)-(199,21)) + │ │ │ │ │ ├── name: :bar + │ │ │ │ │ └── depth: 1 + │ │ │ │ ├── rest: ∅ + │ │ │ │ ├── posts: (length: 0) + │ │ │ │ ├── opening_loc: (199,12)-(199,13) = "[" + │ │ │ │ └── closing_loc: (199,21)-(199,22) = "]" + │ │ │ ├── target: + │ │ │ │ @ LocalVariableTargetNode (location: (199,26)-(199,29)) + │ │ │ │ ├── name: :baz + │ │ │ │ └── depth: 1 + │ │ │ └── operator_loc: (199,23)-(199,25) = "=>" + │ │ └── operator_loc: (199,9)-(199,11) = "=>" + │ ├── opening_loc: (198,4)-(198,6) = "do" + │ └── closing_loc: (200,0)-(200,3) = "end" + └── flags: ∅ |
