diff options
author | Kevin Newton <kddnewton@gmail.com> | 2023-09-10 13:47:36 -0400 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2023-09-13 00:55:04 +0000 |
commit | c421f08f6b5c1cc9a52e713a81595a393ff66e8c (patch) | |
tree | 97c6022eb6330b1a7ec9e9d8f2ba644fca3cccdc /test/yarp | |
parent | 6e64d4370456190541705ec4c6cf3af6bf4ac647 (diff) | |
download | ruby-c421f08f6b5c1cc9a52e713a81595a393ff66e8c.tar.gz |
[ruby/yarp] Handle parsing local variable singleton method definition
https://github.com/ruby/yarp/commit/943204d56f
Diffstat (limited to 'test/yarp')
-rw-r--r-- | test/yarp/fixtures/methods.txt | 3 | ||||
-rw-r--r-- | test/yarp/snapshots/methods.txt | 86 |
2 files changed, 58 insertions, 31 deletions
diff --git a/test/yarp/fixtures/methods.txt b/test/yarp/fixtures/methods.txt index de17645bb5..ac561363f8 100644 --- a/test/yarp/fixtures/methods.txt +++ b/test/yarp/fixtures/methods.txt @@ -163,3 +163,6 @@ end def foo(_a, _a, b, c) end + +foo = 1 +def foo.bar; end diff --git a/test/yarp/snapshots/methods.txt b/test/yarp/snapshots/methods.txt index 6f89c81514..da62c74ddd 100644 --- a/test/yarp/snapshots/methods.txt +++ b/test/yarp/snapshots/methods.txt @@ -1,8 +1,8 @@ -@ ProgramNode (location: (0...1194)) -├── locals: [:a, :c] +@ ProgramNode (location: (0...1220)) +├── locals: [:a, :c, :foo] └── statements: - @ StatementsNode (location: (0...1194)) - └── body: (length: 60) + @ StatementsNode (location: (0...1220)) + └── body: (length: 62) ├── @ DefNode (location: (0...23)) │ ├── name: :foo │ ├── name_loc: (4...7) = "foo" @@ -1584,32 +1584,56 @@ │ ├── rparen_loc: (1147...1148) = ")" │ ├── equal_loc: ∅ │ └── end_keyword_loc: (1164...1167) = "end" - └── @ DefNode (location: (1169...1194)) - ├── name: :foo - ├── name_loc: (1173...1176) = "foo" - ├── receiver: ∅ - ├── parameters: - │ @ ParametersNode (location: (1177...1189)) - │ ├── requireds: (length: 4) - │ │ ├── @ RequiredParameterNode (location: (1177...1179)) - │ │ │ └── name: :_a - │ │ ├── @ RequiredParameterNode (location: (1181...1183)) - │ │ │ └── name: :_a - │ │ ├── @ RequiredParameterNode (location: (1185...1186)) - │ │ │ └── name: :b - │ │ └── @ RequiredParameterNode (location: (1188...1189)) - │ │ └── name: :c - │ ├── optionals: (length: 0) - │ ├── rest: ∅ - │ ├── posts: (length: 0) - │ ├── keywords: (length: 0) - │ ├── keyword_rest: ∅ - │ └── block: ∅ + ├── @ DefNode (location: (1169...1194)) + │ ├── name: :foo + │ ├── name_loc: (1173...1176) = "foo" + │ ├── receiver: ∅ + │ ├── parameters: + │ │ @ ParametersNode (location: (1177...1189)) + │ │ ├── requireds: (length: 4) + │ │ │ ├── @ RequiredParameterNode (location: (1177...1179)) + │ │ │ │ └── name: :_a + │ │ │ ├── @ RequiredParameterNode (location: (1181...1183)) + │ │ │ │ └── name: :_a + │ │ │ ├── @ RequiredParameterNode (location: (1185...1186)) + │ │ │ │ └── name: :b + │ │ │ └── @ RequiredParameterNode (location: (1188...1189)) + │ │ │ └── name: :c + │ │ ├── optionals: (length: 0) + │ │ ├── rest: ∅ + │ │ ├── posts: (length: 0) + │ │ ├── keywords: (length: 0) + │ │ ├── keyword_rest: ∅ + │ │ └── block: ∅ + │ ├── body: ∅ + │ ├── locals: [:_a, :b, :c] + │ ├── def_keyword_loc: (1169...1172) = "def" + │ ├── operator_loc: ∅ + │ ├── lparen_loc: (1176...1177) = "(" + │ ├── rparen_loc: (1189...1190) = ")" + │ ├── equal_loc: ∅ + │ └── end_keyword_loc: (1191...1194) = "end" + ├── @ LocalVariableWriteNode (location: (1196...1203)) + │ ├── name: :foo + │ ├── depth: 0 + │ ├── name_loc: (1196...1199) = "foo" + │ ├── value: + │ │ @ IntegerNode (location: (1202...1203)) + │ │ └── flags: decimal + │ └── operator_loc: (1200...1201) = "=" + └── @ DefNode (location: (1204...1220)) + ├── name: :bar + ├── name_loc: (1212...1215) = "bar" + ├── receiver: + │ @ LocalVariableReadNode (location: (1208...1211)) + │ ├── name: :foo + │ └── depth: 0 + ├── parameters: ∅ ├── body: ∅ - ├── locals: [:_a, :b, :c] - ├── def_keyword_loc: (1169...1172) = "def" - ├── operator_loc: ∅ - ├── lparen_loc: (1176...1177) = "(" - ├── rparen_loc: (1189...1190) = ")" + ├── locals: [] + ├── def_keyword_loc: (1204...1207) = "def" + ├── operator_loc: (1211...1212) = "." + ├── lparen_loc: ∅ + ├── rparen_loc: ∅ ├── equal_loc: ∅ - └── end_keyword_loc: (1191...1194) = "end" + └── end_keyword_loc: (1217...1220) = "end" |