Skip to content

Commit

Permalink
[ruby/yarp] Provide a flag for the integer base
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Sep 11, 2023
1 parent b7ffa74 commit 8953fc7
Show file tree
Hide file tree
Showing 337 changed files with 1,140 additions and 22 deletions.
8 changes: 4 additions & 4 deletions test/yarp/errors_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -889,8 +889,8 @@ def test_returning_to_optional_parameters_multiple_times
ParametersNode(
[RequiredParameterNode(:a)],
[
OptionalParameterNode(:b, Location(), Location(), IntegerNode()),
OptionalParameterNode(:d, Location(), Location(), IntegerNode())
OptionalParameterNode(:b, Location(), Location(), IntegerNode(IntegerBaseFlags::DECIMAL)),
OptionalParameterNode(:d, Location(), Location(), IntegerNode(IntegerBaseFlags::DECIMAL))
],
[RequiredParameterNode(:c), RequiredParameterNode(:e)],
nil,
Expand Down Expand Up @@ -933,7 +933,7 @@ def test_setter_method_cannot_be_defined_in_an_endless_method_definition
Location(),
nil,
nil,
StatementsNode([IntegerNode()]),
StatementsNode([IntegerNode(IntegerBaseFlags::DECIMAL)]),
[],
Location(),
nil,
Expand Down Expand Up @@ -1123,7 +1123,7 @@ def test_duplicated_parameter_names
:foo,
Location(),
nil,
ParametersNode([], [OptionalParameterNode(:a, Location(), Location(), IntegerNode())], [RequiredParameterNode(:b)], RestParameterNode(:c, Location(), Location()), [], nil, nil),
ParametersNode([], [OptionalParameterNode(:a, Location(), Location(), IntegerNode(IntegerBaseFlags::DECIMAL))], [RequiredParameterNode(:b)], RestParameterNode(:c, Location(), Location()), [], nil, nil),
nil,
[:a, :b, :c],
Location(),
Expand Down
1 change: 1 addition & 0 deletions test/yarp/snapshots/alias.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
│ │ │ │ @ StatementsNode (location: (74...75))
│ │ │ │ └── body: (length: 1)
│ │ │ │ └── @ IntegerNode (location: (74...75))
│ │ │ │ └── flags: decimal
│ │ │ └── closing_loc: (75...76) = "}"
│ │ └── closing_loc: (76...77) = "\""
│ ├── old_name:
Expand Down
11 changes: 11 additions & 0 deletions test/yarp/snapshots/arrays.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,11 @@
│ │ └── @ ArrayNode (location: (22...29))
│ │ ├── elements: (length: 3)
│ │ │ ├── @ IntegerNode (location: (22...23))
│ │ │ │ └── flags: decimal
│ │ │ ├── @ IntegerNode (location: (25...26))
│ │ │ │ └── flags: decimal
│ │ │ └── @ IntegerNode (location: (28...29))
│ │ │ └── flags: decimal
│ │ ├── opening_loc: ∅
│ │ └── closing_loc: ∅
│ ├── closing_loc: (18...19) = "]"
Expand Down Expand Up @@ -116,6 +119,7 @@
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "c"
│ │ ├── @ IntegerNode (location: (60...61))
│ │ │ └── flags: decimal
│ │ └── @ SymbolNode (location: (66...68))
│ │ ├── opening_loc: (66...67) = ":"
│ │ ├── value_loc: (67...68) = "d"
Expand All @@ -141,6 +145,7 @@
│ │ │ ├── closing_loc: ∅
│ │ │ └── unescaped: "c"
│ │ ├── @ IntegerNode (location: (86...87))
│ │ │ └── flags: decimal
│ │ └── @ SymbolNode (location: (92...94))
│ │ ├── opening_loc: (92...93) = ":"
│ │ ├── value_loc: (93...94) = "d"
Expand Down Expand Up @@ -415,6 +420,7 @@
│ │ │ │ @ ArgumentsNode (location: (195...196))
│ │ │ │ └── arguments: (length: 1)
│ │ │ │ └── @ IntegerNode (location: (195...196))
│ │ │ │ └── flags: decimal
│ │ │ ├── closing_loc: (196...197) = "]"
│ │ │ ├── block: ∅
│ │ │ ├── flags:
Expand All @@ -438,6 +444,7 @@
│ │ │ @ ArgumentsNode (location: (203...204))
│ │ │ └── arguments: (length: 1)
│ │ │ └── @ IntegerNode (location: (203...204))
│ │ │ └── flags: decimal
│ │ ├── closing_loc: (204...205) = "]"
│ │ ├── block: ∅
│ │ ├── flags:
Expand All @@ -449,7 +456,9 @@
│ @ ArrayNode (location: (208...212))
│ ├── elements: (length: 2)
│ │ ├── @ IntegerNode (location: (208...209))
│ │ │ └── flags: decimal
│ │ └── @ IntegerNode (location: (211...212))
│ │ └── flags: decimal
│ ├── opening_loc: ∅
│ └── closing_loc: ∅
├── @ CallNode (location: (214...233))
Expand Down Expand Up @@ -625,6 +634,7 @@
├── @ ArrayNode (location: (277...286))
│ ├── elements: (length: 2)
│ │ ├── @ IntegerNode (location: (278...279))
│ │ │ └── flags: decimal
│ │ └── @ KeywordHashNode (location: (281...285))
│ │ └── elements: (length: 1)
│ │ └── @ AssocSplatNode (location: (281...285))
Expand All @@ -645,6 +655,7 @@
├── @ ArrayNode (location: (288...309))
│ ├── elements: (length: 2)
│ │ ├── @ IntegerNode (location: (289...290))
│ │ │ └── flags: decimal
│ │ └── @ KeywordHashNode (location: (292...308))
│ │ └── elements: (length: 3)
│ │ ├── @ AssocSplatNode (location: (292...296))
Expand Down
6 changes: 6 additions & 0 deletions test/yarp/snapshots/blocks.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@
│ │ @ ArgumentsNode (location: (48...49))
│ │ └── arguments: (length: 1)
│ │ └── @ IntegerNode (location: (48...49))
│ │ └── flags: decimal
│ ├── closing_loc: (49...50) = ")"
│ ├── block:
│ │ @ BlockNode (location: (51...74))
Expand Down Expand Up @@ -329,6 +330,7 @@
│ │ │ │ │ │ @ ArgumentsNode (location: (161...162))
│ │ │ │ │ │ └── arguments: (length: 1)
│ │ │ │ │ │ └── @ IntegerNode (location: (161...162))
│ │ │ │ │ │ └── flags: decimal
│ │ │ │ │ ├── closing_loc: (162...163) = "]"
│ │ │ │ │ ├── block: ∅
│ │ │ │ │ ├── flags:
Expand Down Expand Up @@ -502,6 +504,7 @@
│ │ │ │ │ ├── operator_loc: (265...266) = "="
│ │ │ │ │ └── value:
│ │ │ │ │ @ IntegerNode (location: (267...268))
│ │ │ │ │ └── flags: decimal
│ │ │ │ ├── posts: (length: 0)
│ │ │ │ ├── rest: ∅
│ │ │ │ ├── keywords: (length: 1)
Expand Down Expand Up @@ -561,6 +564,7 @@
│ ├── name_loc: (292...296) = "fork"
│ ├── value:
│ │ @ IntegerNode (location: (299...300))
│ │ └── flags: decimal
│ └── operator_loc: (297...298) = "="
├── @ CallNode (location: (301...316))
│ ├── receiver: ∅
Expand Down Expand Up @@ -688,11 +692,13 @@
│ │ │ │ │ │ │ ├── name_loc: (365...367) = "a:"
│ │ │ │ │ │ │ └── value:
│ │ │ │ │ │ │ @ IntegerNode (location: (368...369))
│ │ │ │ │ │ │ └── flags: decimal
│ │ │ │ │ │ └── @ KeywordParameterNode (location: (373...377))
│ │ │ │ │ │ ├── name: :b
│ │ │ │ │ │ ├── name_loc: (373...375) = "b:"
│ │ │ │ │ │ └── value:
│ │ │ │ │ │ @ IntegerNode (location: (376...377))
│ │ │ │ │ │ └── flags: decimal
│ │ │ │ │ ├── keyword_rest: ∅
│ │ │ │ │ └── block: ∅
│ │ │ │ ├── locals: (length: 0)
Expand Down
19 changes: 19 additions & 0 deletions test/yarp/snapshots/break.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
│ │ │ │ @ StatementsNode (location: (14...15))
│ │ │ │ └── body: (length: 1)
│ │ │ │ └── @ IntegerNode (location: (14...15))
│ │ │ │ └── flags: decimal
│ │ │ ├── opening_loc: (13...14) = "("
│ │ │ └── closing_loc: (15...16) = ")"
│ │ ├── @ ParenthesesNode (location: (18...21))
│ │ │ ├── body:
│ │ │ │ @ StatementsNode (location: (19...20))
│ │ │ │ └── body: (length: 1)
│ │ │ │ └── @ IntegerNode (location: (19...20))
│ │ │ │ └── flags: decimal
│ │ │ ├── opening_loc: (18...19) = "("
│ │ │ └── closing_loc: (20...21) = ")"
│ │ └── @ ParenthesesNode (location: (23...26))
│ │ ├── body:
│ │ │ @ StatementsNode (location: (24...25))
│ │ │ └── body: (length: 1)
│ │ │ └── @ IntegerNode (location: (24...25))
│ │ │ └── flags: decimal
│ │ ├── opening_loc: (23...24) = "("
│ │ └── closing_loc: (25...26) = ")"
│ └── keyword_loc: (7...12) = "break"
Expand All @@ -37,22 +40,29 @@
│ │ @ ArgumentsNode (location: (34...35))
│ │ └── arguments: (length: 1)
│ │ └── @ IntegerNode (location: (34...35))
│ │ └── flags: decimal
│ └── keyword_loc: (28...33) = "break"
├── @ BreakNode (location: (37...50))
│ ├── arguments:
│ │ @ ArgumentsNode (location: (43...50))
│ │ └── arguments: (length: 3)
│ │ ├── @ IntegerNode (location: (43...44))
│ │ │ └── flags: decimal
│ │ ├── @ IntegerNode (location: (46...47))
│ │ │ └── flags: decimal
│ │ └── @ IntegerNode (location: (49...50))
│ │ └── flags: decimal
│ └── keyword_loc: (37...42) = "break"
├── @ BreakNode (location: (52...65))
│ ├── arguments:
│ │ @ ArgumentsNode (location: (58...65))
│ │ └── arguments: (length: 3)
│ │ ├── @ IntegerNode (location: (58...59))
│ │ │ └── flags: decimal
│ │ ├── @ IntegerNode (location: (61...62))
│ │ │ └── flags: decimal
│ │ └── @ IntegerNode (location: (64...65))
│ │ └── flags: decimal
│ └── keyword_loc: (52...57) = "break"
├── @ BreakNode (location: (67...82))
│ ├── arguments:
Expand All @@ -61,8 +71,11 @@
│ │ └── @ ArrayNode (location: (73...82))
│ │ ├── elements: (length: 3)
│ │ │ ├── @ IntegerNode (location: (74...75))
│ │ │ │ └── flags: decimal
│ │ │ ├── @ IntegerNode (location: (77...78))
│ │ │ │ └── flags: decimal
│ │ │ └── @ IntegerNode (location: (80...81))
│ │ │ └── flags: decimal
│ │ ├── opening_loc: (73...74) = "["
│ │ └── closing_loc: (81...82) = "]"
│ └── keyword_loc: (67...72) = "break"
Expand All @@ -75,7 +88,9 @@
│ │ │ @ StatementsNode (location: (93...98))
│ │ │ └── body: (length: 2)
│ │ │ ├── @ IntegerNode (location: (93...94))
│ │ │ │ └── flags: decimal
│ │ │ └── @ IntegerNode (location: (97...98))
│ │ │ └── flags: decimal
│ │ ├── opening_loc: (89...90) = "("
│ │ └── closing_loc: (99...100) = ")"
│ └── keyword_loc: (84...89) = "break"
Expand All @@ -97,6 +112,7 @@
│ │ │ @ StatementsNode (location: (117...118))
│ │ │ └── body: (length: 1)
│ │ │ └── @ IntegerNode (location: (117...118))
│ │ │ └── flags: decimal
│ │ ├── opening_loc: (116...117) = "("
│ │ └── closing_loc: (118...119) = ")"
│ └── keyword_loc: (111...116) = "break"
Expand All @@ -121,6 +137,7 @@
│ │ │ │ │ @ ArgumentsNode (location: (133...135))
│ │ │ │ │ └── arguments: (length: 1)
│ │ │ │ │ └── @ IntegerNode (location: (133...135))
│ │ │ │ │ └── flags: decimal
│ │ │ │ └── keyword_loc: (127...132) = "break"
│ │ │ ├── opening_loc: (125...126) = "{"
│ │ │ └── closing_loc: (136...137) = "}"
Expand All @@ -133,6 +150,7 @@
│ │ @ ArgumentsNode (location: (141...143))
│ │ └── arguments: (length: 1)
│ │ └── @ IntegerNode (location: (141...143))
│ │ └── flags: decimal
│ ├── closing_loc: ∅
│ ├── block: ∅
│ ├── flags:
Expand Down Expand Up @@ -182,6 +200,7 @@
│ @ ArgumentsNode (location: (166...168))
│ └── arguments: (length: 1)
│ └── @ IntegerNode (location: (166...168))
│ └── flags: decimal
├── closing_loc: ∅
├── block: ∅
├── flags:
Expand Down
7 changes: 7 additions & 0 deletions test/yarp/snapshots/classes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
│ │ ├── name_loc: (8...9) = "a"
│ │ ├── value:
│ │ │ @ IntegerNode (location: (12...13))
│ │ │ └── flags: decimal
│ │ └── operator_loc: (10...11) = "="
│ ├── end_keyword_loc: (14...17) = "end"
│ └── name: :A
Expand Down Expand Up @@ -97,6 +98,7 @@
│ │ ├── name_loc: (89...90) = "a"
│ │ ├── value:
│ │ │ @ IntegerNode (location: (93...94))
│ │ │ └── flags: decimal
│ │ └── operator_loc: (91...92) = "="
│ ├── end_keyword_loc: (95...98) = "end"
│ └── name: :A
Expand Down Expand Up @@ -284,13 +286,15 @@
│ │ └── @ CallNode (location: (316...321))
│ │ ├── receiver:
│ │ │ @ IntegerNode (location: (316...317))
│ │ │ └── flags: decimal
│ │ ├── call_operator_loc: ∅
│ │ ├── message_loc: (318...319) = "+"
│ │ ├── opening_loc: ∅
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (320...321))
│ │ │ └── arguments: (length: 1)
│ │ │ └── @ IntegerNode (location: (320...321))
│ │ │ └── flags: decimal
│ │ ├── closing_loc: ∅
│ │ ├── block: ∅
│ │ ├── flags:
Expand All @@ -308,13 +312,15 @@
│ │ └── @ CallNode (location: (341...346))
│ │ ├── receiver:
│ │ │ @ IntegerNode (location: (341...342))
│ │ │ └── flags: decimal
│ │ ├── call_operator_loc: ∅
│ │ ├── message_loc: (343...344) = "+"
│ │ ├── opening_loc: ∅
│ │ ├── arguments:
│ │ │ @ ArgumentsNode (location: (345...346))
│ │ │ └── arguments: (length: 1)
│ │ │ └── @ IntegerNode (location: (345...346))
│ │ │ └── flags: decimal
│ │ ├── closing_loc: ∅
│ │ ├── block: ∅
│ │ ├── flags:
Expand All @@ -339,6 +345,7 @@
│ │ @ ArgumentsNode (location: (364...365))
│ │ └── arguments: (length: 1)
│ │ └── @ IntegerNode (location: (364...365))
│ │ └── flags: decimal
│ ├── closing_loc: (365...366) = "]"
│ ├── block: ∅
│ ├── flags:
Expand Down
5 changes: 5 additions & 0 deletions test/yarp/snapshots/constants.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@
│ ├── operator_loc: (26...27) = "="
│ └── value:
│ @ IntegerNode (location: (28...29))
│ └── flags: decimal
├── @ ConstantWriteNode (location: (31...36))
│ ├── name: :A
│ ├── name_loc: (31...32) = "A"
│ ├── value:
│ │ @ IntegerNode (location: (35...36))
│ │ └── flags: decimal
│ └── operator_loc: (33...34) = "="
├── @ ConstantReadNode (location: (38...41))
│ └── name: :ABC
Expand All @@ -71,6 +73,7 @@
│ │ @ ArgumentsNode (location: (47...48))
│ │ └── arguments: (length: 1)
│ │ └── @ IntegerNode (location: (47...48))
│ │ └── flags: decimal
│ ├── closing_loc: ∅
│ ├── block: ∅
│ ├── flags:
Expand Down Expand Up @@ -262,6 +265,7 @@
│ ├── operator_loc: (141...142) = "="
│ └── value:
│ @ IntegerNode (location: (143...144))
│ └── flags: decimal
├── @ ConstantPathWriteNode (location: (146...156))
│ ├── target:
│ │ @ ConstantPathNode (location: (146...152))
Expand All @@ -279,6 +283,7 @@
│ ├── operator_loc: (153...154) = "="
│ └── value:
│ @ IntegerNode (location: (155...156))
│ └── flags: decimal
├── @ ConstantPathNode (location: (158...164))
│ ├── parent:
│ │ @ ConstantPathNode (location: (158...161))
Expand Down
Loading

0 comments on commit 8953fc7

Please sign in to comment.